Saturday, 20 December 2014

Generate pdf using rdlc c#


In this article I will demonstrate you how to create rdlc report in asp.net.

Microsoft made it very simple to generate PDF by using the “Microsoft.ReportViewer.WebForms”
Take the reference of Microsoft.ReportViewer.WebForms to work with RDLC. It will appear in your reference folder like below;

clip_image001

Thursday, 18 December 2014

Convert number to words c# code


In many applications you need to convert numbers into words like in bank statement invoice or converting the currency values into words.
Below application will really help you to convert the numbers into words.
You just need to pass the numbers like; “23456” it will convert Twenty Three Thousands Four Hundred Fifty Six.

Application will support till the lakhs if you want to extend it you can extend till what you need.


Friday, 12 December 2014

stylecop visual studio

 

A simple design page : When inserting the Name checking the text value

 

image

Setting of Style Cop Rules and Properties

image

 

Rule Selection

a) Click on the check box to check or uncheck the rules to apply for code analysis, By default it is checked for all rules

image

Company Information

image

Run the style Cop to check the code analysis

Either from Toolsà Run the Style Cop

Or Right click on project explorer à Run the Style Cop

image

 

When you run it it will give the Warnings if it will break the rules.

image

On Running the Style Cop

image

Output Code snippet

After rectifying all the warning by Style cop getting result Violation count : 0

image

Exclude the Particular File from Style Cope

image

Creating Custom Rule

Steps to Creating Custom rule

1> Creating One Class Library file

2> Import the two DLL and reference it to project

using Microsoft.StyleCop.CSharp;

using Microsoft.StyleCop;

From C:\Program Files\Microsoft StyleCop 4.4.0.14

3> Add one XML File for configuration

4> Successfully Build the code in Release mode

5> Place the DLL into

C:\Program Files\Microsoft StyleCop 4.4.0.14

Code Snippet for Custom Rule to Check Data Base is Closed or Not “.CS file”

image

XML Code Snippet

image

Get the Custom Style Cop Rule into project

image

Custom Warning

image

Tuesday, 9 December 2014

c# combine multiple pdf into one

 
*Note : Take reference of itextSharp API DLL reference to work with below application

We were facing the problem of creating the multiple PDF file and send it to clients. So they have to take the print of PDF one by one so, created the application to combine multiple PDF files into one PDF.


clip_image001


Friday, 28 November 2014

vs2013 New Features


Feedback & Notifications

In VS2013 product we can provide the feedback about the product
There it provided different options and you can Report to the Bug to Microsoft directly also
image
  You can see the latest updates on product by seeing the notification from clicking the icon. It will give the count of notification on flag icon just beside of quick launch.


image


Code Lens

This is wonderful features introduce by VS2013, by using it you can see the references of particular method, Constructor and Class in your application in one instance.
image
Just keep the mouse over there it will give you the information of all the references and for more detail you can click so it will redirect to that piece of code or just put the mouse so it will show you the code.
image


Peek Definition

In Previous version of Visual studio, to get the definition of any function we need to do F12 and it will redirect to respective method. Now with the feature of F12 Microsoft introduce feature of Alt + F12. It will open a window in same page, which have function definition.
Just do Alt + F12 or Right click on Method.
image
You will get the peek definition as below; Than page will open which the piece of belongs to
image


Code Preview Scroll Bar

You can customize the Scroll bar for your code preview and it improve the functionality of viewing the code.
image
Scroll will be look like a narrow code window and on doing the mouse over to the scroll it will be look like the left screen.


CodeMap – On Debugging (flow chart Display)

It helps to analysis the flow of the code at time of debugging.
Code map Icon will be visible at the time of debugging and when you click on it, it will open the Call stack.
image
On Right side window will be open which is having the Call stacks with the list of method that pass and list of method will come. It shows the list of debug point in the methods and where exctly we are also.
image

New Blue Theme

