Exemplo n.º 1
0
        //Delete
        public void Delete(int Id)
        {
            OntimeTenderYear ontimeTenderYear = db.OntimeTenderYears.Find(Id);

            db.OntimeTenderYears.Remove(ontimeTenderYear);
            Save();
        }
Exemplo n.º 2
0
        public ActionResult UpdateTenderApprove(List <string> thisReasonId, List <string> txtSM, List <string> txtApprove, List <string> txtRemark, string yearId, string monthId)
        {
            using (TransactionScope Trans = new TransactionScope())
            {
                try
                {
                    // List<string> listSM = new List<string>();
                    int           countSM = 0;
                    List <string> SMs     = new List <string>(txtApprove.Distinct());
                    foreach (string sm in SMs)
                    {
                        var  reasonId = objBs.tenderedAdjustedBs.GetByID(sm).TNRD_ONTIME_REASON_ID;
                        bool isadjust = objBs.ReasonTenderedBs.GetByID(Convert.ToInt32(reasonId)).IsAdjust;
                        DWH_ONTIME_SHIPMENT ontimeShipment = objBs.dWH_ONTIME_SHIPMENTBs.GetByID(sm);
                        //Change adjustable here
                        ontimeShipment.TNRD_ADJUST = isadjust ? 1 : 0;
                        objBs.dWH_ONTIME_SHIPMENTBs.Update(ontimeShipment);

                        //delete TenderedDelays
                        objBs.tenderedAdjustedBs.Delete(sm);

                        //update sum of adjust daily
                        DateTime FTNRDDate    = Convert.ToDateTime(ontimeShipment.FTNRDDATE_D);
                        string   matName      = ontimeShipment.MATFRIGRP;
                        string   segmentId    = ontimeShipment.DATA_SUBGRP;
                        string   sectionId    = ontimeShipment.SECTION_ID;
                        string   departmentId = ontimeShipment.DEPARTMENT_ID;
                        string   UserId       = ontimeShipment.CRTD_USR_CD;
                        string   UpdateUserId = ontimeShipment.UPDT_USR_CD;

                        if (isadjust)
                        {
                            int id = objBs.ontimeTenderBs.GetAll()
                                     .Where(x => x.ActualGiDate == FTNRDDate &&
                                            x.MatFriGrp == matName &&
                                            x.SubSegment == segmentId &&
                                            x.SectionId == sectionId &&
                                            x.CRTD_USR_CD == UserId &&
                                            x.UPDT_USR_CD == UpdateUserId &&
                                            x.DepartmentId == departmentId).FirstOrDefault().Id;
                            OntimeTender ontimeTender = objBs.ontimeTenderBs.GetByID(id);
                            int          adjTNRD      = ontimeTender.AdjustTender + 1;
                            ontimeTender.AdjustTender      = adjTNRD;
                            ontimeTender.SumOfAdjustTender = ontimeTender.OnTime + adjTNRD;
                            objBs.ontimeTenderBs.Update(ontimeTender);

                            // update sum of adjust monthly
                            int idM = objBs.ontimeTenderMonthBs.GetAll()
                                      .Where(x => x.Year == yearId &&
                                             x.MatFriGrp == matName &&
                                             x.Month == monthId &&
                                             x.SubSegment == segmentId &&
                                             x.SectionId == sectionId &&
                                             x.CRTD_USR_CD == UserId &&
                                             x.UPDT_USR_CD == UpdateUserId &&
                                             x.DepartmentId == departmentId).FirstOrDefault().Id;
                            OntimeTenderMonth ontimeTenderMonth = objBs.ontimeTenderMonthBs.GetByID(idM);
                            int adjTNRDMonth = ontimeTenderMonth.AdjustTender + 1;
                            ontimeTenderMonth.AdjustTender      = adjTNRDMonth;
                            ontimeTenderMonth.SumOfAdjustTender = ontimeTenderMonth.OnTime + adjTNRDMonth;
                            objBs.ontimeTenderMonthBs.Update(ontimeTenderMonth);

                            // update sum of adjust yearly
                            int idY = objBs.ontimeTenderYearBs.GetAll()
                                      .Where(x => x.Year == yearId &&
                                             x.MatFriGrp == matName &&
                                             x.SubSegment == segmentId &&
                                             x.SectionId == sectionId &&
                                             x.CRTD_USR_CD == UserId &&
                                             x.UPDT_USR_CD == UpdateUserId &&
                                             x.DepartmentId == departmentId).FirstOrDefault().Id;
                            OntimeTenderYear ontimeTenderYear = objBs.ontimeTenderYearBs.GetByID(idY);
                            int adjTNRDYear = ontimeTenderYear.AdjustTender + 1;
                            ontimeTenderYear.AdjustTender      = adjTNRDYear;
                            ontimeTenderYear.SumOfAdjustTender = ontimeTenderYear.OnTime + adjTNRDYear;
                            objBs.ontimeTenderYearBs.Update(ontimeTenderYear);
                        }
                        countSM++;
                    }

                    Trans.Complete();
                    return(Content(countSM + " - Shipment 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(OntimeTenderYear ontimeTenderYear)
 {
     objDb.Update(ontimeTenderYear);
 }
Exemplo n.º 4
0
 //Insert
 public void Insert(OntimeTenderYear ontimeTenderYear)
 {
     objDb.Insert(ontimeTenderYear);
 }
Exemplo n.º 5
0
 //Update
 public void Update(OntimeTenderYear ontimeTenderYear)
 {
     db.Entry(ontimeTenderYear).State = EntityState.Modified;
     Save();
 }
Exemplo n.º 6
0
 //Insert
 public void Insert(OntimeTenderYear ontimeTenderYear)
 {
     db.OntimeTenderYears.Add(ontimeTenderYear);
     Save();
 }