public List <Entites.Employee> SalryGrid(int EmpID)
        {
            try
            {
                using (SqlConnection con = new SqlConnection(HRMConString))
                {
                    con.Open();
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = "SPEmpID";
                        cmd.Connection  = con;
                        SqlParameter prm = new SqlParameter();

                        prm           = cmd.Parameters.Add("@EmpID", SqlDbType.Int);
                        prm.Direction = ParameterDirection.Input;
                        prm.Value     = EmpID;

                        //forward onnly,read only online cursors
                        SqlDataReader           dr     = cmd.ExecuteReader();
                        List <Entites.Employee> Salgrd = new List <Entites.Employee>();

                        while (dr.Read())
                        {
                            Entites.Employee ES = new Entites.Employee();
                            ES.EmpFirstName = dr.GetString(0);
                            ES.EmpLastName  = dr.GetString(1);
                            ES.DOJ          = dr.GetDateTime(2);
                            // ES.Cname = dr.GetString(2);
                            ES.Gender  = dr.GetString(3);
                            ES.Address = dr.GetString(4);
                            ES.City    = dr.GetString(5);
                            ES.State   = dr.GetString(6);
                            ES.Email   = dr.GetString(7);
                            Salgrd.Add(ES);
                        }
                        dr.Close();
                        con.Close();
                        con.Dispose();
                        //dis is jst below dataredr obj
                        return(Salgrd);
                    }
                }
            }

            catch
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public List <Entites.Employee> RetriveEmpIDImage(int EmpID)
        {
            try
            {
                using (SqlConnection con = new SqlConnection(HRMConString))
                {
                    con.Open();

                    using (SqlCommand cmd = new SqlCommand())
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = "RetriveImage";
                        cmd.Connection  = con;

                        SqlParameter prm = new SqlParameter();

                        prm           = cmd.Parameters.Add("@Empid", SqlDbType.Int);
                        prm.Direction = ParameterDirection.Input;
                        prm.Value     = EmpID;

                        //forward onnly,read only online cursors
                        SqlDataReader           dr         = cmd.ExecuteReader();
                        List <Entites.Employee> empidimage = new List <Entites.Employee>();

                        while (dr.Read())
                        {
                            Entites.Employee Emp = new Entites.Employee();
                            Emp.EmpID = dr.GetInt32(0);
                            Emp.Photo = ((byte[])dr["Photo"]);
                            empidimage.Add(Emp);
                        }
                        dr.Close();
                        con.Close();
                        con.Dispose();

                        return(empidimage);
                    }
                }
            }

            catch
            {
                throw;
            }
        }
Ejemplo n.º 3
0
        public void AddEmployee(Entites.Employee emp)
        {
            try
            {
                using (SqlConnection con = new SqlConnection())
                {
                    con.ConnectionString = HRMConString;
                    con.Open();
                    string str = "SPAddEmployee";

                    using (SqlCommand cmd = new SqlCommand())
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = str;
                        cmd.Connection  = con;

                        SqlParameter sprm = new SqlParameter();

                        sprm           = cmd.Parameters.Add("@empid", SqlDbType.Int);
                        sprm.Direction = ParameterDirection.Input;
                        sprm.Value     = emp.EmpID;

                        sprm           = cmd.Parameters.Add("@efname", SqlDbType.NChar, 50);
                        sprm.Direction = ParameterDirection.Input;
                        sprm.Value     = emp.EmpFirstName;

                        sprm           = cmd.Parameters.Add("@elname", SqlDbType.NChar, 50);
                        sprm.Direction = ParameterDirection.Input;
                        sprm.Value     = emp.EmpLastName;

                        sprm           = cmd.Parameters.Add("@cname", SqlDbType.NChar, 50);
                        sprm.Direction = ParameterDirection.Input;
                        sprm.Value     = emp.CompanyName;

                        sprm           = cmd.Parameters.Add("@doj", SqlDbType.DateTime);
                        sprm.Direction = ParameterDirection.Input;
                        sprm.Value     = emp.DOJ;

                        sprm           = cmd.Parameters.Add("@dob", SqlDbType.DateTime);
                        sprm.Direction = ParameterDirection.Input;
                        sprm.Value     = emp.DOB;

                        sprm           = cmd.Parameters.Add("@gen", SqlDbType.NChar, 10);
                        sprm.Direction = ParameterDirection.Input;
                        sprm.Value     = emp.Gender;

                        sprm           = cmd.Parameters.Add("@addr", SqlDbType.NChar, 50);
                        sprm.Direction = ParameterDirection.Input;
                        sprm.Value     = emp.Address;

                        sprm           = cmd.Parameters.Add("@city", SqlDbType.NChar, 50);
                        sprm.Direction = ParameterDirection.Input;
                        sprm.Value     = emp.City;

                        sprm           = cmd.Parameters.Add("@state", SqlDbType.NChar, 50);
                        sprm.Direction = ParameterDirection.Input;
                        sprm.Value     = emp.State;

                        sprm           = cmd.Parameters.Add("@phne", SqlDbType.Decimal);
                        sprm.Direction = ParameterDirection.Input;
                        sprm.Value     = emp.Phone;

                        sprm           = cmd.Parameters.Add("@email", SqlDbType.NVarChar, 50);
                        sprm.Direction = ParameterDirection.Input;
                        sprm.Value     = emp.Email;

                        sprm           = cmd.Parameters.Add("@phot", SqlDbType.Image);
                        sprm.Direction = ParameterDirection.Input;
                        sprm.Value     = emp.Photo;

                        sprm           = cmd.Parameters.Add("@role", SqlDbType.Int);
                        sprm.Direction = ParameterDirection.Input;
                        sprm.Value     = emp.RoleID;

                        sprm           = cmd.Parameters.Add("@pass", SqlDbType.NVarChar, 50);
                        sprm.Direction = ParameterDirection.Input;
                        sprm.Value     = emp.Pass;
                        cmd.ExecuteNonQuery();
                    }
                }
            }
            catch
            {
                throw;
            }
        }