public void DeleteEmployee(int employeeId) { EmployeeTable employee = db.EmployeeTables.Find(employeeId); db.EmployeeTables.Remove(employee); db.SaveChanges(); }
public static bool AddNew(EmployeeDto emp) { EmployeeTable e = EmployeeDto.ToDal(emp); bool b = Dal.EmployeeDal.AddNew(e); return(b); }
public string EditEmployee(EmployeeModels emp) { if (ModelState.IsValid) { if (emp != null) { var empStatus = db.EmployeeTables.Where(a => a.EmpID == emp.empID); if (empStatus != null) { EmployeeTable employee = db.EmployeeTables.Where(a => a.EmpID == emp.empID).FirstOrDefault(); employee.EmpID = emp.empID; employee.EmpName = emp.employeeName; employee.EmpAddress = emp.employeeAddress; employee.EmpDesignation = emp.employeeDesignation; employee.CreatedBy = emp.createdBy; db.SaveChanges(); return("Successfull"); } else { return("No record found"); } } else { return("error while updating employee"); } } else { return("Please insert data in correct format"); } }
public void SaveCommandClick(object obj) { if (Fio != string.Empty || Birthday != string.Empty || Contacts != string.Empty || Post != string.Empty || PersonalData != string.Empty) { using (var db = new MeiMeiContext()) { var emploeyy = new EmployeeTable { FIO = Fio, Birthday = Birthday, Contacts = Contacts, Post = Post, Salary = Salarity, PersonalData = PersonalData, Photo = a }; db.EmployeeTables.Add(emploeyy); db.SaveChanges(); } MessageBox.Show(Properties.Resources.Сompleted_message, "", MessageBoxButton.OK, MessageBoxImage.Information); Fio = string.Empty; Birthday = string.Empty; Contacts = string.Empty; Post = string.Empty; PersonalData = string.Empty; Salarity = string.Empty; _employeeVMOwner.EmployeeFIOCollection = _employeeVMOwner.EmployeeFIOCollection; } else { MessageBox.Show(Properties.Resources.FirstFill_message, Properties.Resources.Attention_message, MessageBoxButton.OK, MessageBoxImage.Information); } }
public IHttpActionResult SaveEmployee(Employee employee) { EmpDbEntities entity = new EmpDbEntities(); EmployeeTable exist = entity.EmployeeTables.Where(d => d.EmployeeName == employee.EmployeeName).FirstOrDefault(); if (exist != null) { throw new Exception("Record is already exist"); } EmployeeTable table = new EmployeeTable(); table.EmployeeName = employee.EmployeeName; table.EmployeeAddress = employee.EmployeeAddress; table.EmployeePhoneNo = employee.EmployeePhoneNo; table.EmployeeEmail = employee.EmployeeEmail; table.IsActive = employee.IsActive; entity.EmployeeTables.Add(table); int result = entity.SaveChanges(); long empId = table.EmployeeId; if (result > 0) { return(Ok(empId)); } else { return(BadRequest("Failed to Save")); } }
public List <EmployeeTable> getAll(string user, string userId, int page, string comName, string RealName, string Address, string comPhone) { string sqlStr = "update EmployeeTable set e_Name = '" + comName + "',e_RealName = '" + RealName + "',e_Address = '" + Address + "',e_Phone = '" + comPhone + "' where e_Id = " + userId; EmployeeTable.delOrUpTable(sqlStr); return(EmployeeTable.getAll(page)); }
protected void Page_Load(object sender, EventArgs e) { first = true; try { id = Int32.Parse(Server.UrlDecode(Request.QueryString["id"])); } catch (ArgumentNullException) { Response.Redirect("~/"); } EmployeeTable empTable = new EmployeeTable(); emp = new Employee(); emp = empTable.Select(id); if (!Page.IsPostBack) { DoUpdate = false; TextBoxAdress.Text = emp.adress.ToString(); TextBoxCity.Text = emp.city.ToString(); TextBoxExperience.Text = emp.experience.ToString(); TextBoxFname.Text = emp.fname.ToString(); TextBoxLname.Text = emp.lname.ToString(); TextBoxLogin.Text = emp.login.ToString(); TextBoxPassword.Text = emp.password.ToString(); TextBoxPhone.Text = emp.phone.ToString(); } strBuilCommand = new StringBuilder(); strBuilCommand.Append("update Employees set"); }
public IHttpActionResult PutEmployeeTable(int id, EmployeeTable employeeTable) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != employeeTable.EmployeeID) { return(BadRequest()); } db.Entry(employeeTable).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EmployeeTableExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public string DeleteEmployee(string employeeId) { if (ModelState.IsValid) { if (!String.IsNullOrEmpty(employeeId)) { var empID = Convert.ToInt32(employeeId); var empStatus = db.EmployeeTables.Where(a => a.EmpID == empID); if (empStatus != null) { EmployeeTable employee = db.EmployeeTables.Where(a => a.EmpID == empID).FirstOrDefault(); db.EmployeeTables.Remove(employee); db.SaveChanges(); return("Employee Deleted"); } else { return("Employee Not Found"); } } else { return("error while deleting employee"); } } else { return("Data is not in correct format"); } }
public string AddEmployee(EmployeeModels emp) { if (ModelState.IsValid) { if (emp != null) { var emptable = new EmployeeTable { EmpName = emp.employeeName, EmpDesignation = emp.employeeDesignation, EmpAddress = emp.employeeAddress, CreatedBy = emp.createdBy, DepartmentID = emp.deptID, }; db.EmployeeTables.Add(emptable); db.SaveChanges(); return("Successfull"); } else { return("error while adding employee"); } } else { return("Please insert data in correct format"); } }
public IHttpActionResult UpdateEmployee(string employeeName, Employee employee) { EmpDbEntities entity = new EmpDbEntities(); EmployeeTable exist = entity.EmployeeTables.Where(d => d.EmployeeName == employeeName).FirstOrDefault(); if (exist != null) { exist.EmployeeName = employee.EmployeeName; exist.EmployeeAddress = employee.EmployeeAddress; exist.EmployeeEmail = employee.EmployeeEmail; exist.EmployeePhoneNo = employee.EmployeePhoneNo; exist.IsActive = employee.IsActive; entity.EmployeeTables.Add(exist); int result = entity.SaveChanges(); if (result > 0) { return(Ok("Successfully updated")); } else { return(BadRequest("Failed to Update")); } } else { return(BadRequest("Failed to Update")); } }
public IHttpActionResult SaveEmployees(List <Employee> employee) { EmpDbEntities entity = new EmpDbEntities(); employee.ForEach(d => { EmployeeTable exist = entity.EmployeeTables.Where(k => k.EmployeeName == d.EmployeeName).FirstOrDefault(); if (exist != null) { throw new Exception("Record is Already exist"); } EmployeeTable table = new EmployeeTable(); table.EmployeeName = d.EmployeeName; table.EmployeeAddress = d.EmployeeAddress; table.EmployeeEmail = d.EmployeeEmail; table.EmployeePhoneNo = d.EmployeePhoneNo; entity.EmployeeTables.Add(table); }); int result = entity.SaveChanges(); if (result > 0) { return(Ok("Successfully Ssaved")); } else { return(BadRequest("Failed to Save")); } }
private void EmployeeForm_Activated(object sender, EventArgs e) { using (var context = new PineappleContext()) { EmployeeTable.DataSource = null; EmployeeTable.Rows.Clear(); EmployeeTable.Refresh(); context.Employees.Load(); DbSet <Employee> employees = context.Employees; int i = 0; EmployeeTable.RowCount = employees.Count(); foreach (Employee employee in employees) { EmployeeTable[0, i].Value = employee.Id; EmployeeTable[1, i].Value = employee.Name; EmployeeTable[2, i].Value = employee.Surname; EmployeeTable[3, i].Value = employee.DateOfBirth.ToString("dd.MM.yyyy"); EmployeeTable[4, i].Value = employee.Position; EmployeeTable[5, i].Value = employee.Department; i++; } } }
public List <EmployeeTable> getAll(string user, string userId, int page) { string sqlStr = "delete EmployeeTable where e_Id = " + userId; EmployeeTable.delOrUpTable(sqlStr); return(EmployeeTable.getAll(page)); }
protected void EmployeeTable_RowDeleting(object sender, GridViewDeleteEventArgs e) { string SSN = ((Label)EmployeeTable.Rows[e.RowIndex].Cells[1].FindControl("Label1")).Text; client.RemoveEmployee(SSN); EmployeeTable.DataSource = client.GetAllEmployees(); EmployeeTable.DataBind(); }
public EmployeeProfileController() { this._employeeProfileTable = new EmployeeProfileTable(); this._userTable = new UserTable(); validatepermissions = new validatePermissions(); _logTable = new LogBook.Controllers.LogBookController(); _employeeTable = new EmployeeTable(); }
public ActionResult Delete(int id, EmployeeTable employee) { var del = db.Employees.Where(r => r.Id == id).FirstOrDefault(); db.Employees.Remove(del); db.SaveChanges(); return(RedirectToAction("Index")); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { EmployeeTable.DataSource = client.GetAllEmployees(); EmployeeTable.DataBind(); DepartmentTable.DataSource = client.GetAllDepartments(); DepartmentTable.DataBind(); } }
public IHttpActionResult GetEmployeeTable(int id) { EmployeeTable employeeTable = db.EmployeeTable.Find(id); if (employeeTable == null) { return(NotFound()); } return(Ok(employeeTable)); }
public ActionResult Update(EmployeeTable emp) { var updated = db.Employees.Where(e => e.Id == emp.Id).FirstOrDefault(); updated.EName = emp.EName; updated.ESalary = emp.ESalary; updated.DeptId = emp.DeptId; updated.MId = emp.MId; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(EmployeeTable ee) { if (!ModelState.IsValid) { return(RedirectToAction("Create")); } db.Employees.Add(ee); db.SaveChanges(); return(RedirectToAction("Index")); }
public IHttpActionResult PostEmployeeTable(EmployeeTable employeeTable) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.EmployeeTable.Add(employeeTable); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = employeeTable.EmployeeID }, employeeTable)); }
/// <summary> /// 判断用户是否被注册 /// </summary> /// <param name="PhoneOrMail">手机或邮箱</param> /// <param name="pwd">密码</param> /// <param name="isPhone">注册方式</param> /// <returns>相关提示信息</returns> public static string insertTable(string PhoneOrMail, string pwd, bool isPhone) { if (EmployeeTable.hasPhoneOrMail(PhoneOrMail, isPhone)) { return(isPhone ? "该号码已被注册" : "该邮箱已被注册"); } else { EmployeeTable.insertTable(PhoneOrMail, pwd, isPhone); return("注册成功"); } }
public ActionResult DeleteConfirmed(int id) { if (string.IsNullOrEmpty(Convert.ToString(Session["UserID"]))) { return(RedirectToAction("Login", "Home")); } EmployeeTable employeeTable = db.EmployeeTables.Find(id); db.EmployeeTables.Remove(employeeTable); db.SaveChanges(); return(RedirectToAction("Index")); }
public int UpdateEmployee(EmployeeTable employee) { int result = -1; if (employee != null) { db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); result = employee.ID; } return(result); }
public static EmployeeDto Login(string id, string password) { EmployeeTable e = Dal.EmployeeDal.Login(id, password); if (e != null) { EmployeeDto emp = new EmployeeDto(e); return(emp); } return(null); }
public int AddEmployee(EmployeeTable employee) { int result = -1; if (employee != null) { db.EmployeeTables.Add(employee); db.SaveChanges(); result = employee.ID; } return(result); }
public ActionResult Delete(EmployeeTable employee) { try { _employeeRepository.DeleteEmployee(employee.ID); return(RedirectToAction("Index")); } catch { return(View()); } }
public EmployeeController() { // validatelim = new ValidateLimits(); validatepermissions = new validatePermissions(); employeeprofileTable = new EmployeeProfileTable(); witnessesModel = new MongoModel("witnesses"); _listTable = new ListTable(); employeetable = new EmployeeTable(); Notificate = new Notifications(); _logTable = new LogBook.Controllers.LogBookController(); userTable = new UserTable(); profileTable = new ProfileTable(); listTable = new ListTable(); }
public IHttpActionResult DeleteEmployeeTable(int id) { EmployeeTable employeeTable = db.EmployeeTable.Find(id); if (employeeTable == null) { return(NotFound()); } db.EmployeeTable.Remove(employeeTable); db.SaveChanges(); return(Ok(employeeTable)); }
private void button1_Click(object sender, EventArgs e) { EmployeeTable emp = new EmployeeTable(); emp.Employee_Name = NameTextBox.Text; emp.Employee_Location = LocationTextBox.Text; emp.Employee_Salary = Convert.ToDecimal(SalaryTextBox.Text); //MessageBox.Show($"Name:{emp.Employee_Name},Location:{emp.Employee_Location},Salary:{emp.Employee_Salary}"); using (var empObj = new EmployeeContext()) { empObj.Employee_Records.Add(emp); empObj.SaveChanges(); MessageBox.Show($"Name:{emp.Employee_Name},Location:{emp.Employee_Location},Salary:{emp.Employee_Salary} inserted successfully"); } }
protected void Button1_Click(object sender, EventArgs e) { EmployeeTable empTable = new EmployeeTable(); StoredWheelsTable stTable = new StoredWheelsTable(); if (empTable.CheckPasword(Int32.Parse(DropDownList1.SelectedValue), TextBox1.Text)) { int cstID = Int32.Parse(Server.UrlDecode(Request.QueryString["id"])); int empID = Int32.Parse(DropDownList1.SelectedValue); if (stTable.UnstoreTires(cstID, empID)) { Response.Redirect("~/Customers/Customers"); } else { Page.ClientScript.RegisterStartupScript(GetType(), "msgbox", "alert('Něco je špatně');", true); } } }
protected void ButtonStani2_Click(object sender, EventArgs e) { Contract con = new Contract(); EmployeeTable empTable = new EmployeeTable(); try { con.CustomerId = Int32.Parse(GridView1.SelectedValue.ToString()); } catch { Page.ClientScript.RegisterStartupScript(GetType(), "msgbox", "alert('Nejdříve musíte vybrat klienta');", true); return; } ContractTable conTable = new ContractTable(); con.EmployeesId = Int32.Parse(DropDownList1.SelectedValue.ToString()); con.GarageNumber = 2; conTable.Arrival(con); Response.Redirect("~/Contracts/Contracts"); }
protected void ButtonSubmit_Click(object sender, EventArgs e) { try { Employee emp = new Employee() { login = TextBoxLogin.Text, fname = TextBoxFname.Text, lname = TextBoxLname.Text, password = TextBoxPassword.Text, phone = TextBoxPhone.Text, adress = TextBoxAdress.Text, city = TextBoxCity.Text, experience = Byte.Parse(TextBoxExperience.Text) }; EmployeeTable tb = new EmployeeTable(); tb.Insert(emp); Response.Redirect("~/Employees/ListEmployee"); } catch { Page.ClientScript.RegisterStartupScript(GetType(), "msgbox", "alert('Máš to špatně');", true); } }
public static void Query_Basic_ConversionToType( IKLink link ) { Console.WriteLine( "\n===== Basic Query with conversion to a given type..." ); var cmd = link.From( x => x.Employees.As( x.Emp ) ); Console.WriteLine( "\n> Command => {0}", cmd ); foreach( EmployeeTable obj in cmd.ConvertBy( rec => { // Using several ways of accessing the columns... EmployeeTable emp = new EmployeeTable(); dynamic d = rec; emp.Id = d.Id; emp.FirstName = (string)rec["FirstName"]; emp.LastName = (string)rec["Emp", "LastName"]; // Using the hard way, the indexed one, we need to take care of the type conversions... // object orig = rec["Employees", "BirthDate"]; // CalendarDate date = orig == null ? null : new CalendarDate( (DateTime)orig ); // emp.BirthDate = date; emp.BirthDate = d.BirthDate; // If using dynamics no conversion specification is needed emp.JoinDate = d.JoinDate; emp.StartTime = d.StartTime; emp.Active = d.Active; emp.ManagerId = d.Emp.ManagerId; // Using the alias emp.CountryId = d.Employees.CountryId; // Using the table name emp.Photo = d.Photo; return emp; } ) ) Console.WriteLine( "\n> Employee => {0}", obj ); cmd.Dispose(); }
static void _Nested_Readers_Employees( IKLink link, CountryTable ctry ) { var cmd = link.From( x => x.Employees ).Where( x => x.CountryId == ctry.Id ); DEBUG.IndentLine( "\n> Command => {0}", cmd ); foreach( var emp in cmd.ConvertBy( rec => { EmployeeTable table = new EmployeeTable(); dynamic d = rec; table.Id = d.Id; table.FirstName = d.FirstName; table.LastName = d.LastName; table.CountryId = d.CountryId; ctry.Employees.Add( table ); return table; } ) ) DEBUG.WriteLine( "\n> Employee => {0}", emp ); cmd.Dispose(); DEBUG.Unindent(); }
static void _Nested_UpdateReaders_Employees( IKLink link ) { var cmd = link.Update( x => x.Employees ) .Where( x => x.CountryId == "es" ) .Column( x => x.CountryId = "es#" ); DEBUG.IndentLine( "\n> Command => {0}", cmd ); foreach( var emp in cmd.ConvertBy( rec => { EmployeeTable table = new EmployeeTable(); dynamic d = rec; table.Id = d.Id; table.FirstName = d.FirstName; table.LastName = d.LastName; table.CountryId = d.CountryId; return table; } ) ) DEBUG.WriteLine( "\n> Employee => {0}", emp ); cmd.Dispose(); DEBUG.Unindent(); }