Tuesday, September 24, 2013

recp dAL

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entities;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
    public class RecDAL
    {
        public static string connStr = ConfigurationSettings.AppSettings["connectionString"];
        SqlConnection con = new SqlConnection(connStr);
        SqlCommand cmd;
        public DataTable getLogin(EntRec rr)
        {
           
            con.Open();
            cmd = new SqlCommand("sp_Login", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@uname", rr.userName);
            cmd.Parameters.AddWithValue("@pwd", rr.Pwd);
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(dt);
            return dt;
        }
        public DataTable LoadData()
        {
            DataTable dt = new DataTable();
            cmd = new SqlCommand("sp_LoadFullData", con);
            cmd.CommandType = CommandType.StoredProcedure;          
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(dt);
            return dt;
        }
    }
}

dropdown selected value

 int id = (int)GridView1.DataKeys[e.NewSelectedIndex].Values["id"];
            if (id == 1)
            {
                DataTable dt = new DataTable();
                RecBAL rb = new RecBAL();
                dt = rb.getFullData();
                DropDownList1.DataSource = dt;
                DropDownList1.DataTextField = "username";
                DropDownList1.DataValueField = "id";
                DropDownList1.DataBind();
            }

gridview edit

lblAddCountry.Text = "";
            GridView gvCountry= (GridView)sender;
            iCompanyId = Int32.Parse(gvCountry.DataKeys[Int32.Parse(e.NewEditIndex.ToString())].Values["ID"].ToString());
            strName=gvCountry.DataKeys[Int32.Parse(e.NewEditIndex.ToString())].Values["Name"].ToString();
            strCode=gvCountry.DataKeys[Int32.Parse(e.NewEditIndex.ToString())].Values["CountryCode"].ToString();
            txtAddCountry.Text = strName;
            txtAddCountryCode.Text = strCode;
            iStatus = 1;
            Session["strStatus"] ="U";
            Session["iCompanyId"] = iCompanyId;
            btnAddCountry.Text = "Update";


DELETE

 GridView gvCountry = (GridView)sender;
            int iCountryId = (int)gvCountry.DataKeys[e.RowIndex].Values["ID"];


Select

 protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            int id = (int)GridView1.DataKeys[e.NewSelectedIndex].Values["id"];
        }

web config

 <appSettings>
    <add key="connectionString" value="Data Source=192.168.1.7\SQLEXPRESS;Initial Catalog=TB_RECP_TEST;Persist Security Info=True;User ID=sa;Password=apple@123"/>
   
  </appSettings>

Monday, September 23, 2013

UI Country

using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.IO;

using HRHO_Entities;
using HRHO_BL;
namespace HRHO
{
    public partial class AddCountry : System.Web.UI.Page
    {
        DataBaseAccess objDataBaseAccess = new DataBaseAccess();
        dboperations db = new dboperations();
        SqlConnection con = new SqlConnection(CommonFile.getConnectionString());
        int iCompanyId;
        string strName, strStatus;
        string strCode;
        int iStatus;

        CountryBL c_bl = new CountryBL();
        CountryEntities c_ent = new CountryEntities();
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Cache.SetNoStore();
            try
            {
                if (Session["staffID"].ToString().Trim() == "")
                {
                    Response.Redirect("Home.aspx");

                }
            }
            catch (Exception)
            {
                Session["staffID"] = "";
                Response.Redirect("Home.aspx");

            }
            if (!IsPostBack)
            {
                gvdisplay();
                iStatus=0;
             
                Session["strStatus"] = "A";
                if (iStatus == 0)
                {
                    btnAddCountry.Text = "Add";
                }
            }
         
        }
       
        private void gvdisplay()
        {
            /*
            string strQuery = "select * from TB_COUNTRY where Status=0 order by Name";
            string strTable = "TB_COUNTRY";
            DataSet dt = new DataSet();
            dt = objDataBaseAccess.GetRecords(strTable, strQuery);
            gvCountry.DataSource = dt.Tables[0];
            gvCountry.DataBind();
            */
         
            c_ent.Name = "";
            c_ent.CountryCode = "";
            c_ent.ID = 0;
            c_ent.flag = 4;
            List<CountryEntities> countryList = c_bl.GetCountry(c_ent);
            gvCountry.DataSource = countryList;
            gvCountry.DataBind();
           
        }
        private void clear()
        {
            txtAddCountry.Text = "";
            txtAddCountryCode.Text = "";
            lblAddCountry.Text = "";
            txtSearchby.Text = "";
            ddlSearch.Text = "--select--";
            btnAddCountry.Text = "Add";
             gvdisplay();
            Session["strStatus"] = "A";
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            Session["strStatus"] = "A";
            btnAddCountry.Text = "Add Country";
            clear();
        }

