//Delete public void Delete(int Id) { OntimeAcceptMonth ontimeAcceptMonth = db.OntimeAcceptMonths.Find(Id); db.OntimeAcceptMonths.Remove(ontimeAcceptMonth); Save(); }
//Update public void Update(OntimeAcceptMonth ontimeAcceptMonth) { objDb.Update(ontimeAcceptMonth); }
//Insert public void Insert(OntimeAcceptMonth ontimeAcceptMonth) { objDb.Insert(ontimeAcceptMonth); }
public ActionResult UpdateAcceptApprove(List <string> thisReasonId, List <string> txtSM, List <string> txtApprove, List <string> txtRemark, string yearId, string monthId) { using (TransactionScope Trans = new TransactionScope()) { try { // List<string> listSM = new List<string>(); int countSM = 0; List <string> SMs = new List <string>(txtApprove.Distinct()); foreach (string sm in SMs) { var reasonId = objBs.acceptedAdjustedBs.GetByID(sm).ACPD_REASON_ID; bool isadjust = objBs.reasonAcceptedBs.GetByID(Convert.ToInt32(reasonId)).IsAdjust; DWH_ONTIME_SHIPMENT ontimeShipment = objBs.dWH_ONTIME_SHIPMENTBs.GetByID(sm); //Change adjustable here ontimeShipment.ACPD_ADJUST = isadjust ? 1 : 0; objBs.dWH_ONTIME_SHIPMENTBs.Update(ontimeShipment); //delete AcceptedDelays objBs.acceptedAdjustedBs.Delete(sm); //update sum of adjust daily DateTime LACPDDate = Convert.ToDateTime(ontimeShipment.LACPDDATE_D); string matNameId = Convert.ToString(ontimeShipment.MATFRIGRP); string sectionId = Convert.ToString(ontimeShipment.SECTION_ID); string departmentId = Convert.ToString(ontimeShipment.DEPARTMENT_ID); if (isadjust) { int id = objBs.ontimeAcceptBs.GetAll() .Where(x => x.ActualGiDate == LACPDDate && x.DepartmentId == departmentId && x.SectionId == sectionId && x.MatFriGrp == matNameId).FirstOrDefault().Id; OntimeAccept ontimeAccept = objBs.ontimeAcceptBs.GetByID(id); int adjACPD = ontimeAccept.AdjustAccept + 1; ontimeAccept.AdjustAccept = adjACPD; ontimeAccept.SumOfAdjustAccept = ontimeAccept.OnTime + adjACPD; objBs.ontimeAcceptBs.Update(ontimeAccept); // update sum of adjust monthly int idM = objBs.ontimeAcceptMonthBs.GetAll() .Where(x => x.Year == yearId && x.Month == monthId && x.DepartmentId == departmentId && x.SectionId == sectionId && x.MatFriGrp == matNameId).FirstOrDefault().Id; OntimeAcceptMonth ontimeAcceptMonth = objBs.ontimeAcceptMonthBs.GetByID(idM); int adjACPDMonth = ontimeAcceptMonth.AdjustAccept + 1; ontimeAcceptMonth.AdjustAccept = adjACPDMonth; ontimeAcceptMonth.SumOfAdjustAccept = ontimeAcceptMonth.OnTime + adjACPDMonth; objBs.ontimeAcceptMonthBs.Update(ontimeAcceptMonth); // update sum of adjust yearly int idY = objBs.ontimeAcceptYearBs.GetAll() .Where(x => x.Year == yearId && x.DepartmentId == departmentId && x.SectionId == sectionId && x.MatFriGrp == matNameId).FirstOrDefault().Id; OntimeAcceptYear ontimeAcceptYear = objBs.ontimeAcceptYearBs.GetByID(idY); int adjACPDYear = ontimeAcceptYear.AdjustAccept + 1; ontimeAcceptYear.AdjustAccept = adjACPDYear; ontimeAcceptYear.SumOfAdjustAccept = ontimeAcceptYear.OnTime + adjACPDYear; objBs.ontimeAcceptYearBs.Update(ontimeAcceptYear); } countSM++; } Trans.Complete(); return(Content(countSM + " - Shipment is adjusted Successfully!")); } catch (Exception ex) { return(Content("Operation update reason ontimed failed !" + ex.ToString())); } // return View(); } }
//Update public void Update(OntimeAcceptMonth ontimeAcceptMonth) { db.Entry(ontimeAcceptMonth).State = EntityState.Modified; Save(); }
//Insert public void Insert(OntimeAcceptMonth ontimeAcceptMonth) { db.OntimeAcceptMonths.Add(ontimeAcceptMonth); Save(); }