public string UpdateEmployee(int id, string name, string phone, string email, string address, bool gender, string qualification, string img_path) { try { var query = from a in connection.Emp_Tables where a.Id == id select a; if (query.Count() != 0) { Emp_Table emp = query.First(); emp.Name = name; emp.Phone = phone; emp.Email = email; emp.Address = address; emp.Gender = gender; emp.Qualification = qualification; if (img_path != null) { FileStream fs = new FileStream(img_path, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); emp.Image = br.ReadBytes((int)fs.Length); } connection.SubmitChanges(); return("Employee Information Updated!"); } else { return("This Employee Is Not Exist"); } } catch (Exception ex) { return(ex.ToString()); } }
public string AddEmployee(string name, string phone, string email, string address, bool gender, string qualification, string img_path) { try { Emp_Table emp = new Emp_Table(); emp.Name = name; emp.Phone = phone; emp.Email = email; emp.Address = address; emp.Gender = gender; emp.Qualification = qualification; FileStream fs = new FileStream(img_path, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); emp.Image = br.ReadBytes((int)fs.Length); emp.Password = "******"; emp.Admin = false; connection.Emp_Tables.InsertOnSubmit(emp); connection.SubmitChanges(); var query = from a in connection.Emp_Tables where a.Id == connection.Emp_Tables.Max(ab => ab.Id) select a; Emp_Detail edt = new Emp_Detail(); edt.Emp_Id = query.First().Id; edt.Curr_Status = (byte)1; connection.Emp_Details.InsertOnSubmit(edt); connection.SubmitChanges(); return("Employee Information Saved!"); } catch (Exception ex) { return(ex.ToString()); } }
private void button3_Click_1(object sender, EventArgs e) { bunifuMaterialTextbox3.Text = bunifuMaterialTextbox3.Text.Trim(' '); bunifuMaterialTextbox5.Text = bunifuMaterialTextbox5.Text.Trim(' '); try { int e_id = int.Parse(bunifuMaterialTextbox3.Text); bool idflag = emp.CheckId(e_id); if (idflag == true) { object employee = emp.ReturnEmployee(e_id); Data_Access_Layer.Emp_Table user_emp = (Data_Access_Layer.Emp_Table)employee; if (user_emp.Password == bunifuMaterialTextbox5.Text) { if (bunifuCheckbox1.Checked == true) { Settings.Default["U_Name"] = bunifuMaterialTextbox3.Text; Settings.Default["U_Pass"] = bunifuMaterialTextbox5.Text; Settings.Default["Remember"] = true; Settings.Default.Save(); } else { Settings.Default["U_Name"] = null; Settings.Default["U_Pass"] = null; Settings.Default["Remember"] = false; Settings.Default.Save(); } this.Hide(); if (user_emp.Admin == true) { Form8 f8 = new Form8(e_id); this.Hide(); f8.Show(); } else { Form2 f2 = new Form2(e_id); this.Hide(); f2.Show(); } } else { MessageBox.Show("You Entered A Wrong Password"); } } else { MessageBox.Show("You Entered A Wrong Id"); } } catch (Exception x) { MessageBox.Show(x.ToString()); } }
public bool UpdatePassword(int id, string password) { try { var query = from a in connection.Emp_Tables where a.Id == id select a; Emp_Table emp = query.First(); emp.Password = password; connection.SubmitChanges(); return(true); } catch (Exception) { return(false); } }
partial void DeleteEmp_Table(Emp_Table instance);
partial void UpdateEmp_Table(Emp_Table instance);
partial void InsertEmp_Table(Emp_Table instance);