        protected void btnAddCountry_Click(object sender, EventArgs e)
        {
            string test = Session["strStatus"].ToString();
            con.Open();
            /*SqlCommand cmd = new SqlCommand("SELECT * FROM TB_COUNTRY WHERE (Name = '" + txtAddCountry.Text + "') OR (CountryCode = '" + txtAddCountryCode.Text + "') and (status=0)", con);
            cmd.Parameters.AddWithValue("@Name", txtAddCountry.Text);
            cmd.Parameters.AddWithValue("@CountryCode", txtAddCountryCode.Text);*/
            c_ent.Name = txtAddCountry.Text;
            c_ent.CountryCode = txtAddCountryCode.Text;
            if (test=="A")
            {
                /*
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable dt = new DataTable();
                da.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    clear();
                    lblAddCountry.Visible = true;
                    lblAddCountry.Style.Add(HtmlTextWriterStyle.Color, "red");
                    lblAddCountry.Text = "Country name or Country Code already exist";
                 
                   
                }
                else
                {
                    string sql = "insert into TB_COUNTRY (Name,CountryCode,Status) values ('" + txtAddCountry.Text + "','" + txtAddCountryCode.Text + "',0)";
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = sql;
                    cmd.ExecuteNonQuery();
                    clear();
                    lblAddCountry.Visible = true;
                    lblAddCountry.Style.Add(HtmlTextWriterStyle.Color, "green");
                    lblAddCountry.Text = "Added succesfully !";
                    con.Close();
                    gvdisplay();

                }
                 */
                c_ent.ID = 0;
                c_ent.flag = 1;
                int a=c_bl.InsertCountry(c_ent);
                if (a > 0)
                {
                    clear();
                    lblAddCountry.Visible = true;
                    lblAddCountry.Style.Add(HtmlTextWriterStyle.Color, "green");
                    lblAddCountry.Text = "Added succesfully !";
                }
                else
                {
                    lblAddCountry.Visible = true;
                    lblAddCountry.Style.Add(HtmlTextWriterStyle.Color, "red");
                    lblAddCountry.Text = "Country name or country code already existed !";
                }
                gvdisplay();

            }
            if (test == "U")
            {
                iCompanyId = Convert.ToInt32(Session["iCompanyId"]);
                //string s3 = "update TB_COUNTRY set CountryCode='" + txtAddCountryCode.Text + "',Name='" + txtAddCountry.Text + "' where ID=" + iCompanyId + "";
                //db.exnon(s3);

                c_ent.ID = iCompanyId;
                c_ent.Name = txtAddCountry.Text;
                c_ent.CountryCode = txtAddCountryCode.Text;
                c_ent.flag = 2;
                int cnt=c_bl.UpdateCountry(c_ent);
                if (cnt > 0)
                {

                    clear();
                    lblAddCountry.Visible = true;
                    lblAddCountry.Style.Add(HtmlTextWriterStyle.Color, "green");
                    lblAddCountry.Text = "Updated Successfully";
                    btnAddCountry.Text = "Add";
                    txtAddCountry.Text = "";
                    txtAddCountryCode.Text = "";
                    gvdisplay();
                    Session["strStatus"] = "A";
                }
                else
                {
                    lblAddCountry.Visible = true;
                    lblAddCountry.Text = "Country Not Updated: Name or code already existing";
                }
            }
            }

        protected void gvCountry_RowEditing(object sender, GridViewEditEventArgs e)
        {
            lblAddCountry.Text = "";
            GridView gvCountry= (GridView)sender;
            iCompanyId = Int32.Parse(gvCountry.DataKeys[Int32.Parse(e.NewEditIndex.ToString())].Values["ID"].ToString());
            strName=gvCountry.DataKeys[Int32.Parse(e.NewEditIndex.ToString())].Values["Name"].ToString();
            strCode=gvCountry.DataKeys[Int32.Parse(e.NewEditIndex.ToString())].Values["CountryCode"].ToString();
            txtAddCountry.Text = strName;
            txtAddCountryCode.Text = strCode;
            iStatus = 1;
            Session["strStatus"] ="U";
            Session["iCompanyId"] = iCompanyId;
            btnAddCountry.Text = "Update";
            gvdisplay();
         
         
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            Label lblCountryName = (Label)btn.FindControl("Label1");
            string strCountryName = lblCountryName.Text;
            Label lblCountryCode = (Label)btn.FindControl("Label2");
            string strCountrCode = lblCountryCode.Text;
            Label lblID = (Label)btn.FindControl("lblID");
         
        }

        protected void Button3_Click(object sender, EventArgs e)
        {

        }