Microsoft Introduces theme in VS2012, Now they increase the collection of themes and introduce the blue theme.
You can choose the themes from Options à General
image
Blue theme will look like vs2010 IDE
image


Navigate To By Ctrl+,
Using the new Navigate To, smart semantic search will open and there you can type the method name or Class name it will open in the list with the search;
Just Type the ctrl + , and search you are looking for and by clicking on search result it navigate to search result.
image
 
Enhanced Scrollbar
Enhanced Scrollbar provides the vertical scrollbar a visual cues.
It mark the scroll bar with Quick view for debug point, Unsaved Value, Error, Current Position and Search result.
It brings the information into finger tips and when you click on that mark it open that piece of code where the mark belongs to.
image


Auto Brace Complete
Auto Brace is the power tool feature introduces in vs2013, As pet it parenthesis, Braces and Quotes will automatically
added for you when you open it.
image


Move Line Up/ Down
One another feature for power tool, you can move up or down the selected piece of code by using alt + arrow up and
down by alt + arrow Down
image






Monday, 10 November 2014

sequence of events in master page and content page

In your application if you are using Master page, Content Page (Child Page) and User controls. Page life cycle for different pages have different events. Below content you can see the  Sequence of events for Master Page, Content Page and User Controls.

Problem: Why its required?
Many time its happen that you need the value of master page into Child page or the user control page into Webpage. Then from below description you will know that what is the possibility.

Creating the three file in application.
1. Site1,Master
2. WebForm1,aspx
3. WebUserControl1.aspx

Saturday, 1 November 2014

Converting String to Int in C#

String is the reference type in C# and int is the value type.(What is Ref and Value type )
So, The way of maintain the memory location are quite different for both of them and to converting the value to refrence is called boxing in C#.

If you see the below program;
static void Main(string[] args)
        {
            int i = 123;
            string str = "123";

            if (str.Equals(i))
                Console.WriteLine("Success");
            else
                Console.WriteLine("fails");

        }

Sunday, 28 September 2014

ADO.Net Framework as Database Helper

 Interface to work with ADO.Net sample and it will work like DB helper class


using System;
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Data.SqlClient;
using System.Collections;
using System.Xml;
using System.Web.UI;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Caching;
using System.Text;

/// <summary>
/// Summary description for DataBaseInterface
/// </summary>
///

namespace Ramosh.Support.DataLayer
{
    public class DBInterface : BasePage<DBInterface>
    {
        /// <summary>
        /// Enum of DataTables in DataSet
        /// </summary>
        public enum Tables
        {
            Statuses = 0,
            Types,
            Categories
        }

        public enum eGetValueDropDown
        {
            STATE ,
            CITY ,
            LOCATION
        }

        #region Properties & Fields

        /// <summary>
        /// Property to manage the DataSet of static data
        /// </summary>
        private static DataSet StaticDataSet
        {
            get
            {
                // Get DataSet from Cache
                Cache oCache = HttpContext.Current.Cache;
                DataSet ds = (DataSet)oCache[StaticDataSetCache];

                // If the DataSet is not in Cache then generate it and cache it
                if (ds == null)
                {
                    ds = CacheStaticData();
                }

                return ds;
            }
        }

        private const string StaticDataSetCache = "StaticDataSetCache";

        #endregion

        /// <summary>
        /// Bind static data to a ListControl (DropDownList / ListBox / RadioButtonList / CheckBoxList) with a header value
        /// </summary>
        /// <param name="listControl"></param>
        /// <param name="tableIndex"></param>
        /// <param name="header"></param>
        public static void Bind(ListControl listControl, Tables tableIndex, string header)
        {
            // Get the DataTable from the cached DataSet
            DataTable dt = GetData(tableIndex);

            // Set the DataValueField and DataTextField of the LsitControl       
            listControl.DataValueField = dt.Columns[0].ToString();
            listControl.DataTextField = dt.Columns[1].ToString();

            // Bind the data to the LsitControl
            listControl.DataSource = dt;
            listControl.DataBind();

            // Add the header row if required
            if (header.Length > 0)
            {
                listControl.Items.Insert(0, new ListItem("- " + header + " -", "0"));
            }
        }

