//Delete public void Delete(int Id) { OntimeTenderMonth ontimeTenderMonth = db.OntimeTenderMonths.Find(Id); db.OntimeTenderMonths.Remove(ontimeTenderMonth); Save(); }
public ActionResult UpdateTenderApprove(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.tenderedAdjustedBs.GetByID(sm).TNRD_ONTIME_REASON_ID; bool isadjust = objBs.ReasonTenderedBs.GetByID(Convert.ToInt32(reasonId)).IsAdjust; DWH_ONTIME_SHIPMENT ontimeShipment = objBs.dWH_ONTIME_SHIPMENTBs.GetByID(sm); //Change adjustable here ontimeShipment.TNRD_ADJUST = isadjust ? 1 : 0; objBs.dWH_ONTIME_SHIPMENTBs.Update(ontimeShipment); //delete TenderedDelays objBs.tenderedAdjustedBs.Delete(sm); //update sum of adjust daily DateTime FTNRDDate = Convert.ToDateTime(ontimeShipment.FTNRDDATE_D); string matName = ontimeShipment.MATFRIGRP; string segmentId = ontimeShipment.DATA_SUBGRP; string sectionId = ontimeShipment.SECTION_ID; string departmentId = ontimeShipment.DEPARTMENT_ID; string UserId = ontimeShipment.CRTD_USR_CD; string UpdateUserId = ontimeShipment.UPDT_USR_CD; if (isadjust) { int id = objBs.ontimeTenderBs.GetAll() .Where(x => x.ActualGiDate == FTNRDDate && x.MatFriGrp == matName && x.SubSegment == segmentId && x.SectionId == sectionId && x.CRTD_USR_CD == UserId && x.UPDT_USR_CD == UpdateUserId && x.DepartmentId == departmentId).FirstOrDefault().Id; OntimeTender ontimeTender = objBs.ontimeTenderBs.GetByID(id); int adjTNRD = ontimeTender.AdjustTender + 1; ontimeTender.AdjustTender = adjTNRD; ontimeTender.SumOfAdjustTender = ontimeTender.OnTime + adjTNRD; objBs.ontimeTenderBs.Update(ontimeTender); // update sum of adjust monthly int idM = objBs.ontimeTenderMonthBs.GetAll() .Where(x => x.Year == yearId && x.MatFriGrp == matName && x.Month == monthId && x.SubSegment == segmentId && x.SectionId == sectionId && x.CRTD_USR_CD == UserId && x.UPDT_USR_CD == UpdateUserId && x.DepartmentId == departmentId).FirstOrDefault().Id; OntimeTenderMonth ontimeTenderMonth = objBs.ontimeTenderMonthBs.GetByID(idM); int adjTNRDMonth = ontimeTenderMonth.AdjustTender + 1; ontimeTenderMonth.AdjustTender = adjTNRDMonth; ontimeTenderMonth.SumOfAdjustTender = ontimeTenderMonth.OnTime + adjTNRDMonth; objBs.ontimeTenderMonthBs.Update(ontimeTenderMonth); // update sum of adjust yearly int idY = objBs.ontimeTenderYearBs.GetAll() .Where(x => x.Year == yearId && x.MatFriGrp == matName && x.SubSegment == segmentId && x.SectionId == sectionId && x.CRTD_USR_CD == UserId && x.UPDT_USR_CD == UpdateUserId && x.DepartmentId == departmentId).FirstOrDefault().Id; OntimeTenderYear ontimeTenderYear = objBs.ontimeTenderYearBs.GetByID(idY); int adjTNRDYear = ontimeTenderYear.AdjustTender + 1; ontimeTenderYear.AdjustTender = adjTNRDYear; ontimeTenderYear.SumOfAdjustTender = ontimeTenderYear.OnTime + adjTNRDYear; objBs.ontimeTenderYearBs.Update(ontimeTenderYear); } 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(OntimeTenderMonth ontimeTenderMonth) { objDb.Update(ontimeTenderMonth); }
//Insert public void Insert(OntimeTenderMonth ontimeTenderMonth) { objDb.Insert(ontimeTenderMonth); }
//Update public void Update(OntimeTenderMonth ontimeTenderMonth) { db.Entry(ontimeTenderMonth).State = EntityState.Modified; Save(); }
//Insert public void Insert(OntimeTenderMonth ontimeTenderMonth) { db.OntimeTenderMonths.Add(ontimeTenderMonth); Save(); }