        protected void gvCountry_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            GridView gvCountry = (GridView)sender;
            int iCountryId = (int)gvCountry.DataKeys[e.RowIndex].Values["ID"];
            //int i=Int32.Parse(gvCountry.DataKeys[Int32.Parse(e.NewEditIndex.ToString())].Values["ID"].ToString());
            //string iCountryId=gvCountry.Rows[e.RowIndex].Cells[1].ToString();
            //iCompanyId = Convert.ToInt32(Session["iCompanyId"]);
            /*
            string s3 = "update TB_COUNTRY set Status=1 where CountryCode='" + strCountryId + "'";
            db.exnon(s3);
            clear();*/
            c_ent.ID = Convert.ToInt32(iCountryId);
            c_ent.flag = 3;
            c_ent.Name = "";
            c_ent.CountryCode="";
            int cnt=c_bl.DeleteCountry(c_ent);
            if (cnt > 0)
            {
                lblAddCountry.Visible = true;
             
             
                lblAddCountry.Text = "Deleted successfully";
            }
            else
            {
                lblAddCountry.Visible = true;
             
                lblAddCountry.Text = " Data cannot be Deleted";
            }
            gvdisplay();
        }

        protected void gvCountry_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvCountry.PageIndex = e.NewPageIndex;
            clear();
            gvdisplay();
        }


        //protected void btnSearch_Click(object sender, EventArgs e)
        //{
        //    if (txtSearchby.Text == "")
        //    {
        //        lblSearchCountry.Visible = true;
        //        lblSearchCountry.Style.Add(HtmlTextWriterStyle.Color, "red");
        //        lblSearchCountry.Text = "Please enter data to search";
        //        return;
        //    }
        //        lblSearchCountry.Visible = false;
        //        string ddlvar =(ddlSearch.SelectedValue.ToString());
        //        string strQuery = "SELECT Name,CountryCode FROM TB_COUNTRY WHERE "+ddlvar+" LIKE '%" + txtSearchby.Text + "%'";
        //            string strTable = "TB_COUNTRY";
        //            DataSet dt = new DataSet();
        //            dt = objDataBaseAccess.GetRecords(strTable, strQuery);
        //            gvsearch.DataSource = dt.Tables[0];
        //            gvsearch.DataBind();
        //        if (gvsearch.Rows.Count == 0)
        //        {
        //            clear();
        //            lblSearchCountry.Visible = true;
        //            lblSearchCountry.Style.Add(HtmlTextWriterStyle.Color, "red");
        //            lblSearchCountry.Text = "No data found";
        //          }
        //        else
        //        {
        //            lblAddCountry.Visible = false;
        //            gvsearch.DataBind();
        //        }
        //}

        protected void gvCountry_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {

        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            if (txtSearchby.Text == "")
            {
                lblSearchCountry.Visible = true;
                lblSearchCountry.Style.Add(HtmlTextWriterStyle.Color, "red");
                lblSearchCountry.Text = "Please enter data to search";
                return;
            }
            if (ddlSearch.Text == "--select--")
            {
                lblSearchCountry.Visible = true;
                lblSearchCountry.Style.Add(HtmlTextWriterStyle.Color, "red");
                lblSearchCountry.Text = "Please select country or code first";
                gvCountry.Visible = false;
                return;
            }
            gvCountry.Visible = true;
            lblSearchCountry.Visible = false;
            string ddlvar = (ddlSearch.SelectedValue.ToString());
            string strQuery = "SELECT ID,Name,CountryCode FROM TB_COUNTRY WHERE " + ddlvar + " LIKE '" + txtSearchby.Text + "%' AND Status='1' ";
            string strTable = "TB_COUNTRY";
            DataSet dt = new DataSet();
            dt = objDataBaseAccess.GetRecords(strTable, strQuery);
            gvCountry.DataSource = dt;
            gvCountry.DataBind();
            if (gvCountry.Rows.Count == 0)
            {
                //clear();
                lblSearchCountry.Visible = true;
                lblSearchCountry.Style.Add(HtmlTextWriterStyle.Color, "red");
                lblSearchCountry.Text = "No data found";
            }
            else
            {
                lblSearchCountry.Visible = false;
                gvCountry.DataBind();
            }
        }

     
    }
}

country BAL

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using HRHO_Entities;
using HRHO_DAL;
namespace HRHO_BL
{
    public class CountryBL
    {
        public int InsertCountry(CountryEntities C_Ent)
        {
            CountryDAL C_DAL = new CountryDAL();
            return C_DAL.InsertCountry(C_Ent);
        }
        public List<CountryEntities> GetCountry(CountryEntities C_Ent)
        {
            CountryDAL C_DAL = new CountryDAL();
            return C_DAL.GetCountry(C_Ent);
        }
        public int DeleteCountry(CountryEntities C_Ent)
        {
            CountryDAL C_DAL = new CountryDAL();
            return C_DAL.DeleteCountry(C_Ent);
        }
        public int UpdateCountry(CountryEntities C_Ent)
        {
            CountryDAL C_DAL = new CountryDAL();
            return C_DAL.UpdateCountry(C_Ent);
        }
    }
}

INSERT DAL

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

using System.Configuration;
using HRHO_Entities;
using HRHO_Utilities;
namespace HRHO_DAL
{
    public class SalaryDAL:DataProviderBase
    {
       