        /// <summary>
        /// Clear the Static Data from the Cache
        /// </summary>
        public static void ClearCache()
        {
            Cache oCache = HttpContext.Current.Cache;
            oCache.Remove("StaticDataSetCache");
        }

        /// <summary>
        /// Cache Static Data
        /// </summary>
        public static DataSet CacheStaticData()
        {
            Cache oCache = System.Web.HttpContext.Current.Cache;

            // Get Static DataSet
            DataSet ds = GetDataSet(Convert.ToString(eGetValueDropDown.STATE));
            // Insert into cache
            oCache.Insert(StaticDataSetCache, ds);

            return ds;
        }

        /// <summary>
        /// Get a DataTable from the cached DataSet
        /// </summary>
        /// <param name="tableIndex"></param>
        /// <returns></returns>
        public static DataTable GetData(Tables tableIndex)
        {
            return StaticDataSet.Tables[(int)tableIndex];
        }


      


        public SqlConnection con;
        private static int SQL_DEADLOCK_ERROR_NUM = 1205;
        #region database connection stuffs and parmeters
        /// <summary>
        /// Returns a new SqlConnection.
        /// </summary>
        /// <returns>SqlConnection object</returns>
        public static SqlConnection GetConnection()
        {
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = ConfigurationManager.ConnectionStrings["ASPNETDB"].ConnectionString; ;
            return conn;
        }
        /// <summary>
        /// Helper method to set properties of command object and its parameters
        /// </summary>
        /// <param name="spParams"></param>
        /// <param name="command"></param>
        private static void InflateCommandObject(SpParamCollection spParams, SqlCommand command)
        {
            command.CommandTimeout = 0;//Config.ExecuteTimeout;
            command.CommandType = CommandType.StoredProcedure;

            if (null == spParams) return;

            foreach (SpParam param in spParams)
            {
                if (true == param.ParamDirectionOut)
                    command.Parameters.Add(param.Name, param.Value).Direction = ParameterDirection.Output;
                else
                    command.Parameters.Add(param.Name, param.Value);
            }
        }


        #endregion

        # region Exceute non query command and insert and update the vale in databas
        // <summary>
        /// Overloaded method for ExecProcNonQuery that uses default sql connection,and it return integer which is getting from DB
        /// </summary>
        /// <param name="procName"></param>
        /// <param name="spParams"></param>
        public static Int16 ExecProcNonQueryText(string procName, SpParamCollection spParams)
        {
            Int16 ret = 0;
            ExecProcNonQueryText(procName, spParams, GetConnection(), out ret);
            return ret;
        }

