示例#1
0
 private void btn_Newemployee_Click(object sender, EventArgs e)
 {
     if (txt_employeename.Text == String.Empty)
     {
         MessageBox.Show("Enter Name:");
     }
     else if (txt_employeecity.Text == String.Empty)
     {
         MessageBox.Show("enter city:");
     }
     else if (txt_employeesalary.Text == String.Empty)
     {
         MessageBox.Show("enter salary:");
     }
     else if (txt_employeepassword.Text == String.Empty)
     {
         MessageBox.Show("enter password:"******"employee added:id:" + id);
     }
 }
示例#2
0
        public int AddEmployee(Employeemodel model)
        {
            SqlCommand com_add_employee = new SqlCommand("proc_addemployee", con);

            com_add_employee.Parameters.AddWithValue("@name", model.employeename);
            com_add_employee.Parameters.AddWithValue("@city", model.employeecity);
            com_add_employee.Parameters.AddWithValue("@salary", model.employeesalary);
            com_add_employee.Parameters.AddWithValue("@password", model.employeepassword);

            com_add_employee.CommandType = CommandType.StoredProcedure;

            SqlParameter para_return = new SqlParameter();

            para_return.Direction = ParameterDirection.ReturnValue;

            com_add_employee.Parameters.Add(para_return);
            con.Open();

            com_add_employee.ExecuteNonQuery();//exec proc

            con.Close();

            int id = Convert.ToInt32(para_return.Value);

            return(id);
        }
示例#3
0
        public List <Employeemodel> Searchemployee(string key)
        {
            SqlCommand com_search = new SqlCommand("proc_searchemployee", con);

            com_search.Parameters.AddWithValue("@key", key);
            com_search.CommandType = CommandType.StoredProcedure;
            con.Open();
            SqlDataReader        dr   = com_search.ExecuteReader();
            List <Employeemodel> list = new List <Employeemodel>();

            while (dr.Read())
            {
                Employeemodel model = new Employeemodel();
                model.employeeid       = dr.GetInt32(0);
                model.employeename     = dr.GetString(1);
                model.employeecity     = dr.GetString(2);
                model.employeesalary   = dr.GetInt32(3);
                model.employeepassword = dr.GetString(4);
                list.Add(model);
            }
            con.Close();
            return(list);
        }
示例#4
0
        public Employeemodel Findemployee(int id)
        {
            SqlCommand com_find = new SqlCommand("proc_findemployee", con);

            com_find.Parameters.AddWithValue("@id", id);
            com_find.CommandType = CommandType.StoredProcedure;
            con.Open();
            SqlDataReader dr = com_find.ExecuteReader();

            if (dr.Read())
            {
                Employeemodel model = new Employeemodel();
                model.employeeid       = dr.GetInt32(0);
                model.employeename     = dr.GetString(1);
                model.employeecity     = dr.GetString(2);
                model.employeesalary   = dr.GetInt32(3);
                model.employeepassword = dr.GetString(4);
                con.Close();
                return(model);
            }
            con.Close();
            return(null);
        }
示例#5
0
 private void btn_find_Click(object sender, EventArgs e)
 {
     if (txt_enteremployeeid.Text == String.Empty)
     {
         MessageBox.Show("enter id:");
     }
     else
     {
         int           id    = Convert.ToInt32(txt_enteremployeeid.Text);
         EmployeesDAL  dal   = new EmployeesDAL();
         Employeemodel model = dal.Findemployee(id);
         if (model != null)
         {
             txt_employeename.Text     = model.employeename;
             txt_employeecity.Text     = model.employeecity;
             txt_employeesalary.Text   = model.employeesalary.ToString();
             txt_employeepassword.Text = model.employeepassword;
         }
         else
         {
             MessageBox.Show("employee not found");
         }
     }
 }