示例#1
0
        //Delete
        public void Delete(int Id)
        {
            OntimeDeliveryMonth ontimeDeliveryMonth = db.OntimeDeliveryMonths.Find(Id);

            db.OntimeDeliveryMonths.Remove(ontimeDeliveryMonth);
            Save();
        }
        public ActionResult UpdateOntimeApprove(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.ontimeAdjustedBs.GetByID(dn).ON_TIME_REASON_ID;
                        bool          isadjust = objBs.reasonOntimeBs.GetByID(Convert.ToInt32(reasonId)).IsAdjust;
                        DWH_ONTIME_DN ontimeDn = objBs.dWH_ONTIME_DNBs.GetByID(dn);
                        ontimeDn.ON_TIME_ADJUST = isadjust ? 1 : 0;

                        objBs.dWH_ONTIME_DNBs.Update(ontimeDn);

                        //delete OntimedDelays
                        objBs.ontimeAdjustedBs.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.ontimeDeliveryBs.GetAll()
                                     .Where(x => x.ActualGiDate == ONTIMEDate &&
                                            x.DepartmentId == departmentId &&
                                            x.SectionId == sectionId &&
                                            x.MatFriGrp == matNameId).FirstOrDefault().Id;

                            OntimeDelivery ontimeDelivery = objBs.ontimeDeliveryBs.GetByID(id);

                            int adjOntime = ontimeDelivery.AdjustDelivery + 1;
                            ontimeDelivery.AdjustDelivery      = adjOntime;
                            ontimeDelivery.SumOfAdjustDelivery = ontimeDelivery.OnTime + adjOntime;
                            objBs.ontimeDeliveryBs.Update(ontimeDelivery);

                            // update sum of adjust monthly
                            int idM = objBs.ontimeDeliveryMonthBs.GetAll()
                                      .Where(x => x.Year == yearId &&
                                             x.Month == monthId &&
                                             x.DepartmentId == departmentId &&
                                             x.SectionId == sectionId &&
                                             x.MatFriGrp == matNameId).FirstOrDefault().Id;

                            OntimeDeliveryMonth ontimeDeliveryMonth = objBs.ontimeDeliveryMonthBs.GetByID(idM);

                            int adjOntimeMonth = ontimeDeliveryMonth.AdjustDelivery + 1;
                            ontimeDeliveryMonth.AdjustDelivery      = adjOntimeMonth;
                            ontimeDeliveryMonth.SumOfAdjustDelivery = ontimeDeliveryMonth.OnTime + adjOntimeMonth;
                            objBs.ontimeDeliveryMonthBs.Update(ontimeDeliveryMonth);

                            // update sum of adjust yearly
                            int idY = objBs.ontimeDeliveryYearBs.GetAll()
                                      .Where(x => x.Year == yearId &&
                                             x.DepartmentId == departmentId &&
                                             x.SectionId == sectionId &&
                                             x.MatFriGrp == matNameId).FirstOrDefault().Id;

                            OntimeDeliveryYear ontimeDeliveryYear = objBs.ontimeDeliveryYearBs.GetByID(idY);

                            int adjOntimeYear = ontimeDeliveryYear.AdjustDelivery + 1;
                            ontimeDeliveryYear.AdjustDelivery      = adjOntimeYear;
                            ontimeDeliveryYear.SumOfAdjustDelivery = ontimeDeliveryYear.OnTime + adjOntimeYear;
                            objBs.ontimeDeliveryYearBs.Update(ontimeDeliveryYear);

                            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();
            }
        }
示例#3
0
 //Update
 public void Update(OntimeDeliveryMonth ontimeDeliveryMonth)
 {
     objDb.Update(ontimeDeliveryMonth);
 }
示例#4
0
 //Insert
 public void Insert(OntimeDeliveryMonth ontimeDeliveryMonth)
 {
     objDb.Insert(ontimeDeliveryMonth);
 }
示例#5
0
 //Update
 public void Update(OntimeDeliveryMonth ontimeDeliveryMonth)
 {
     db.Entry(ontimeDeliveryMonth).State = EntityState.Modified;
     Save();
 }
示例#6
0
 //Insert
 public void Insert(OntimeDeliveryMonth ontimeDeliveryMonth)
 {
     db.OntimeDeliveryMonths.Add(ontimeDeliveryMonth);
     Save();
 }