        /// <summary>
        /// Execute the given stored procedure. No results are expected from the proc.
        /// </summary>
        /// <param name="procName"></param>
        /// <param name="spParams"></param>
        public static void ExecProcNonQueryText(string procName, SpParamCollection spParams, SqlConnection conn, out Int16 ret)
        {
            SqlCommand command = new SqlCommand();
            try
            {
                conn.Open();
               
                command.Connection = conn;
                command.CommandType = CommandType.Text;
                command.CommandText = procName;
                //command.ExecuteNonQuery();
               // InflateCommandObject(spParams, command);
               
             //   command.CommandTimeout = 0;
                ret = (Int16)command.ExecuteNonQuery();
            }
            catch (SqlException sqlEx)
            {
                if (SQL_DEADLOCK_ERROR_NUM == sqlEx.Number)
                {
                    try
                    {
                        command.CommandTimeout = 60;
                        ret = (Int16)command.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        throw ex; ;
                    }
                }
                else
                {
                    throw sqlEx;
                }
            }
            catch (Exception ex)
            {
                throw ex; ;
            }
            finally
            {
                command = null;
                if (null != conn)
                {
                    conn.Close();
                    conn.Dispose();
                }

            }
        }
        // <summary>
        /// Overloaded method for ExecProcNonQuery that uses default sql connection,and it return integer which is getting from DB
        /// </summary>
        /// <param name="procName"></param>
        /// <param name="spParams"></param>
        public static Int16 ExecProcNonQuery(string procName, SpParamCollection spParams)
        {
            Int16 ret = 0;
            ExecProcNonQuery(procName, spParams, GetConnection(), out ret);
            return ret;
        }
        /// <summary>
        /// Execute the given stored procedure. No results are expected from the proc.
        /// </summary>
        /// <param name="procName"></param>
        /// <param name="spParams"></param>
        public static void ExecProcNonQuery(string procName, SpParamCollection spParams, SqlConnection conn, out Int16 ret)
        {
            SqlCommand command = new SqlCommand(procName, conn);


            try
            {
                InflateCommandObject(spParams, command);
                conn.Open();
                command.CommandTimeout = 0;
                ret = (Int16)command.ExecuteNonQuery();
            }
            catch (SqlException sqlEx)
            {
                if (SQL_DEADLOCK_ERROR_NUM == sqlEx.Number)
                {
                    try
                    {
                        command.CommandTimeout = 60;
                        ret = (Int16)command.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        throw ex; ;
                    }
                }
                else
                {
                    throw sqlEx;
                }
            }
            catch (Exception ex)
            {
                throw ex; ;
            }
            finally
            {
                command = null;
                if (null != conn)
                {
                    conn.Close();
                    conn.Dispose();
                }

            }
        }
        # endregion

        #region To populate the data into the datareader from database

        /// Overloaded method for ExecProcNonQuery that uses default sql connection,and it return datareader which is getting from DB
        /// </summary>
        /// <param name="procName"></param>
        /// <param name="spParams"></param>
        public static SqlDataReader ExecProcAndPopulateDataReader(string procName, SpParamCollection spParams)
        {
            SqlDataReader dr;
            ExecProcAndPopulateDataReader(procName, spParams, out dr, GetConnection());
            return dr;
        }

        /// Overloaded method for ExecProcNonQuery that uses default sql connection,and it return datareader which is getting from DB
        /// </summary>
        /// <param name="procName"></param>
        /// <param name="spParams"></param>
        public static SqlDataReader ExecProcAndPopulateDataReaderText(string QueryText,SpParamCollection spParams)
        {
            SqlDataReader dr;
            ExecProcAndPopulateDataReaderTextType(QueryText, out dr, GetConnection());
            return dr;
        }

        public static void ExecProcAndPopulateDataReaderTextType(string QueryText,  out SqlDataReader dr, SqlConnection conn)
        {
            SqlCommand command = new SqlCommand(QueryText, conn);
            conn.Open();

            try
            {
                command.CommandType = CommandType.Text;
              //  InflateCommandObject(spParams, command);
                dr = command.ExecuteReader();
            }
            catch (SqlException sqlEx)
            {
                if (SQL_DEADLOCK_ERROR_NUM == sqlEx.Number)
                {
                    try
                    {
                        dr = command.ExecuteReader();
                    }
                    catch (Exception ex)
                    {
                        throw ex; ;
                    }
                }
                else
                {
                    throw sqlEx;
                }
            }
            catch (Exception ex)
            {
                throw ex; ;
            }
        }


        /// <summary>
        /// Execute the given stored procedure and then populate the DataReader with the data.
        /// </summary>
        /// <param name="procName"></param>
        /// <param name="spParams"></param>
        /// <param name="dr"></param>
        public static void ExecProcAndPopulateDataReader(string procName, SpParamCollection spParams, out SqlDataReader dr, SqlConnection conn)
        {
            SqlCommand command = new SqlCommand(procName, conn);
            conn.Open();

            try
            {
                InflateCommandObject(spParams, command);
                dr = command.ExecuteReader();
            }
            catch (SqlException sqlEx)
            {
                if (SQL_DEADLOCK_ERROR_NUM == sqlEx.Number)
                {
                    try
                    {
                        dr = command.ExecuteReader();
                    }
                    catch (Exception ex)
                    {
                        throw ex; ;
                    }
                }
                else
                {
                    throw sqlEx;
                }
            }
            catch (Exception ex)
            {
                throw ex; ;
            }
        }
        #endregion