        public bool InsertSalary(SalaryEntities S_Ent)
        {
            IDBManager dbManager = new DBManager(base.GetProvider(), ConfigurationManager.AppSettings["connection"].ToString());
            //try
            //{
                dbManager.Open();
                dbManager.CreateParameters(28);

                dbManager.AddParameters(0, "@staffID", S_Ent.staffID);
                dbManager.AddParameters(1, "@staffCode", S_Ent.staffCode);
                dbManager.AddParameters(2,"@designation",S_Ent.designation);
                dbManager.AddParameters(3, "@PF", S_Ent.PF);
                dbManager.AddParameters(4, "@HRA",S_Ent.HRA);
                dbManager.AddParameters(5, "@TA", S_Ent.TA);
                dbManager.AddParameters(6, "@DA",S_Ent.DA);
                dbManager.AddParameters(7, "@targetAmount",S_Ent.targetAmount);
                dbManager.AddParameters(8, "@achievedAmount",S_Ent.achievedAmount);
                dbManager.AddParameters(9, "@businessIncentive",S_Ent.businessIncentive);
                dbManager.AddParameters(10, "@advance",S_Ent.advance);
                dbManager.AddParameters(11, "@loanAdvance",S_Ent.loanAdvance);
                dbManager.AddParameters(12, "@totalWorkingDays",S_Ent.totalWorkingDays);
                dbManager.AddParameters(13, "@leaveTaken",S_Ent.leaveTaken);
                dbManager.AddParameters(14, "@LOP",S_Ent.LOP);
                dbManager.AddParameters(15, "@totalPaidDays",S_Ent.totalPaidDays);
                dbManager.AddParameters(16, "@totalSalary",S_Ent.totalSalary);
                dbManager.AddParameters(17, "@salaryAfterDeduction",S_Ent.salaryAfterDeduction);
                dbManager.AddParameters(18, "@cautionDeposit",S_Ent.cautionDeposit);
                dbManager.AddParameters(19, "@netSalary",S_Ent.netSalary);
                dbManager.AddParameters(20, "@salaryMonth",S_Ent.salaryMonth);
                dbManager.AddParameters(21, "@loginedUser",S_Ent.loginedUser);
                dbManager.AddParameters(22, "@flag",1);
                dbManager.AddParameters(23, "@salaryYear", S_Ent.salaryYear);
                dbManager.AddParameters(24, "@branch", S_Ent.branch);
                dbManager.AddParameters(25, "@basicSalary",S_Ent.basicSalary);
                dbManager.AddParameters(26, "@groupedIncentive", S_Ent.groupedIncentive);
                dbManager.AddParameters(27, "@groupedBusiness", S_Ent.groupedBusiness);
                int a=dbManager.ExecuteNonQuery(CommandType.StoredProcedure, "[sp_GENERATE_SALARY]");
            //}
            //catch (Exception ex)
            //{
            //    ex.GetBaseException();
            //    return false;
            //}
            return true;
        }
        public bool     ModifySalary(SalaryEntities S_Ent)
        {
            IDBManager dbManager = new DBManager(base.GetProvider(), ConfigurationManager.AppSettings["connection"].ToString());
           
                dbManager.Open();
                dbManager.CreateParameters(28);

                dbManager.AddParameters(0, "@staffID", S_Ent.staffID);
                dbManager.AddParameters(1, "@staffCode", S_Ent.staffCode);
                dbManager.AddParameters(2, "@designation", S_Ent.designation);
                dbManager.AddParameters(3, "@PF", S_Ent.PF);
                dbManager.AddParameters(4, "@HRA", S_Ent.HRA);
                dbManager.AddParameters(5, "@TA", S_Ent.TA);
                dbManager.AddParameters(6, "@DA", S_Ent.DA);
                dbManager.AddParameters(7, "@targetAmount", S_Ent.targetAmount);
                dbManager.AddParameters(8, "@achievedAmount", S_Ent.achievedAmount);
                dbManager.AddParameters(9, "@businessIncentive", S_Ent.businessIncentive);
                dbManager.AddParameters(10, "@advance", S_Ent.advance);
                dbManager.AddParameters(11, "@loanAdvance", S_Ent.loanAdvance);
                dbManager.AddParameters(12, "@totalWorkingDays", S_Ent.totalWorkingDays);
                dbManager.AddParameters(13, "@leaveTaken", S_Ent.leaveTaken);
                dbManager.AddParameters(14, "@LOP", S_Ent.LOP);
                dbManager.AddParameters(15, "@totalPaidDays", S_Ent.totalPaidDays);
                dbManager.AddParameters(16, "@totalSalary", S_Ent.totalSalary);
                dbManager.AddParameters(17, "@salaryAfterDeduction", S_Ent.salaryAfterDeduction);
                dbManager.AddParameters(18, "@cautionDeposit", S_Ent.cautionDeposit);
                dbManager.AddParameters(19, "@netSalary", S_Ent.netSalary);
                dbManager.AddParameters(20, "@salaryMonth", S_Ent.salaryMonth);
                dbManager.AddParameters(21, "@loginedUser", S_Ent.loginedUser);
                dbManager.AddParameters(22, "@flag",2);
                dbManager.AddParameters(23, "@salaryYear", S_Ent.salaryYear);
                dbManager.AddParameters(24, "@branch", S_Ent.branch);
                dbManager.AddParameters(25, "@basicSalary",S_Ent.basicSalary);
                dbManager.AddParameters(26, "@groupedIncentive", S_Ent.groupedIncentive);
                dbManager.AddParameters(27, "@groupedBusiness", S_Ent.groupedBusiness);

                int a = dbManager.ExecuteNonQuery(CommandType.StoredProcedure, "[sp_GENERATE_SALARY]");
           
                //ex.GetBaseException();
                //return false;
           
            return true;
        }
        public List<SalaryEntities> SelectStaffs(SalaryEntities S_Ent)
        {
            List<SalaryEntities> staffList = new List<SalaryEntities>();
            /*
            DataSet objDSet = new DataSet();
            IDBManager dbManager = new DBManager(base.GetProvider(), ConfigurationManager.AppSettings["connection"].ToString());

            dbManager.Open();
            dbManager.CreateParameters(2);

            dbManager.AddParameters(0, "@branch", S_Ent.branch);
            dbManager.AddParameters(1, "@flag", S_Ent.flag);
            objDSet = dbManager.ExecuteDataSet(CommandType.StoredProcedure, "[sp_SALARY_STAFF]");

            if (objDSet.Tables.Count > 0)
            {
                foreach (DataRow drow in objDSet.Tables[0].Rows)
                {
                    SalaryEntities enty = new SalaryEntities();
                    enty.staffID = Convert.ToInt32(drow["staffID"]);
                    enty.staffName = Convert.ToString(drow["staffName"]);
                    enty.staffCode = Convert.ToString(drow["staffCode"]);
                    enty.RegionalDesigID = Convert.ToInt32(drow["RegionalDesigID"]);
                    enty.designationID = Convert.ToInt32(drow["designationID"]);
                    enty.basic = Convert.ToInt64(drow["basic"]);
                    enty.target = Convert.ToInt64(drow["target"]);
                    enty.PF = Convert.ToInt64(drow["pf"]);
                    enty.HRA = Convert.ToInt64(drow["hra"]);
                    enty.DA = Convert.ToInt64(drow["da"]);
                    enty.TA = Convert.ToInt64(drow["ta"]);
                    enty.dailyAllowance = Convert.ToInt64(drow["dailyAllowance"]);
                    enty.medicalAllowance = Convert.ToInt64(drow["medicalAllowance"]);
                    enty.familyPlan = Convert.ToInt64(drow["familyPlan"]);
                    enty.storeCard = Convert.ToInt64(drow["storeCard"]);
                    enty.extraIncentive = Convert.ToInt64(drow["extraIncentive"]);
                    staffList.Add(enty);

                }
            }
          */
            return staffList;
        }
    }
   
}

