//Delete public void Delete(int Id) { OntimeDocReturn ontimeDocReturn = db.OntimeDocReturns.Find(Id); db.OntimeDocReturns.Remove(ontimeDocReturn); Save(); }
//Update public void Update(OntimeDocReturn ontimeDocReturn) { objDb.Update(ontimeDocReturn); }
//Insert public void Insert(OntimeDocReturn ontimeDocReturn) { objDb.Insert(ontimeDocReturn); }
//Update public void Update(OntimeDocReturn ontimeDocReturn) { objDb.Update(ontimeDocReturn); }
//Insert public void Insert(OntimeDocReturn ontimeDocReturn) { objDb.Insert(ontimeDocReturn); }
public ActionResult UpdateDocReturnApprove(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.docReturnAdjustedBs.GetByID(dn).SCGL_DOCRET_REASON_ID; bool isadjust = objBs.reasonDocReturnBs.GetByID(Convert.ToInt32(reasonId)).IsAdjust; DWH_ONTIME_DN ontimeDn = objBs.dWH_ONTIME_DNBs.GetByID(dn); ontimeDn.SCGL_DOCRET_ADJUST = isadjust ? 1 : 0; objBs.dWH_ONTIME_DNBs.Update(ontimeDn); //delete OntimedDelays objBs.docReturnAdjustedBs.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.ontimeDocReturnBs.GetAll() .Where(x => x.ActualGiDate == ONTIMEDate && x.DepartmentId == departmentId && x.SectionId == sectionId && x.MatFriGrp == matNameId).FirstOrDefault().Id; OntimeDocReturn ontimeDocReturn = objBs.ontimeDocReturnBs.GetByID(id); int adjOntime = ontimeDocReturn.AdjustDocReturn + 1; ontimeDocReturn.AdjustDocReturn = adjOntime; ontimeDocReturn.SumOfAdjustDocReturn = ontimeDocReturn.OnTime + adjOntime; objBs.ontimeDocReturnBs.Update(ontimeDocReturn); // update sum of adjust monthly int idM = objBs.ontimeDocReturnMonthBs.GetAll() .Where(x => x.Year == yearId && x.Month == monthId && x.DepartmentId == departmentId && x.SectionId == sectionId && x.MatFriGrp == matNameId).FirstOrDefault().Id; OntimeDocReturnMonth ontimeDocReturnMonth = objBs.ontimeDocReturnMonthBs.GetByID(idM); int adjOntimeMonth = ontimeDocReturnMonth.AdjustDocReturn + 1; ontimeDocReturnMonth.AdjustDocReturn = adjOntimeMonth; ontimeDocReturnMonth.SumOfAdjustDocReturn = ontimeDocReturnMonth.OnTime + adjOntimeMonth; objBs.ontimeDocReturnMonthBs.Update(ontimeDocReturnMonth); // update sum of adjust yearly int idY = objBs.ontimeDocReturnYearBs.GetAll() .Where(x => x.Year == yearId && x.DepartmentId == departmentId && x.SectionId == sectionId && x.MatFriGrp == matNameId).FirstOrDefault().Id; OntimeDocReturnYear ontimeDocReturnYear = objBs.ontimeDocReturnYearBs.GetByID(idY); int adjOntimeYear = ontimeDocReturnYear.AdjustDocReturn + 1; ontimeDocReturnYear.AdjustDocReturn = adjOntimeYear; ontimeDocReturnYear.SumOfAdjustDocReturn = ontimeDocReturnYear.OnTime + adjOntimeYear; objBs.ontimeDocReturnYearBs.Update(ontimeDocReturnYear); 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(OntimeDocReturn ontimeDocReturn) { db.Entry(ontimeDocReturn).State = EntityState.Modified; Save(); }
//Insert public void Insert(OntimeDocReturn ontimeDocReturn) { db.OntimeDocReturns.Add(ontimeDocReturn); Save(); }
//Update public void Update(OntimeDocReturn ontimeDocReturn) { db.Entry(ontimeDocReturn).State = EntityState.Modified; Save(); }
//Insert public void Insert(OntimeDocReturn ontimeDocReturn) { db.OntimeDocReturns.Add(ontimeDocReturn); Save(); }