        #region Use of dataset to populate the balue from database and put into dataset

        /// <summary>
        /// Overloaded method for ExecProcAndFillDataSet that uses default sql connection
        /// </summary>
        /// <param name="procName"></param>
        /// <param name="spParams"></param>
        /// <param name="ds"></param>
        public static void ExecProcAndFillDataSetText(string procName, SpParamCollection spParams, DataSet ds)
        {
            ExecProcAndFillDataSetText(procName, spParams, ds, GetConnection());
        }
        /// <summary>
        /// Execute the given stored procedure and then populate the DataSet with the returned data.
        /// </summary>
        /// <param name="procName"></param>
        /// <param name="spParams"></param>
        /// <param name="ds"></param>
        public static void ExecProcAndFillDataSetText(string procName, SpParamCollection spParams, DataSet ds, SqlConnection conn)
        {
            SqlCommand command = new SqlCommand(procName, conn);
            command.CommandType = CommandType.Text;
            SqlDataAdapter dataAdapter = new SqlDataAdapter(command);
            try
            {
                InflateCommandObject(spParams, command);

                //Fill DataSet

                dataAdapter.Fill(ds);
            }
            catch (SqlException sqlEx)
            {
                if (SQL_DEADLOCK_ERROR_NUM == sqlEx.Number)
                {
                    try
                    {
                        dataAdapter.Fill(ds);
                    }
                    catch (Exception ex)
                    {
                        throw ex; ;
                    }
                }
                else
                {
                    throw sqlEx;
                }
            }
            catch (Exception ex)
            {
                throw ex; ;
            }
            finally
            {
                command = null;
                if (null != conn)
                {
                    conn.Close();
                    conn.Dispose();
                }
            }
        }


        /// <summary>
        /// Overloaded method for ExecProcAndFillDataSet that uses default sql connection
        /// </summary>
        /// <param name="procName"></param>
        /// <param name="spParams"></param>
        /// <param name="ds"></param>
        public static void ExecProcAndFillDataSet(string procName, SpParamCollection spParams, DataSet ds)
        {
            ExecProcAndFillDataSet(procName, spParams, ds, GetConnection());
        }
        /// <summary>
        /// Execute the given stored procedure and then populate the DataSet with the returned data.
        /// </summary>
        /// <param name="procName"></param>
        /// <param name="spParams"></param>
        /// <param name="ds"></param>
        public static void ExecProcAndFillDataSet(string procName, SpParamCollection spParams, DataSet ds, SqlConnection conn)
        {
            SqlCommand command = new SqlCommand(procName, conn);
            SqlDataAdapter dataAdapter = new SqlDataAdapter(command);
            try
            {
                InflateCommandObject(spParams, command);

                //Fill DataSet

                dataAdapter.Fill(ds);
            }
            catch (SqlException sqlEx)
            {
                if (SQL_DEADLOCK_ERROR_NUM == sqlEx.Number)
                {
                    try
                    {
                        dataAdapter.Fill(ds);
                    }
                    catch (Exception ex)
                    {
                        throw ex; ;
                    }
                }
                else
                {
                    throw sqlEx;
                }
            }
            catch (Exception ex)
            {
                throw ex; ;
            }
            finally
            {
                command = null;
                if (null != conn)
                {
                    conn.Close();
                    conn.Dispose();
                }
            }
        }
        #endregion

        #region Read data from databes and return it into XML File

