コード例 #1
0
        //Delete
        public void Delete(string SHPMNTNO)
        {
            DWH_ONTIME_SHIPMENT ontimeShipment = db.DWH_ONTIME_SHIPMENTs.Find(SHPMNTNO);

            db.DWH_ONTIME_SHIPMENTs.Remove(ontimeShipment);
            Save();
        }
コード例 #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();
            }
        }
コード例 #3
0
        public ContentResult UploadReason()
        {
            using (TransactionScope Trans = new TransactionScope())
            {
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    string errorRef = "";

                    string             reference  = Request.Files.AllKeys[i];
                    HttpPostedFileBase FileUpload = Request.Files[i]; //Uploaded file
                                                                      //Use the following properties to get file's name, size and MIMEType
                    string fileName   = reference;
                    string targetpath = Server.MapPath("~/Content/Docs/tnrd/");
                    FileUpload.SaveAs(targetpath + DateTime.Now.ToString("yyyyMMddHHmm", new CultureInfo("th-TH")) + "_adjust.xlsx");
                    string pathToExcelFile = targetpath + DateTime.Now.ToString("yyyyMMddHHmm", new CultureInfo("th-TH")) + "_adjust.xlsx";
                    var    ext             = Path.GetExtension(pathToExcelFile);

                    int countSM = 0;

                    //if (FileUpload.ContentType == "application/vnd.ms-excel" || FileUpload.ContentType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
                    if (ext == ".xlsx")
                    {
                        DataTable dT = ExcelModels.openExcel(pathToExcelFile, 1);
                        try
                        {
                            foreach (DataRow dr in dT.Rows)
                            {
                                //Do record adjust data - send to approval
                                if (!String.IsNullOrEmpty(dr[0].ToString()))
                                {
                                    string sm         = dr[0].ToString();
                                    int    reasonId   = Convert.ToInt32(dr[15].ToString());
                                    string remark     = dr[16].ToString();
                                    string reasonName = objBs.ReasonTenderedBs.GetByID(reasonId).Name;
                                    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           = 0;
                                    ontimeShipment.TNRD_ADJUST_BY        = User.Identity.Name;
                                    ontimeShipment.TNRD_ADJUST_DATE      = DateTime.Now;
                                    ontimeShipment.TNRD_ONTIME_REASON    = reasonName;
                                    ontimeShipment.TNRD_ONTIME_REASON_ID = Convert.ToInt32(reasonId);
                                    ontimeShipment.TNRD_ONTIME_REMARK    = remark;
                                    objBs.dWH_ONTIME_SHIPMENTBs.Update(ontimeShipment);

                                    TenderedDelay tmp_adjusted = objBs.tenderedDelayBs.GetByID(sm);
                                    if (tmp_adjusted == null)
                                    {
                                        errorRef = errorRef + sm + " , ";
                                    }
                                    else
                                    {
                                        TenderedAdjusted tmp_toInsert = new TenderedAdjusted
                                        {
                                            CARRIER_ID            = tmp_adjusted.CARRIER_ID,
                                            DEPARTMENT_ID         = tmp_adjusted.DEPARTMENT_ID,
                                            DEPARTMENT_NAME       = tmp_adjusted.DEPARTMENT_NAME,
                                            SECTION_ID            = tmp_adjusted.SECTION_ID,
                                            SECTION_NAME          = tmp_adjusted.SECTION_NAME,
                                            MATFRIGRP             = tmp_adjusted.MATFRIGRP,
                                            MATNAME               = tmp_adjusted.MATNAME,
                                            REGION_ID             = tmp_adjusted.REGION_ID,
                                            REGION_NAME_EN        = tmp_adjusted.REGION_NAME_EN,
                                            REGION_NAME_TH        = tmp_adjusted.REGION_NAME_TH,
                                            SOLDTO                = tmp_adjusted.SOLDTO,
                                            SOLDTO_NAME           = tmp_adjusted.SOLDTO_NAME,
                                            SHIPTO                = tmp_adjusted.SHIPTO,
                                            SEGMENT               = tmp_adjusted.SEGMENT,
                                            SUBSEGMENT            = tmp_adjusted.SUBSEGMENT,
                                            LAST_SHPG_LOC_NAME    = tmp_adjusted.LAST_SHPG_LOC_NAME,
                                            VENDOR_CODE           = tmp_adjusted.VENDOR_CODE,
                                            VENDOR_NAME           = tmp_adjusted.VENDOR_NAME,
                                            SHCRDATE              = tmp_adjusted.SHCRDATE,
                                            SHCRDATE_D            = tmp_adjusted.SHCRDATE_D,
                                            PLNTNRDDATE           = tmp_adjusted.PLNTNRDDATE,
                                            PLNTNRDDATE_D         = tmp_adjusted.PLNTNRDDATE_D,
                                            FTNRDDATE             = tmp_adjusted.FTNRDDATE,
                                            FTNRDDATE_D           = tmp_adjusted.FTNRDDATE_D,
                                            SHPPOINT              = tmp_adjusted.SHPPOINT,
                                            TRUCK_TYPE            = tmp_adjusted.TRUCK_TYPE,
                                            SHPMNTNO              = tmp_adjusted.SHPMNTNO,
                                            DELVNO                = tmp_adjusted.DELVNO,
                                            CRTD_USR_CD           = tmp_adjusted.CRTD_USR_CD,
                                            UPDT_USR_CD           = tmp_adjusted.UPDT_USR_CD,
                                            LOADED_DATE           = DateTime.Now,
                                            TNRD_ADJUST           = isadjust ? 1 : 0,
                                            TNRD_ADJUST_BY        = User.Identity.Name,
                                            TNRD_ADJUST_DATE      = DateTime.Now,
                                            TNRD_ONTIME_REASON    = reasonName,
                                            TNRD_ONTIME_REASON_ID = Convert.ToInt32(reasonId),
                                            TNRD_ONTIME_REMARK    = remark
                                        };
                                        //insert waiting ofr approval
                                        objBs.tenderedAdjustedBs.Insert(tmp_toInsert);
                                        //delete AcceptedDelays
                                        objBs.tenderedDelayBs.Delete(sm);

                                        countSM++;
                                    }
                                }
                            }
                            Trans.Complete();
                            if (errorRef != "")
                            {
                                errorRef = "<div style='overflow:auto'> Shipment หมายเลข " + errorRef + "ได้ทำการ adjust ไปแล้ว </div>";
                            }
                            return(Content("อัพโหลดสำเร็จ " + countSM + " Shipment" + "<br>" + errorRef));
                        }
                        catch (Exception e)
                        {
                            return(Content("อัพโหลดไม่สำเร็จ กรอกข้อมูลไม่ถูกต้อง"));
                        }
                    }
                    //deleting excel file from folder
                    if ((System.IO.File.Exists(pathToExcelFile)))
                    {
                        System.IO.File.Delete(pathToExcelFile);
                    }
                }
            }
            return(Content("อัพโหลดไม่สำเร็จ ประเภทไฟล์ไม่ถูกต้อง"));
        }