LOGIN DAL

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using HRHO_Entities;
using HRHO_Utilities;
using System.Configuration;
namespace HRHO_DAL
{
    class LoginDAL:DataProviderBase
    {
        public List<LoginProperty> Getloginval(string uname, string pwd, string ipaddr)
        {
            string a = "";
            string b = "";
            List<LoginProperty> Stlogin = new List<LoginProperty>();
            IDBManager dbManager = new DBManager(base.GetProvider(), ConfigurationManager.AppSettings["connection"].ToString());
            DataSet dS = new DataSet();
            DataTable dT = new DataTable();
            try
            {
                dbManager.Open();
                dbManager.CreateParameters(3);
                dbManager.AddParameters(0, "@uname", uname);
                dbManager.AddParameters(1, "@pwd", pwd);
                dbManager.AddParameters(2, "@IP_ADDR", ipaddr);
                dS = dbManager.ExecuteDataSet(CommandType.StoredProcedure, "Getloginval");

                if (dS.Tables.Count > 0)
                {

                    LoginProperty stl = new LoginProperty();
                    foreach (DataRow Dr in dS.Tables[0].Rows)
                    {


                        stl.firstName = Convert.ToString(Dr["firstName"]);
                        //b = Convert.ToString(Dr["firstName"]);
                        stl.userType = Convert.ToInt32(Dr["userType"]);

                        Stlogin.Add(stl);
                    }

                }
                else
                {

                    return Stlogin;
                }

                return Stlogin;
            }
            catch (Exception er)
            {
                throw;
            }

        }
    }
}

DAL DataProviderBase

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using HRHO_Utilities;
namespace HRHO_DAL
{
    public abstract class DataProviderBase
    {


        protected DataProvider GetProvider()
        {
            DataProvider prov;


            switch (ConfigurationManager.AppSettings["DataProvider"].ToString())
            {
                case "Odbc":
                    prov = DataProvider.Odbc;
                    break;
                case "OleDb":
                    prov = DataProvider.OleDb;
                    break;
                case "Oracle":
                    prov = DataProvider.Oracle;
                    break;
                default:
                    prov = DataProvider.SqlServer;
                    break;
            }

            return prov;
        }

    }
}

Entities

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HRHO_Entities
{
    public class CountryEntities
    {
        #region
        public int ID { get; set; }
        public string Name { get; set; }
        public string CountryCode { get; set; }
        public int companyId { get; set; }
        public int flag { get; set; }
        //public int companyId { get; set; }
       
        #endregion
    }
}