        // <summary>
        /// Overloaded method for ExecProcAndReturnXmlDocument that uses default sql connection
        /// </summary>
        /// <param name="procName"></param>
        /// <param name="spParams"></param>
        public static XmlDocument ExecProcAndReturnXmlDocument(string procName, SpParamCollection spParams)
        {
            XmlDocument xmlDoc = null;
            xmlDoc = ExecProcAndReturnXmlDocument(procName, spParams, GetConnection());
            return xmlDoc;
        }
        /// <summary>
        /// Execute the given stored procedure which is expected to return an xml document
        /// (using sql FOR XML clause), and then return that xml document.
        /// </summary>
        /// <param name="procName"></param>
        /// <param name="spParams"></param>
        public static XmlDocument ExecProcAndReturnXmlDocument(string procName, SpParamCollection spParams, SqlConnection conn)
        {
            SqlCommand command = new SqlCommand(procName, conn);
            XmlDocument xmlDoc = null;

            try
            {
                InflateCommandObject(spParams, command);
                conn.Open();

                //Get XmlDocument
                XmlTextReader reader = (XmlTextReader)command.ExecuteXmlReader();
                xmlDoc = new XmlDocument();
                xmlDoc.Load(reader);
                reader.Close();
            }
            catch (SqlException sqlEx)
            {
                if (SQL_DEADLOCK_ERROR_NUM == sqlEx.Number)
                {
                    try
                    {
                        //Get XmlDocument
                        XmlTextReader reader = (XmlTextReader)command.ExecuteXmlReader();
                        xmlDoc = new XmlDocument();
                        xmlDoc.Load(reader);
                        reader.Close();
                    }
                    catch (Exception ex)
                    {
                        throw ex; ;
                    }
                }
                else
                {
                    throw sqlEx;
                }
            }
            catch (Exception ex)
            {
                throw ex; ;
            }
            finally
            {
                command = null;
                if (null != conn)
                {
                    conn.Close();
                    conn.Dispose();
                }
            }
            return xmlDoc;
        }
        #endregion

        #region Private Methods to get the value in data set

        /// <summary>
        /// Get Static data from database
        /// </summary>
        /// <returns></returns>
        public  static DataSet GetDataSet(string SprocName)
        {
            SqlDataReader dr = null;
            DataSet ds = new DataSet();
            try
            {
                //SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["StaticDataHelperConnectionString"].ToString());
              //  SqlCommand cmd = new SqlCommand("proc_StaticDataSelect", GetConnection());
                SqlCommand cmd = new SqlCommand(SprocName, GetConnection());

               
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

                // Load DataSet with multiple resultsets from the SqlDataReader
                ds.Load(dr, LoadOption.OverwriteChanges, GetDataTablesValuesArray());

                return ds;
            }
            finally
            {
                if (dr != null && !dr.IsClosed)
                {
                    dr.Close();
                }
            }
        }

        /// <summary>
        /// Helper method to return an string array of the values in the Tables enum
        /// </summary>
        /// <returns></returns>
        private static string[] GetDataTablesValuesArray()
        {
            string[] s = new string[0];
            foreach (Tables value in Enum.GetValues(typeof(Tables)))
            {
                Array.Resize(ref s, s.Length + 1);
                s.SetValue(value.ToString(), s.Length - 1);
            }
            return s;
        }

        #endregion
    }

    #region Structs Make a parmetariged straucture
    /// <summary>
    /// Represents a stored procedure's command paramater
    /// name/value pair and the direction of the parameter
    /// </summary>
    public struct SpParam
    {
        private string m_paramName;
        private object m_paramValue;
        private bool m_paramDirectionOut;

        public string Name
        {

            get { return m_paramName; }
        }

        public object Value
        {
            get { return m_paramValue; }
        }

        public bool ParamDirectionOut
        {
            get { return m_paramDirectionOut; }
        }

        /// <summary>
        /// Overridden constructor that sets the paramDirectionOut parameter to false
        /// </summary>
        public SpParam(string paramName, object paramValue) : this(paramName, paramValue, false) { }

        /// <summary>
        /// Constructor that sets paramDirectionOut parameter specifically
        /// </summary>
        public SpParam(string paramName, object paramValue, bool paramDirectionOut)
        {
            m_paramName = paramName;
            m_paramValue = paramValue;
            m_paramDirectionOut = paramDirectionOut;
        }
    }
    #endregion

