protected void btnupdateEmployee_Click(object sender, EventArgs e) { DBFunctions db = new DBFunctions(); DateTime dob = DateTime.Parse(dropdownyears.SelectedItem.Text + "-" + dropdownMonth.SelectedItem.Text + "-" + dropdownDay.SelectedItem.Text); Employee_tbl employee = new Employee_tbl {ID=int.Parse(Request.QueryString["empid"]), Name = EmpNametxt.Text, Qualification = Qualificationtxt.Text, PhoneNumber = phonetxt.Text, Gender = dropdownGender.SelectedValue, Deptid = int.Parse(DeptList.SelectedValue), DateOFBirth = dob.ToShortDateString(), Email = Emailtxt.Text, CNIC = CNICtxt.Text, Address = Addresstxt.Text, City = Citytxt.Text, BankAccountNumber = Accounttxt.Text, Bank = Banktxt.Text, Designation = Designationtxt.Text, EmployeeType = int.Parse(DropDownEmpType.SelectedValue) }; db.updateEmployee(employee); Response.Redirect("ManageEmployee.aspx"); }
public void updateEmployee(Employee_tbl employee) { db = new CollegeERPDBEntities(); db.Employee_tbl.Attach(employee); // var progrm = db.Program_tbl.Where(x => x.ID == id).FirstOrDefault(); db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); }
public Employee_tbl addEmployee(Employee_tbl Employee) { db = new CollegeERPDBEntities(); db.Employee_tbl.Add(Employee); db.SaveChanges(); return Employee; }
protected void btnaddEmployee_Click(object sender, EventArgs e) { DBFunctions db = new DBFunctions(); DateTime dob=DateTime.Parse(dropdownyears.SelectedItem.Text+"-"+dropdownMonth.SelectedItem.Text+"-"+dropdownDay.SelectedItem.Text); Employee_tbl employee = new Employee_tbl { Name = EmpNametxt.Text, Qualification = Qualificationtxt.Text, PhoneNumber = phonetxt.Text, Gender = dropdownGender.SelectedValue, Deptid = int.Parse(DeptList.SelectedValue), DateOFBirth = dob.ToShortDateString(), Email = Emailtxt.Text, CNIC = CNICtxt.Text, Address = Addresstxt.Text, City = Citytxt.Text, BankAccountNumber = Accounttxt.Text, Bank = Banktxt.Text,Designation=Designationtxt.Text,EmployeeType=int.Parse(DropDownEmpType.SelectedValue),Username=usernametxt.Text,Password=Passwordtxt.Text,IsFirstTime=0 }; employee = db.addEmployee(employee); employee.Department_tbl = db.getalldepartments().Where(x => x.ID == int.Parse(DeptList.SelectedValue)).FirstOrDefault(); List<Employee_tbl> emp = new List<Employee_tbl>(); emp.Add(employee); renderemployees(emp); }