DBManager

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace HRHO_Utilities
{

    /// <summary>
    /// This enum contains all the DataProvider types supported by the DBManager
    /// </summary>
    public enum DataProvider
    {
        Oracle, SqlServer, OleDb, Odbc
    }

    public interface IDBManager
    {
        /// <summary>
        /// Get or set Data Provider type
        /// </summary>
        DataProvider ProviderType
        {
            get;
            set;
        }

        /// <summary>
        /// Get or set connection string
        /// </summary>
        string ConnectionString
        {
            get;
            set;
        }

        /// <summary>
        /// Get connection object
        /// </summary>
        IDbConnection Connection
        {
            get;
        }

        /// <summary>
        /// Get transaction object
        /// </summary>
        IDbTransaction Transaction
        {
            get;
        }

        /// <summary>
        /// Get or set DataReader object
        /// </summary>
        IDataReader DataReader
        {
            get;
            set;
        }

        /// <summary>
        /// Get command object
        /// </summary>
        IDbCommand Command
        {
            get;
        }

        /// <summary>
        /// Get parameter array
        /// </summary>
        IDbDataParameter[] Parameters
        {
            get;
        }

        /// <summary>
        /// This method can be used to establish (open) a new connection with the data source.
        /// </summary>
        void Open();

        /// <summary>
        /// This method can be used to begin (start) an ADO.NET transaction.
        /// </summary>
        void BeginTransaction();

        /// <summary>
        /// This method can be used to commit (end) an ADO.NET transaction.
        /// </summary>
        void CommitTransaction();

        /// <summary>
        /// This method can be used to initialise 'n' number of parameters.
        /// </summary>
        /// <param name="paramsCount">Number of parameters to initialise</param>
        void CreateParameters(int paramsCount);

        /// <summary>
        /// This method can be used to add a parameter to already initialised parameter object.
        /// </summary>
        /// <param name="index">Index of the parameter object</param>
        /// <param name="paramName">Parameter name (as given in the T-SQL)</param>
        /// <param name="objValue">Parameter value</param>
        void AddParameters(int index, string paramName, object objValue);

        /// <summary>
        /// This method can be used to add a parameter to already initialised parameter object.
        /// </summary>
        /// <param name="index">Index of the parameter object</param>
        /// <param name="paramName">Parameter name (as given in the T-SQL)</param>
        /// <param name="objValue">Parameter value</param>
        /// <param name="direction">Parameter direction (can be Input, OutPut and InputOutPut)</param>
        void AddParameters(int index, string paramName, object objValue, ParameterDirection direction);

        /// <summary>
        /// This method can be used to add a parameter to already initialised parameter object.
        /// </summary>
        /// <param name="index">Index of the parameter object</param>
        /// <param name="paramName">Parameter name (as given in the T-SQL)</param>
        /// <param name="objValue">Parameter value</param>
        /// <param name="type">Parameter type</param>
        /// <param name="size">Size of the parameter</param>
        /// <param name="direction">Parameter direction (can be Input, OutPut and InputOutPut)</param>
        void AddParameters(int index, string paramName, object objValue, DbType type, int size, ParameterDirection direction);

        /// <summary>
        /// This method can be used to execute an ADO.NET DataReader.
        /// </summary>
        /// <param name="commandType">Command type (can be Text or Stored Procedure)</param>
        /// <param name="commandText">Command text (can be T-SQL statement or Stored Procedure name)</param>
        /// <returns>Returns an ADO.NET DataReader object</returns>
        IDataReader ExecuteReader(CommandType commandType, string commandText);

        /// <summary>
        /// This method can be used to fetch an ADO.NET DataSet.
        /// </summary>
        /// <param name="commandType">Command type (can be Text or Stored Procedure)</param>
        /// <param name="commandText">Command text (can be T-SQL statement or Stored Procedure name)</param>
        /// <returns>Returns an ADO.NET DataSet object</returns>
        DataSet ExecuteDataSet(CommandType commandType, string commandText);

        /// <summary>
        /// This method can be used to fetch a Scalar value.
        /// </summary>
        /// <param name="commandType">Command type (can be Text or Stored Procedure)</param>
        /// <param name="commandText">Command text (can be T-SQL statement or Stored Procedure name)</param>
        /// <returns>Returns a scalar value as object</returns>
        object ExecuteScalar(CommandType commandType, string commandText);

        /// <summary>
        /// This method can be used to execute a T-SQL statement.
        /// </summary>
        /// <param name="commandType">Command type (can be Text or Stored Procedure)</param>
        /// <param name="commandText">Command text (can be T-SQL statement or Stored Procedure name)</param>
        /// <returns>Returns the number of Rows affected by the statement</returns>
        int ExecuteNonQuery(CommandType commandType, string commandText);

        /// <summary>
        /// This method can be used to close an already oppened DataReader object.
        /// </summary>
        void CloseReader();
        void SQLBulkInsert(DataTable dt, string tableName);

        /// <summary>
        /// This method can be used to close an already oppened Connection object.
        /// </summary>
        void Close();

        /// <summary>
        /// This method will deallocate all the resources allocated to the DBManager object.
        /// </summary>
        void Dispose();

    }  

}

DBManagerFactory

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Data.Odbc;
using System.Data.OracleClient;
namespace HRHO_Utilities
{
    public sealed class DBManagerFactory
    {
        private DBManagerFactory() { }

