public ActionResult DeleteConfirmed(int id) { Paysheet paysheet = db.Paysheets.Find(id); db.Paysheets.Remove(paysheet); db.SaveChanges(); return(RedirectToAction("Index")); }
public void PaymentPayroll(Paysheet paysheet) { using (var en = new DB_SystemFoodTrucksEntities()) { en.Paysheet.Add(paysheet); en.SaveChanges(); } }
public ActionResult Edit([Bind(Include = "Id,CustomerID,Chit_num,TruckLic_num,Job_num,DestinationID,Date_of_delivery,RateID,DriversID")] Paysheet paysheet) { if (ModelState.IsValid) { db.Entry(paysheet).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerID = new SelectList(db.Customers, "Id", "FirstName", paysheet.CustomerID); ViewBag.DestinationID = new SelectList(db.Destinations, "Id", "Name", paysheet.DestinationID); ViewBag.DriversID = new SelectList(db.Drivers, "Id", "FirstName", paysheet.DriversID); ViewBag.RateID = new SelectList(db.Rates, "Id", "Name", paysheet.RateID); return(View(paysheet)); }
// GET: Paysheets/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Paysheet paysheet = db.Paysheets.Find(id); if (paysheet == null) { return(HttpNotFound()); } return(View(paysheet)); }
public void PayrollWithLoan(Paysheet paysheet, Mov_CxC_Employees mov_CxC) { using (var en = new DB_SystemFoodTrucksEntities()) { using (DbContextTransaction transaction = en.Database.BeginTransaction()) { try { //var payment_bd = new Paysheet() //{ // Amount = paysheet.Amount, // Payment_date = paysheet.Payment_date, // Id_employee = paysheet.Id_employee, // Note = paysheet.Note //}; en.Paysheet.Add(paysheet); en.SaveChanges(); var updateloan_bd = en.Mov_CxC_Employees.First(m => m.Id_employee == mov_CxC.Id_employee && m.Transaction_type == 1); updateloan_bd.Amount_rest = mov_CxC.Amount_rest; updateloan_bd.FeeRest = mov_CxC.FeeRest; en.SaveChanges(); var payloan = new Mov_CxC_Employees() { Id_employee = mov_CxC.Id_employee, Amount_charged = mov_CxC.Amount_charged, Transaction_date = mov_CxC.Transaction_date, Transaction_type = mov_CxC.Transaction_type, Loan_Amount = 0, Fee_Amount = 0, Fee = 0, FeeRest = 0, Amount_rest = 0 }; en.Mov_CxC_Employees.Add(payloan); en.SaveChanges(); transaction.Commit(); } catch (Exception ex) { MessageBoxRM.Show(ex.Message); transaction.Rollback(); } } } }
// GET: Paysheets/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Paysheet paysheet = db.Paysheets.Find(id); if (paysheet == null) { return(HttpNotFound()); } ViewBag.CustomerID = new SelectList(db.Customers, "Id", "FirstName", paysheet.CustomerID); ViewBag.DestinationID = new SelectList(db.Destinations, "Id", "Name", paysheet.DestinationID); ViewBag.DriversID = new SelectList(db.Drivers, "Id", "FirstName", paysheet.DriversID); ViewBag.RateID = new SelectList(db.Rates, "Id", "Name", paysheet.RateID); return(View(paysheet)); }
private void btnPaidPaysheet_Click(object sender, RoutedEventArgs e) { var employee = new Employees(); var loan = new Mov_CxC_Employees(); int index = cboEmployee.SelectedIndex; employee = (Employees)cboEmployee.Items[index]; int desc = Convert.ToInt32(txtDesc.Text); loan = PaysheetBL.GetInstance().GetMov(employee.Id); string nota; if (string.IsNullOrEmpty(txtNota.Text)) { nota = "-"; } else { nota = txtNota.Text; } if (desc > 0) { var newPayment = new Paysheet() { Amount = Convert.ToInt32(txtSueldo.Text), Payment_date = DateTime.Now, Id_employee = employee.Id, Note = nota }; var updateLoan = new Mov_CxC_Employees() { Id_employee = employee.Id, Amount_charged = desc, Amount_rest = loan.Amount_rest - desc, FeeRest = loan.FeeRest - 1, Transaction_date = DateTime.Now, Transaction_type = 3 }; PaysheetBL.GetInstance().PayrollWithLoan(newPayment, updateLoan); MessageBoxRM.Show($"Pago nomina a {employee.Name} {employee.Last_name} aplicado.", "Pago nomina y cobro cuota de prestamo", MessageBoxButtonRM.OK, MessageBoxIconRM.Information); txtSueldo.Clear(); txtDesc.Clear(); txtMontoP.Clear(); txtNota.Clear(); cboEmployee.SelectedIndex = -1; } else { var newPayment = new Paysheet() { Amount = Convert.ToInt32(txtSueldo.Text), Payment_date = DateTime.Now, Id_employee = employee.Id, Note = nota }; PaysheetBL.GetInstance().PaymentPayroll(newPayment); MessageBoxRM.Show($"Pago nomina a {employee.Name} {employee.Last_name} aplicado.", "Pago nomina", MessageBoxButtonRM.OK, MessageBoxIconRM.Information); txtSueldo.Clear(); txtDesc.Clear(); txtMontoP.Clear(); txtNota.Clear(); cboEmployee.SelectedIndex = -1; } }