Exemplo n.º 1
0
        //Delete
        public void Delete(int Id)
        {
            OntimeOutboundYear ontimeOutboundYear = db.OntimeOutboundYears.Find(Id);

            db.OntimeOutboundYears.Remove(ontimeOutboundYear);
            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();
            }
        }
Exemplo n.º 3
0
 //Update
 public void Update(OntimeOutboundYear ontimeOutboundYear)
 {
     objDb.Update(ontimeOutboundYear);
 }
Exemplo n.º 4
0
 //Insert
 public void Insert(OntimeOutboundYear ontimeOutboundYear)
 {
     objDb.Insert(ontimeOutboundYear);
 }
Exemplo n.º 5
0
 //Update
 public void Update(OntimeOutboundYear ontimeOutboundYear)
 {
     objDb.Update(ontimeOutboundYear);
 }
Exemplo n.º 6
0
 //Insert
 public void Insert(OntimeOutboundYear ontimeOutboundYear)
 {
     objDb.Insert(ontimeOutboundYear);
 }
Exemplo n.º 7
0
 //Update
 public void Update(OntimeOutboundYear ontimeOutboundYear)
 {
     db.Entry(ontimeOutboundYear).State = EntityState.Modified;
     Save();
 }
Exemplo n.º 8
0
 //Insert
 public void Insert(OntimeOutboundYear ontimeOutboundYear)
 {
     db.OntimeOutboundYears.Add(ontimeOutboundYear);
     Save();
 }