コード例 #4
0
        public ActionResult UpdateTenderReason(List <String> dynamic_select, List <string> txtSM, List <string> txtRemark)
        {
            using (TransactionScope Trans = new TransactionScope())
            {
                try
                {
                    // List<string> listSM = new List<string>();
                    int countSM = 0;
                    for (int i = 0; i < dynamic_select.Count; i++)
                    {
                        if (!String.IsNullOrEmpty(dynamic_select[i]))
                        {
                            string sm         = txtSM[i];
                            string reasonId   = dynamic_select[i];
                            string remark     = txtRemark[i];
                            string reasonName = objBs.ReasonTenderedBs.GetByID(Convert.ToInt32(reasonId)).Name;
                            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           = 0;
                            ontimeShipment.TNRD_ADJUST_BY        = User.Identity.Name;
                            ontimeShipment.TNRD_ADJUST_DATE      = DateTime.Now;
                            ontimeShipment.TNRD_ONTIME_REASON    = reasonName;
                            ontimeShipment.TNRD_ONTIME_REASON_ID = Convert.ToInt32(reasonId);
                            ontimeShipment.TNRD_ONTIME_REMARK    = remark;
                            objBs.dWH_ONTIME_SHIPMENTBs.Update(ontimeShipment);

                            TenderedDelay tmp_adjusted = objBs.tenderedDelayBs.GetByID(sm);
                            if (tmp_adjusted == null)
                            {
                                return(Json("shipment " + sm + " ได้ทำการ adjust ไปแล้ว"));
                            }
                            TenderedAdjusted tmp_toInsert = new TenderedAdjusted
                            {
                                CARRIER_ID            = tmp_adjusted.CARRIER_ID,
                                DEPARTMENT_ID         = tmp_adjusted.DEPARTMENT_ID,
                                DEPARTMENT_NAME       = tmp_adjusted.DEPARTMENT_NAME,
                                SECTION_ID            = tmp_adjusted.SECTION_ID,
                                SECTION_NAME          = tmp_adjusted.SECTION_NAME,
                                MATFRIGRP             = tmp_adjusted.MATFRIGRP,
                                MATNAME               = tmp_adjusted.MATNAME,
                                REGION_ID             = tmp_adjusted.REGION_ID,
                                REGION_NAME_EN        = tmp_adjusted.REGION_NAME_EN,
                                REGION_NAME_TH        = tmp_adjusted.REGION_NAME_TH,
                                SOLDTO                = tmp_adjusted.SOLDTO,
                                SOLDTO_NAME           = tmp_adjusted.SOLDTO_NAME,
                                SHIPTO                = tmp_adjusted.SHIPTO,
                                SEGMENT               = tmp_adjusted.SEGMENT,
                                SUBSEGMENT            = tmp_adjusted.SUBSEGMENT,
                                LAST_SHPG_LOC_NAME    = tmp_adjusted.LAST_SHPG_LOC_NAME,
                                VENDOR_CODE           = tmp_adjusted.VENDOR_CODE,
                                VENDOR_NAME           = tmp_adjusted.VENDOR_NAME,
                                SHCRDATE              = tmp_adjusted.SHCRDATE,
                                SHCRDATE_D            = tmp_adjusted.SHCRDATE_D,
                                PLNTNRDDATE           = tmp_adjusted.PLNTNRDDATE,
                                PLNTNRDDATE_D         = tmp_adjusted.PLNTNRDDATE_D,
                                FTNRDDATE             = tmp_adjusted.FTNRDDATE,
                                FTNRDDATE_D           = tmp_adjusted.FTNRDDATE_D,
                                SHPPOINT              = tmp_adjusted.SHPPOINT,
                                TRUCK_TYPE            = tmp_adjusted.TRUCK_TYPE,
                                SHPMNTNO              = tmp_adjusted.SHPMNTNO,
                                DELVNO                = tmp_adjusted.DELVNO,
                                CRTD_USR_CD           = tmp_adjusted.CRTD_USR_CD,
                                UPDT_USR_CD           = tmp_adjusted.UPDT_USR_CD,
                                LOADED_DATE           = DateTime.Now,
                                TNRD_ADJUST           = isadjust ? 1 : 0,
                                TNRD_ADJUST_BY        = User.Identity.Name,
                                TNRD_ADJUST_DATE      = DateTime.Now,
                                TNRD_ONTIME_REASON    = reasonName,
                                TNRD_ONTIME_REASON_ID = Convert.ToInt32(reasonId),
                                TNRD_ONTIME_REMARK    = remark
                            };
                            //insert waiting ofr approval
                            objBs.tenderedAdjustedBs.Insert(tmp_toInsert);
                            //delete AcceptedDelays
                            objBs.tenderedDelayBs.Delete(sm);

                            countSM++;
                        }
                    }

                    Trans.Complete();
                    return(RedirectToAction("Index", new { sms = countSM + "-Shipment is adjusted Successfully!" }));
                }
                catch (Exception ex)
                {
                    return(RedirectToAction("Index", new { sms = "Operation update reason accepted failed !" + ex.ToString() }));
                }
                //  return View();
            }
        }
コード例 #5
0
 //Update
 public void Update(DWH_ONTIME_SHIPMENT DWH_ONTIME_SHIPMENT)
 {
     db.Entry(DWH_ONTIME_SHIPMENT).State = EntityState.Modified;
     Save();
 }
コード例 #6
0
 //Insert
 public void Insert(DWH_ONTIME_SHIPMENT DWH_ONTIME_SHIPMENT)
 {
     db.DWH_ONTIME_SHIPMENTs.Add(DWH_ONTIME_SHIPMENT);
     Save();
 }
コード例 #7
0
 //Insert
 public void Insert(DWH_ONTIME_SHIPMENT DWH_ONTIME_SHIPMENT)
 {
     objDb.Insert(DWH_ONTIME_SHIPMENT);
 }
コード例 #8
0
 //Update
 public void Update(DWH_ONTIME_SHIPMENT DWH_ONTIME_SHIPMENT)
 {
     objDb.Update(DWH_ONTIME_SHIPMENT);
 }