Ejemplo n.º 1
0
        //Delete
        public void Delete(int Id)
        {
            OntimeDocReturnMonth ontimeDocReturnMonth = db.OntimeDocReturnMonths.Find(Id);

            db.OntimeDocReturnMonths.Remove(ontimeDocReturnMonth);
            Save();
        }
Ejemplo n.º 2
0
        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();
            }
        }
Ejemplo n.º 3
0
 //Update
 public void Update(OntimeDocReturnMonth ontimeDocReturnMonth)
 {
     db.Entry(ontimeDocReturnMonth).State = EntityState.Modified;
     Save();
 }
Ejemplo n.º 4
0
 //Insert
 public void Insert(OntimeDocReturnMonth ontimeDocReturnMonth)
 {
     db.OntimeDocReturnMonths.Add(ontimeDocReturnMonth);
     Save();
 }
Ejemplo n.º 5
0
 //Update
 public void Update(OntimeDocReturnMonth ontimeDocReturnMonth)
 {
     objDb.Update(ontimeDocReturnMonth);
 }
Ejemplo n.º 6
0
 //Insert
 public void Insert(OntimeDocReturnMonth ontimeDocReturnMonth)
 {
     objDb.Insert(ontimeDocReturnMonth);
 }