public IHttpActionResult PutEmpSalary(int id, EmpSalary empSalary) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != empSalary.Id) { return(BadRequest()); } db.Entry(empSalary).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EmpSalaryExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
protected void salaryCalculator_Click(object sender, EventArgs e) { DateTime date = DateTime.Now; var firstDayOfMonth = new DateTime(date.Year, date.Month, 1); var lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1); int fridays = CountDays(DayOfWeek.Friday, firstDayOfMonth, lastDayOfMonth); var employee = _employeeUserManager.GetEmployeeById(EmployeeId); int month = int.Parse(DateTime.Now.ToString("MM")); int year = int.Parse(DateTime.Now.Year.ToString()); int days = DateTime.DaysInMonth(year, month) - fridays; double salaryPerDay = employee.BasicSalary / days; if (days != Count) { int absentday = days - Count; employee.BasicSalary -= (absentday * salaryPerDay); } var empSalary = new EmpSalary() { EmployeeName = employee.FullName, EmployeeCode = employee.EmployeeId, TotalPresentDay = Count, Salary = employee.BasicSalary }; Session["empSalalry"] = empSalary; Response.Redirect("EmployeeSalary.aspx"); }
private void btnDelete_Click(object sender, EventArgs e) { try { EmpSalary oEmpSalary = new EmpSalary(); if (lsvEmpSalary.SelectedItems != null && lsvEmpSalary.SelectedItems.Count > 0) { oEmpSalary = (EmpSalary)lsvEmpSalary.SelectedItems[0].Tag; if (MessageBox.Show("Do you want to delete the selected item?", "Delete Setup", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { using (DEWSRMEntities db = new DEWSRMEntities()) { db.EmpSalaries.Attach(oEmpSalary); db.EmpSalaries.Remove(oEmpSalary); db.SaveChanges(); } RefreshList(); } } } catch (Exception Ex) { MessageBox.Show("Cannot delete item due to " + Ex.Message); } }
private void btnSave_Click(object sender, EventArgs e) { if (MessageBox.Show("Do you want to save the information?", "Save Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { using (DEWSRMEntities db = new DEWSRMEntities()) { if (_EmpSalary.EmpSalaryID <= 0) { RefreshObject(); _EmpSalary.EmpSalaryID = db.EmpSalaries.Count() > 0 ? db.EmpSalaries.Max(obj => obj.EmpSalaryID) + 1 : 1; db.EmpSalaries.Add(_EmpSalary); } else { _EmpSalary = db.EmpSalaries.FirstOrDefault(obj => obj.EmpSalaryID == _EmpSalary.EmpSalaryID); RefreshObject(); } db.SaveChanges(); MessageBox.Show("Data saved successfully.", "Save Information", MessageBoxButtons.OK, MessageBoxIcon.Information); if (MessageBox.Show("Do you want to paid another employee salary?", "Salary Paid.", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { if (ItemChanged != null) { ItemChanged(); } this.Close(); } else { if (ItemChanged != null) { ItemChanged(); } _EmpSalary = new EmpSalary(); RefreshValue(); } } } catch (Exception ex) { if (ex.InnerException == null) { MessageBox.Show(ex.Message, "Failed to save", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(ex.InnerException.Message, "Failed to save", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public IHttpActionResult GetEmpSalary(int id) { EmpSalary empSalary = db.EmpSalaries.Find(id); if (empSalary == null) { return(NotFound()); } return(Ok(empSalary)); }
protected void Page_Load(object sender, EventArgs e) { if (Session["empSalalry"] != null) { EmpSalary empSalary = (EmpSalary)Session["empSalalry"]; nameLabel.Text = empSalary.EmployeeName; employeeCodelabel.Text = empSalary.EmployeeCode; workingDayLabel.Text = empSalary.TotalPresentDay.ToString(); salaryLabel.Text = empSalary.Salary.ToString(); } }
public void SaveEmpSalary(EmpSalary empSalary) { try { context.EmpSalary.Add(empSalary); context.SaveChanges(); } catch (Exception ex) { } }
public ActionResult Edit([Bind(Include = "Id,EmployeeId,SalaryAmn,Date")] EmpSalary empSalary) { if (ModelState.IsValid) { db.Entry(empSalary).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.EmployeeId = new SelectList(db.Employees, "Id", "Name", empSalary.EmployeeId); return(View(empSalary)); }
public IHttpActionResult PostEmpSalary(EmpSalary empSalary) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.EmpSalaries.Add(empSalary); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = empSalary.Id }, empSalary)); }
public ActionResult DeleteConfirmed(int id) { EmpSalary empSalary = db.EmpSalaries.Find(id); int EmpId = empSalary.EmployeeId; Employee e1 = db.Employees.Find(EmpId); e1.Salary = e1.Salary - empSalary.SalaryAmn; db.EmpSalaries.Remove(empSalary); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: EmpSalaries/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmpSalary empSalary = db.EmpSalaries.Find(id); if (empSalary == null) { return(HttpNotFound()); } return(View(empSalary)); }
public IHttpActionResult DeleteEmpSalary(int id) { EmpSalary empSalary = db.EmpSalaries.Find(id); if (empSalary == null) { return(NotFound()); } db.EmpSalaries.Remove(empSalary); db.SaveChanges(); return(Ok(empSalary)); }
// GET: EmpSalaries/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmpSalary empSalary = db.EmpSalaries.Find(id); if (empSalary == null) { return(HttpNotFound()); } ViewBag.EmployeeId = new SelectList(db.Employees, "Id", "Name", empSalary.EmployeeId); return(View(empSalary)); }
public ActionResult Create([Bind(Include = "Id,EmployeeId,SalaryAmn,Date")] EmpSalary empSalary) { if (ModelState.IsValid) { db.EmpSalaries.Add(empSalary); db.SaveChanges(); Employee e1 = db.Employees.Find(empSalary.EmployeeId); e1.Salary = e1.Salary + empSalary.SalaryAmn; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.EmployeeId = new SelectList(db.Employees, "Id", "Name", empSalary.EmployeeId); return(View(empSalary)); }
/// <summary> /// 根据员工id获取该员工最近三个月的工资详情 /// </summary> /// <param name="employeeid">员工id</param> /// <returns></returns> public List <EmpSalary> GetEmpSalaryIofo(string employeeid) { DataTable dt = employeedal.GetEmpSalaryIofo(employeeid); List <EmpSalary> list = new List <EmpSalary>(); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { EmpSalary result = new EmpSalary(); result.SendDate = dt.Rows[i]["sendtovbankdate"].ToString(); result.tureSalary = dt.Rows[i]["tureSalary"].ToString(); result.subSalary = dt.Rows[i]["subSalary"].ToString(); result.soSalary = dt.Rows[i]["soSalary"].ToString(); list.Add(result); } } return(list); }
public void EditEmpSalary(EmpSalary empSalary) { try { var empSal = context.EmpSalary.Find(empSalary.EmployeeID); if (empSal != null) { empSalary.Id = empSal.Id; context.Entry(empSal).CurrentValues.SetValues(empSalary); context.SaveChanges(); } else { context.EmpSalary.Add(empSalary); context.SaveChanges(); } } catch (Exception ex) { throw; } }
private void btnEdit_Click(object sender, EventArgs e) { try { if (lsvEmpSalary.SelectedItems.Count <= 0) { MessageBox.Show("select an item to edit", "Item not yet selected", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } EmpSalary oEmpSalary = null; fEmployeeSalary frm = new fEmployeeSalary(); if (lsvEmpSalary.SelectedItems != null && lsvEmpSalary.SelectedItems.Count > 0) { oEmpSalary = (EmpSalary)lsvEmpSalary.SelectedItems[0].Tag; } frm.ItemChanged = RefreshList; frm.ShowDlg(oEmpSalary); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void ShowDlg(EmpSalary oEmpSalary) { _EmpSalary = oEmpSalary; RefreshValue(); this.ShowDialog(); }