    #region Parameters
    /// <summary>
    /// Represents a collection of parameters (SpParams').
    /// </summary>
    ///

    public class SpParamCollection : ArrayList
    {
        public SpParamCollection()
        {
        }

        public void Add(SpParam param)
        {
            base.Add(param);
        }
        public void clear()
        {
            base.Clear();
        }

    }

    #endregion
}

==================================================


Using of the Method which is created there as

using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

/// <summary>
/// Summary description for WIN_CgPearl
/// </summary>
///
namespace Ramosh.Support.DataLayer.DAL
{
    public class WIN_CgPearlDAL : DBInterface
    {
        public WIN_CgPearlDAL()
        {
        }

        internal static Int16 Insert_CgPearl(WIN_CgPearl objCgPearl)
        {
            Int16 ret = 0;
            DataSet dts = new DataSet();
            try
            {
                SpParamCollection spParams = new SpParamCollection();

                spParams.Add(new SpParam("@CgPearlName", objCgPearl.CgPearlName));
                spParams.Add(new SpParam("@CreatedDate", objCgPearl.CreatedDate));
                spParams.Add(new SpParam("@ModifiedDate", objCgPearl.ModifiedDate));
                spParams.Add(new SpParam("@IsActive", objCgPearl.IsActive));
                ret = ExecProcNonQuery("WIN_Insert_CgPearl", spParams);
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
            return ret;
        }

        internal static Int16 Delete_CgPearl(WIN_CgPearl objCgPearl)
        {
            Int16 ret = 0;
            DataSet dts = new DataSet();
            try
            {
                SpParamCollection spParams = new SpParamCollection();

                spParams.Add(new SpParam("@CgPearl_Id", objCgPearl.CgPearl_Id));
                ret = ExecProcNonQuery("WIN_Delete_CgPearl", spParams);
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
            return ret;
        }

        internal static Int16 Update_CgPearl(WIN_CgPearl objCgPearl)
        {
            Int16 ret = 0;
            DataSet dts = new DataSet();
            try
            {
                SpParamCollection spParams = new SpParamCollection();
                spParams.Add(new SpParam("@CgPearl_Id", objCgPearl.CgPearl_Id));
                spParams.Add(new SpParam("@CgPearlName", objCgPearl.CgPearlName));
                spParams.Add(new SpParam("@ModifiedDate", objCgPearl.ModifiedDate));
                spParams.Add(new SpParam("@IsActive", objCgPearl.IsActive));
                ret = ExecProcNonQuery("WIN_Update_CGPearl", spParams);
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
            return ret;
        }

        internal static BasePage<WIN_CgPearl> Select_CgPearl()
        {
            IDataReader oReader = null;
            BasePage<WIN_CgPearl> objCgPearl = new BasePage<WIN_CgPearl>();
         
                SpParamCollection spParams = new SpParamCollection();
                oReader = ExecProcAndPopulateDataReader("WIN_Select_CgPearl", spParams);
                while (oReader.Read())
                {
                    objCgPearl.Add(new WIN_CgPearl(oReader));
                }
          
            return objCgPearl;
        }

        internal static BasePage<WIN_CgPearl> Select_CgPearl_Id(WIN_CgPearl objCgPearl)
        {
            IDataReader oReader = null;
            BasePage<WIN_CgPearl> objBCgPearl = new BasePage<WIN_CgPearl>();
            try
            {
                SpParamCollection spParams = new SpParamCollection();
                spParams.Add(new SpParam("@CgPearl_Id", objCgPearl.CgPearl_Id));
                oReader = ExecProcAndPopulateDataReader("WIN_Select_CgPearl_Id", spParams);
                while (oReader.Read())
                {
                    objBCgPearl.Add(new WIN_CgPearl(oReader));
                }
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }

            return objBCgPearl;
        }
    }
}