예제 #1
0
        //Method Wich is a stored procdure in the sql server

        public int EmployeeInsert(AdminBL NewEmployee)
        {
            SqlParameter[] parm = new SqlParameter[8];
            parm[0] = new SqlParameter("@Name", NewEmployee.Name);
            parm[1] = new SqlParameter("@Age", NewEmployee.Age);
            parm[2] = new SqlParameter("@Salary", NewEmployee.Salary);
            parm[3] = new SqlParameter("@RoleID", NewEmployee.RoleID);
            parm[4] = new SqlParameter("@About", NewEmployee.About);
            parm[5] = new SqlParameter("@image", NewEmployee.Image);
            parm[6] = new SqlParameter("@UserName", NewEmployee.UserName);
            parm[7] = new SqlParameter("@Password", NewEmployee.Password);
            return(ExecNonQuery("Sp_InsertEmployee", CommandType.StoredProcedure, parm));
        }
예제 #2
0
        public AdminBL SelectEmployeeByID(int ID)
        {
            SqlParameter[] parm = new SqlParameter[1];
            parm[0] = new SqlParameter("@ID", ID);

            DataTable tb       = ExecReader("sp_SelectEmployeeByID", CommandType.StoredProcedure, parm);
            AdminBL   Employee = new AdminBL();

            Employee.ID     = (int)tb.Rows[0][0];
            Employee.Name   = tb.Rows[0][1].ToString();
            Employee.Age    = Convert.ToInt32(tb.Rows[0]["Age"].ToString());
            Employee.Salary = (decimal)tb.Rows[0][3];
            Employee.RoleID = (int)tb.Rows[0][4];
            Employee.About  = tb.Rows[0][5].ToString();
            //put it in stream to use it
            Employee.Image = tb.Rows[0][6] as byte[];

            Employee.UserName = tb.Rows[0]["UserName"].ToString();
            Employee.Password = tb.Rows[0]["Password"].ToString();
            return(Employee);
        }