//Delete public void Delete(int Id) { OntimeOutbound ontimeOutbound = db.OntimeOutbounds.Find(Id); db.OntimeOutbounds.Remove(ontimeOutbound); Save(); }
public ActionResult UpdateOutboundApprove(List <string> thisReasonId, List <string> txtDN, List <string> txtApprove, List <string> txtRemark, string yearId, string monthId) { using (TransactionScope Trans = new TransactionScope()) { try { // List<string> listSM = new List<string>(); int countDN = 0; List <string> DNs = new List <string>(txtApprove.Distinct()); foreach (string dn in DNs) { var reasonId = objBs.outboundAdjustedBs.GetByID(dn).OUTB_REASON_ID; bool isadjust = objBs.reasonOutboundBs.GetByID(Convert.ToInt32(reasonId)).IsAdjust; DWH_ONTIME_DN ontimeDn = objBs.dWH_ONTIME_DNBs.GetByID(dn); ontimeDn.OUTB_ADJUST = isadjust ? 1 : 0; objBs.dWH_ONTIME_DNBs.Update(ontimeDn); //delete OutboundedDelays objBs.outboundAdjustedBs.Delete(dn); //update sum of adjust daily DateTime ONTIMEDate = Convert.ToDateTime(ontimeDn.ACTGIDATE_D); string matNameId = Convert.ToString(ontimeDn.MATFRIGRP); string sectionId = Convert.ToString(ontimeDn.SECTION_ID); string departmentId = Convert.ToString(ontimeDn.DEPARTMENT_ID); if (isadjust) { int id = objBs.ontimeOutboundBs.GetAll() .Where(x => x.ActualGiDate == ONTIMEDate && x.DepartmentId == departmentId && x.SectionId == sectionId && x.MatFriGrp == matNameId).FirstOrDefault().Id; OntimeOutbound ontimeOutbound = objBs.ontimeOutboundBs.GetByID(id); int adjOntime = ontimeOutbound.AdjustOutbound + 1; ontimeOutbound.AdjustOutbound = adjOntime; ontimeOutbound.SumOfAdjustOutbound = ontimeOutbound.OnTime + adjOntime; objBs.ontimeOutboundBs.Update(ontimeOutbound); // update sum of adjust monthly int idM = objBs.ontimeOutboundMonthBs.GetAll() .Where(x => x.Year == yearId && x.Month == monthId && x.DepartmentId == departmentId && x.SectionId == sectionId && x.MatFriGrp == matNameId).FirstOrDefault().Id; OntimeOutboundMonth ontimeOutboundMonth = objBs.ontimeOutboundMonthBs.GetByID(idM); int adjOutboundMonth = ontimeOutboundMonth.AdjustOutbound + 1; ontimeOutboundMonth.AdjustOutbound = adjOutboundMonth; ontimeOutboundMonth.SumOfAdjustOutbound = ontimeOutboundMonth.OnTime + adjOutboundMonth; objBs.ontimeOutboundMonthBs.Update(ontimeOutboundMonth); // update sum of adjust yearly int idY = objBs.ontimeOutboundYearBs.GetAll() .Where(x => x.Year == yearId && x.DepartmentId == departmentId && x.SectionId == sectionId && x.MatFriGrp == matNameId).FirstOrDefault().Id; OntimeOutboundYear ontimeOutboundYear = objBs.ontimeOutboundYearBs.GetByID(idY); int adjOutboundYear = ontimeOutboundYear.AdjustOutbound + 1; ontimeOutboundYear.AdjustOutbound = adjOutboundYear; ontimeOutboundYear.SumOfAdjustOutbound = ontimeOutboundYear.OnTime + adjOutboundYear; objBs.ontimeOutboundYearBs.Update(ontimeOutboundYear); countDN++; } } Trans.Complete(); return(Content(countDN + " - Delivery note is adjusted Successfully!")); } catch (Exception ex) { return(Content("Operation update reason ontimed failed !" + ex.ToString())); } // return View(); } }
//Update public void Update(OntimeOutbound ontimeOutbound) { db.Entry(ontimeOutbound).State = EntityState.Modified; Save(); }
//Insert public void Insert(OntimeOutbound ontimeOutbound) { db.OntimeOutbounds.Add(ontimeOutbound); Save(); }
//Update public void Update(OntimeOutbound ontimeOutbound) { objDb.Update(ontimeOutbound); }
//Insert public void Insert(OntimeOutbound ontimeOutbound) { objDb.Insert(ontimeOutbound); }