//Delete public void Delete(int Id) { OntimeInboundYear ontimeInboundYear = db.OntimeInboundYears.Find(Id); db.OntimeInboundYears.Remove(ontimeInboundYear); Save(); }
//Update public void Update(OntimeInboundYear ontimeInboundYear) { objDb.Update(ontimeInboundYear); }
//Insert public void Insert(OntimeInboundYear ontimeInboundYear) { objDb.Insert(ontimeInboundYear); }
//Update public void Update(OntimeInboundYear ontimeInboundYear) { db.Entry(ontimeInboundYear).State = EntityState.Modified; Save(); }
//Insert public void Insert(OntimeInboundYear ontimeInboundYear) { db.OntimeInboundYears.Add(ontimeInboundYear); Save(); }
public ActionResult UpdateInboundApprove(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.inboundAdjustedBs.GetByID(dn).INB_REASON_ID; bool isadjust = objBs.reasonInboundBs.GetByID(Convert.ToInt32(reasonId)).IsAdjust; DWH_ONTIME_DN ontimeDn = objBs.dWH_ONTIME_DNBs.GetByID(dn); ontimeDn.INB_ADJUST = isadjust ? 1 : 0; objBs.dWH_ONTIME_DNBs.Update(ontimeDn); //delete InboundedDelays objBs.inboundAdjustedBs.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.ontimeInboundBs.GetAll() .Where(x => x.ActualGiDate == ONTIMEDate && x.DepartmentId == departmentId && x.SectionId == sectionId && x.MatFriGrp == matNameId).FirstOrDefault().Id; OntimeInbound ontimeInbound = objBs.ontimeInboundBs.GetByID(id); int adjOntime = ontimeInbound.AdjustInbound + 1; ontimeInbound.AdjustInbound = adjOntime; ontimeInbound.SumOfAdjustInbound = ontimeInbound.OnTime + adjOntime; objBs.ontimeInboundBs.Update(ontimeInbound); // update sum of adjust monthly int idM = objBs.ontimeInboundMonthBs.GetAll() .Where(x => x.Year == yearId && x.Month == monthId && x.DepartmentId == departmentId && x.SectionId == sectionId && x.MatFriGrp == matNameId).FirstOrDefault().Id; OntimeInboundMonth ontimeInboundMonth = objBs.ontimeInboundMonthBs.GetByID(idM); int adjInboundMonth = ontimeInboundMonth.AdjustInbound + 1; ontimeInboundMonth.AdjustInbound = adjInboundMonth; ontimeInboundMonth.SumOfAdjustInbound = ontimeInboundMonth.OnTime + adjInboundMonth; objBs.ontimeInboundMonthBs.Update(ontimeInboundMonth); // update sum of adjust yearly int idY = objBs.ontimeInboundYearBs.GetAll() .Where(x => x.Year == yearId && x.DepartmentId == departmentId && x.SectionId == sectionId && x.MatFriGrp == matNameId).FirstOrDefault().Id; OntimeInboundYear ontimeInboundYear = objBs.ontimeInboundYearBs.GetByID(idY); int adjInboundYear = ontimeInboundYear.AdjustInbound + 1; ontimeInboundYear.AdjustInbound = adjInboundYear; ontimeInboundYear.SumOfAdjustInbound = ontimeInboundYear.OnTime + adjInboundYear; objBs.ontimeInboundYearBs.Update(ontimeInboundYear); 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(); } }