        public static IDbConnection GetConnection(DataProvider providerType)
        {
            IDbConnection iDbConnection = null;
            switch (providerType)
            {
                case DataProvider.SqlServer:
                    iDbConnection = new SqlConnection();
                    break;
                case DataProvider.OleDb:
                    iDbConnection = new OleDbConnection();
                    break;
                case DataProvider.Odbc:
                    iDbConnection = new OdbcConnection();
                    break;
                case DataProvider.Oracle:
                    iDbConnection = new OracleConnection();
                    break;
                default:
                    return null;
            }
            return iDbConnection;
        }

        public static IDbCommand GetCommand(DataProvider providerType)
        {
            switch (providerType)
            {
                case DataProvider.SqlServer:
                    return new SqlCommand();
                case DataProvider.OleDb:
                    return new OleDbCommand();
                case DataProvider.Odbc:
                    return new OdbcCommand();
                case DataProvider.Oracle:
                    return new OracleCommand();
                default:
                    return null;
            }
        }

        public static IDbDataAdapter GetDataAdapter(DataProvider providerType)
        {
            switch (providerType)
            {
                case DataProvider.SqlServer:
                    return new SqlDataAdapter();
                case DataProvider.OleDb:
                    return new OleDbDataAdapter();
                case DataProvider.Odbc:
                    return new OdbcDataAdapter();
                case DataProvider.Oracle:
                    return new OracleDataAdapter();
                default:
                    return null;
            }
        }

        public static IDbTransaction GetTransaction(DataProvider providerType)
        {
            IDbConnection iDbConnection = GetConnection(providerType);
            IDbTransaction iDbTransaction = iDbConnection.BeginTransaction();
            return iDbTransaction;
        }

        public static IDataParameter GetParameter(DataProvider providerType)
        {
            IDataParameter iDataParameter = null;
            switch (providerType)
            {
                case DataProvider.SqlServer:
                    iDataParameter = new SqlParameter();
                    break;
                case DataProvider.OleDb:
                    iDataParameter = new OleDbParameter();
                    break;
                case DataProvider.Odbc:
                    iDataParameter = new OdbcParameter();
                    break;
                case DataProvider.Oracle:
                    iDataParameter = new OracleParameter();
                    break;

            }
            return iDataParameter;
        }

        public static IDbDataParameter[] GetParameters(DataProvider providerType, int paramsCount)
        {
            IDbDataParameter[] idbParams = new IDbDataParameter[paramsCount];

            switch (providerType)
            {
                case DataProvider.SqlServer:
                    for (int i = 0; i < paramsCount; ++i)
                    {
                        idbParams[i] = new SqlParameter();
                    }
                    break;
                case DataProvider.OleDb:
                    for (int i = 0; i < paramsCount; ++i)
                    {
                        idbParams[i] = new OleDbParameter();
                    }
                    break;
                case DataProvider.Odbc:
                    for (int i = 0; i < paramsCount; ++i)
                    {
                        idbParams[i] = new OdbcParameter();
                    }
                    break;
                case DataProvider.Oracle:
                    for (int i = 0; i < paramsCount; ++i)
                    {
                        idbParams[i] = new OracleParameter();
                    }
                    break;
                default:
                    idbParams = null;
                    break;
            }
            return idbParams;
        }
    }
}

Utilities DBMAnager

DBManager


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace HRHO_Utilities
{
    public class DBManager : IDBManager, IDisposable
    {
        private IDbConnection idbConnection;
        private IDataReader idataReader;
        private IDbCommand idbCommand;
        private DataProvider providerType;
        private IDbTransaction idbTransaction = null;
        private IDbDataParameter[] idbParameters = null;
        private string strConnection;

        /// <summary>
        /// Default Constructor
        /// </summary>
        public DBManager() { }

        /// <summary>
        /// Overloaded Constructor (First overload)
        /// </summary>
        /// <param name="providerType">Data provider type</param>
        public DBManager(DataProvider providerType)
        {
            this.providerType = providerType;
        }

        /// <summary>
        /// Overloaded Constructor (Second overload)
        /// </summary>
        /// <param name="providerType">Data provider type</param>
        /// <param name="connectionString">Connection string</param>
        public DBManager(DataProvider providerType, string connectionString)
        {
            this.providerType = providerType;
            this.strConnection = connectionString;
        }

        public IDbConnection Connection
        {
            get
            {
                return idbConnection;
            }
        }

        public IDataReader DataReader
        {
            get
            {
                return idataReader;
            }
            set
            {
                idataReader = value;
            }
        }

        public DataProvider ProviderType
        {
            get
            {
                return providerType;
            }
            set
            {
                providerType = value;
            }
        }

        public string ConnectionString
        {
            get
            {
                return strConnection;
            }
            set
            {
                strConnection = value;
            }
        }

        public IDbCommand Command
        {
            get
            {
                return idbCommand;
            }
        }

        public IDbTransaction Transaction
        {
            get
            {
                return idbTransaction;
            }
        }

        public IDbDataParameter[] Parameters
        {
            get
            {
                return idbParameters;
            }
        }

        public void Open()
        {
            idbConnection = DBManagerFactory.GetConnection(this.providerType);
            idbConnection.ConnectionString = this.ConnectionString;
            if (idbConnection.State != ConnectionState.Open)
                idbConnection.Open();
            this.idbCommand = DBManagerFactory.GetCommand(this.ProviderType);
        }

        public void Close()
        {
            if (idbConnection.State != ConnectionState.Closed)
                idbConnection.Close();
        }

        public void Dispose()
        {
            this.Close();
            this.idbCommand = null;
            this.idbTransaction = null;
            this.idbConnection = null;
            GC.SuppressFinalize(this);
        }

        public void CreateParameters(int paramsCount)
        {
            idbParameters = new IDbDataParameter[paramsCount];
            idbParameters = DBManagerFactory.GetParameters(this.ProviderType, paramsCount);
        }

        public void AddParameters(int index, string paramName, object objValue)
        {
            if (index < idbParameters.Length)
            {
                idbParameters[index].ParameterName = paramName;
                idbParameters[index].Value = objValue;
            }
        }

        public void AddParameters(int index, string paramName, object objValue, ParameterDirection direction)
        {
            if (index < idbParameters.Length)
            {
                idbParameters[index].ParameterName = paramName;
                idbParameters[index].Value = objValue;
                idbParameters[index].Direction = direction;
            }
        }

        public void AddParameters(int index, string paramName, object objValue, DbType type, int size, ParameterDirection direction)
        {
            if (index < idbParameters.Length)
            {
                idbParameters[index].ParameterName = paramName;
                idbParameters[index].Value = objValue;
                idbParameters[index].DbType = type;
                idbParameters[index].Size = size;
                idbParameters[index].Direction = direction;
            }
        }

        public void BeginTransaction()
        {
            if (this.idbTransaction == null)
                idbTransaction = DBManagerFactory.GetTransaction(this.ProviderType);
            this.idbCommand.Transaction = idbTransaction;
        }

        public void CommitTransaction()
        {
            if (this.idbTransaction != null)
                this.idbTransaction.Commit();
            idbTransaction = null;
        }

        public IDataReader ExecuteReader(CommandType commandType, string commandText)
        {
            this.idbCommand = DBManagerFactory.GetCommand(this.ProviderType);
            PrepareCommand(idbCommand, this.Connection, this.Transaction, commandType, commandText, this.Parameters);
            this.DataReader = idbCommand.ExecuteReader();
            idbCommand.Parameters.Clear();
            return this.DataReader;
        }

        public void CloseReader()
        {
            if (this.DataReader != null)
                this.DataReader.Close();
        }

        private void AttachParameters(IDbCommand command, IDbDataParameter[] commandParameters)
        {
            foreach (IDbDataParameter idbParameter in commandParameters)
            {
                if ((idbParameter.Direction == ParameterDirection.InputOutput) && (idbParameter.Value == null))
                {
                    idbParameter.Value = DBNull.Value;
                }
                command.Parameters.Add(idbParameter);
            }
        }

        private void PrepareCommand(IDbCommand command, IDbConnection connection, IDbTransaction transaction, CommandType commandType, string commandText, IDbDataParameter[] commandParameters)
        {
            command.Connection = connection;
            command.CommandText = commandText;
            command.CommandType = commandType;

            if (transaction != null)
            {
                command.Transaction = transaction;
            }

            if (commandParameters != null)
            {
                AttachParameters(command, commandParameters);
            }
        }

        public int ExecuteNonQuery(CommandType commandType, string commandText)
        {
            this.idbCommand = DBManagerFactory.GetCommand(this.ProviderType);
            PrepareCommand(idbCommand, this.Connection, this.Transaction,
            commandType, commandText, this.Parameters);
            int returnValue = idbCommand.ExecuteNonQuery();
            idbCommand.Parameters.Clear();
            return returnValue;
        }

        public object ExecuteScalar(CommandType commandType, string commandText)
        {
            this.idbCommand = DBManagerFactory.GetCommand(this.ProviderType);
            PrepareCommand(idbCommand, this.Connection, this.Transaction, commandType, commandText, this.Parameters);
            object returnValue = idbCommand.ExecuteScalar();
            idbCommand.Parameters.Clear();
            return returnValue;
        }

        public DataSet ExecuteDataSet(CommandType commandType, string commandText)
        {
            this.idbCommand = DBManagerFactory.GetCommand(this.ProviderType);
            PrepareCommand(idbCommand, this.Connection, this.Transaction, commandType, commandText, this.Parameters);
            IDbDataAdapter dataAdapter = DBManagerFactory.GetDataAdapter(this.ProviderType);
            dataAdapter.SelectCommand = idbCommand;
            DataSet dataSet = new DataSet();
            dataAdapter.Fill(dataSet);
            idbCommand.Parameters.Clear();
            return dataSet;
        }
        public void SQLBulkInsert(DataTable dt, string tableName)
        {
            SqlBulkCopy sqlBulkInsert = new SqlBulkCopy(strConnection);
            sqlBulkInsert.DestinationTableName = tableName;
            sqlBulkInsert.WriteToServer(dt);

        }
    }
}