Exemplo n.º 1
0
        //Delete
        public void Delete(string shipmentNo)
        {
            AcceptedAdjusted acceptedAdjusted = db.AcceptedAdjusted.Find(shipmentNo);

            db.AcceptedAdjusted.Remove(acceptedAdjusted);
            Save();
        }
Exemplo n.º 2
0
 //Update
 public void Update(AcceptedAdjusted acceptedAdjusted)
 {
     objDb.Update(acceptedAdjusted);
 }
Exemplo n.º 3
0
 //Insert
 public void Insert(AcceptedAdjusted acceptedAdjusted)
 {
     objDb.Insert(acceptedAdjusted);
 }
Exemplo n.º 4
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/acpd/");
                    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.reasonAcceptedBs.GetByID(reasonId).Name;
                                    bool isadjust = objBs.reasonAcceptedBs.GetByID(Convert.ToInt32(reasonId)).IsAdjust;
                                    DWH_ONTIME_SHIPMENT ontimeShipment = objBs.dWH_ONTIME_SHIPMENTBs.GetByID(sm);
                                    //Change adjustable here
                                    ontimeShipment.ACPD_ADJUST = 0;
                                    ontimeShipment.ACPD_ADJUST_BY = User.Identity.Name;
                                    ontimeShipment.ACPD_ADJUST_DATE = DateTime.Now;
                                    ontimeShipment.ACPD_REASON = reasonName;
                                    ontimeShipment.ACPD_REASON_ID = Convert.ToInt32(reasonId);
                                    ontimeShipment.ACPD_REMARK = remark;
                                    objBs.dWH_ONTIME_SHIPMENTBs.Update(ontimeShipment);

                                    AcceptedDelay tmp_adjusted = objBs.acceptedDelayBs.GetByID(sm);
                                    if (tmp_adjusted == null)
                                    {
                                        errorRef = errorRef + sm + " , ";
                                    }
                                    else
                                    {
                                        AcceptedAdjusted tmp_toInsert = new AcceptedAdjusted
                                        {
                                            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,
                                            SEGMENT = tmp_adjusted.SEGMENT,
                                            SUBSEGMENT = tmp_adjusted.SUBSEGMENT,
                                            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,
                                            LAST_SHPG_LOC_NAME = tmp_adjusted.LAST_SHPG_LOC_NAME,
                                            VENDOR_CODE = tmp_adjusted.VENDOR_CODE,
                                            VENDOR_NAME = tmp_adjusted.VENDOR_NAME,
                                            LTNRDDATE = tmp_adjusted.LTNRDDATE,
                                            LTNRDDATE_D = tmp_adjusted.LTNRDDATE_D,
                                            PLNACPDDATE = tmp_adjusted.PLNACPDDATE,
                                            PLNACPDDATE_D = tmp_adjusted.PLNACPDDATE_D,
                                            LACPDDATE = tmp_adjusted.LACPDDATE,
                                            LACPDDATE_D = tmp_adjusted.LACPDDATE_D,
                                            SHPPOINT = tmp_adjusted.SHPPOINT,
                                            TRUCK_TYPE = tmp_adjusted.TRUCK_TYPE,
                                            SHPMNTNO = tmp_adjusted.SHPMNTNO,
                                            DELVNO = tmp_adjusted.DELVNO,
                                            LOADED_DATE = DateTime.Now,
                                            ACPD_ADJUST = isadjust ? 1 : 0,
                                            ACPD_ADJUST_BY = User.Identity.Name,
                                            ACPD_ADJUST_DATE = DateTime.Now,
                                            ACPD_REASON = reasonName,
                                            ACPD_REASON_ID = Convert.ToInt32(reasonId),
                                            ACPD_REMARK = remark
                                        };
                                        //insert waiting ofr approval
                                        objBs.acceptedAdjustedBs.Insert(tmp_toInsert);
                                        //delete AcceptedDelays
                                        objBs.acceptedDelayBs.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("อัพโหลดไม่สำเร็จ ประเภทไฟล์ไม่ถูกต้อง");
        }
Exemplo n.º 5
0
        public ActionResult UpdateAcceptReason(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.reasonAcceptedBs.GetByID(Convert.ToInt32(reasonId)).Name;
                            bool isadjust = objBs.reasonAcceptedBs.GetByID(Convert.ToInt32(reasonId)).IsAdjust;
                            DWH_ONTIME_SHIPMENT ontimeShipment = objBs.dWH_ONTIME_SHIPMENTBs.GetByID(sm);
                            //Change adjustable here
                            ontimeShipment.ACPD_ADJUST = 0;
                            ontimeShipment.ACPD_ADJUST_BY = User.Identity.Name;
                            ontimeShipment.ACPD_ADJUST_DATE = DateTime.Now;
                            ontimeShipment.ACPD_REASON = reasonName;
                            ontimeShipment.ACPD_REASON_ID = Convert.ToInt32(reasonId);
                            ontimeShipment.ACPD_REMARK = remark;
                            objBs.dWH_ONTIME_SHIPMENTBs.Update(ontimeShipment);

                            AcceptedDelay tmp_adjusted = objBs.acceptedDelayBs.GetByID(sm);
                            if (tmp_adjusted == null)
                            {
                                return Json("shipment " + sm + " ได้ทำการ adjust ไปแล้ว");
                            }
                            AcceptedAdjusted tmp_toInsert = new AcceptedAdjusted
                            {
                                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,
                                SEGMENT = tmp_adjusted.SEGMENT,
                                SUBSEGMENT = tmp_adjusted.SUBSEGMENT,
                                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,
                                LAST_SHPG_LOC_NAME = tmp_adjusted.LAST_SHPG_LOC_NAME,
                                VENDOR_CODE = tmp_adjusted.VENDOR_CODE,
                                VENDOR_NAME = tmp_adjusted.VENDOR_NAME,
                                LTNRDDATE = tmp_adjusted.LTNRDDATE,
                                LTNRDDATE_D = tmp_adjusted.LTNRDDATE_D,
                                PLNACPDDATE = tmp_adjusted.PLNACPDDATE,
                                PLNACPDDATE_D = tmp_adjusted.PLNACPDDATE_D,
                                LACPDDATE = tmp_adjusted.LACPDDATE,
                                LACPDDATE_D = tmp_adjusted.LACPDDATE_D,
                                SHPPOINT = tmp_adjusted.SHPPOINT,
                                TRUCK_TYPE = tmp_adjusted.TRUCK_TYPE,
                                SHPMNTNO = tmp_adjusted.SHPMNTNO,
                                DELVNO = tmp_adjusted.DELVNO,
                                LOADED_DATE = DateTime.Now,
                                ACPD_ADJUST = isadjust ? 1 : 0,
                                ACPD_ADJUST_BY = User.Identity.Name,
                                ACPD_ADJUST_DATE = DateTime.Now,
                                ACPD_REASON = reasonName,
                                ACPD_REASON_ID = Convert.ToInt32(reasonId),
                                ACPD_REMARK = remark
                            };
                            //insert waiting ofr approval
                            objBs.acceptedAdjustedBs.Insert(tmp_toInsert);
                            //delete AcceptedDelays
                            objBs.acceptedDelayBs.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.InnerException.InnerException.Message.ToString() });
                }
                //  return View();
            }
        }
Exemplo n.º 6
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/acpd/");
                    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.reasonAcceptedBs.GetByID(reasonId).Name;
                                    bool   isadjust   = objBs.reasonAcceptedBs.GetByID(Convert.ToInt32(reasonId)).IsAdjust;
                                    DWH_ONTIME_SHIPMENT ontimeShipment = objBs.dWH_ONTIME_SHIPMENTBs.GetByID(sm);
                                    //Change adjustable here
                                    ontimeShipment.ACPD_ADJUST      = 0;
                                    ontimeShipment.ACPD_ADJUST_BY   = User.Identity.Name;
                                    ontimeShipment.ACPD_ADJUST_DATE = DateTime.Now;
                                    ontimeShipment.ACPD_REASON      = reasonName;
                                    ontimeShipment.ACPD_REASON_ID   = Convert.ToInt32(reasonId);
                                    ontimeShipment.ACPD_REMARK      = remark;
                                    objBs.dWH_ONTIME_SHIPMENTBs.Update(ontimeShipment);

                                    AcceptedDelay tmp_adjusted = objBs.acceptedDelayBs.GetByID(sm);
                                    if (tmp_adjusted == null)
                                    {
                                        errorRef = errorRef + sm + " , ";
                                    }
                                    else
                                    {
                                        AcceptedAdjusted tmp_toInsert = new AcceptedAdjusted
                                        {
                                            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,
                                            SEGMENT            = tmp_adjusted.SEGMENT,
                                            SUBSEGMENT         = tmp_adjusted.SUBSEGMENT,
                                            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,
                                            LAST_SHPG_LOC_NAME = tmp_adjusted.LAST_SHPG_LOC_NAME,
                                            VENDOR_CODE        = tmp_adjusted.VENDOR_CODE,
                                            VENDOR_NAME        = tmp_adjusted.VENDOR_NAME,
                                            LTNRDDATE          = tmp_adjusted.LTNRDDATE,
                                            LTNRDDATE_D        = tmp_adjusted.LTNRDDATE_D,
                                            PLNACPDDATE        = tmp_adjusted.PLNACPDDATE,
                                            PLNACPDDATE_D      = tmp_adjusted.PLNACPDDATE_D,
                                            LACPDDATE          = tmp_adjusted.LACPDDATE,
                                            LACPDDATE_D        = tmp_adjusted.LACPDDATE_D,
                                            SHPPOINT           = tmp_adjusted.SHPPOINT,
                                            TRUCK_TYPE         = tmp_adjusted.TRUCK_TYPE,
                                            SHPMNTNO           = tmp_adjusted.SHPMNTNO,
                                            DELVNO             = tmp_adjusted.DELVNO,
                                            LOADED_DATE        = DateTime.Now,
                                            ACPD_ADJUST        = isadjust ? 1 : 0,
                                            ACPD_ADJUST_BY     = User.Identity.Name,
                                            ACPD_ADJUST_DATE   = DateTime.Now,
                                            ACPD_REASON        = reasonName,
                                            ACPD_REASON_ID     = Convert.ToInt32(reasonId),
                                            ACPD_REMARK        = remark
                                        };
                                        //insert waiting ofr approval
                                        objBs.acceptedAdjustedBs.Insert(tmp_toInsert);
                                        //delete AcceptedDelays
                                        objBs.acceptedDelayBs.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("อัพโหลดไม่สำเร็จ ประเภทไฟล์ไม่ถูกต้อง"));
        }
Exemplo n.º 7
0
        public ActionResult UpdateAcceptReason(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.reasonAcceptedBs.GetByID(Convert.ToInt32(reasonId)).Name;
                            bool   isadjust   = objBs.reasonAcceptedBs.GetByID(Convert.ToInt32(reasonId)).IsAdjust;
                            DWH_ONTIME_SHIPMENT ontimeShipment = objBs.dWH_ONTIME_SHIPMENTBs.GetByID(sm);
                            //Change adjustable here
                            ontimeShipment.ACPD_ADJUST      = 0;
                            ontimeShipment.ACPD_ADJUST_BY   = User.Identity.Name;
                            ontimeShipment.ACPD_ADJUST_DATE = DateTime.Now;
                            ontimeShipment.ACPD_REASON      = reasonName;
                            ontimeShipment.ACPD_REASON_ID   = Convert.ToInt32(reasonId);
                            ontimeShipment.ACPD_REMARK      = remark;
                            objBs.dWH_ONTIME_SHIPMENTBs.Update(ontimeShipment);

                            AcceptedDelay tmp_adjusted = objBs.acceptedDelayBs.GetByID(sm);
                            if (tmp_adjusted == null)
                            {
                                return(Json("shipment " + sm + " ได้ทำการ adjust ไปแล้ว"));
                            }
                            AcceptedAdjusted tmp_toInsert = new AcceptedAdjusted
                            {
                                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,
                                SEGMENT            = tmp_adjusted.SEGMENT,
                                SUBSEGMENT         = tmp_adjusted.SUBSEGMENT,
                                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,
                                LAST_SHPG_LOC_NAME = tmp_adjusted.LAST_SHPG_LOC_NAME,
                                VENDOR_CODE        = tmp_adjusted.VENDOR_CODE,
                                VENDOR_NAME        = tmp_adjusted.VENDOR_NAME,
                                LTNRDDATE          = tmp_adjusted.LTNRDDATE,
                                LTNRDDATE_D        = tmp_adjusted.LTNRDDATE_D,
                                PLNACPDDATE        = tmp_adjusted.PLNACPDDATE,
                                PLNACPDDATE_D      = tmp_adjusted.PLNACPDDATE_D,
                                LACPDDATE          = tmp_adjusted.LACPDDATE,
                                LACPDDATE_D        = tmp_adjusted.LACPDDATE_D,
                                SHPPOINT           = tmp_adjusted.SHPPOINT,
                                TRUCK_TYPE         = tmp_adjusted.TRUCK_TYPE,
                                SHPMNTNO           = tmp_adjusted.SHPMNTNO,
                                DELVNO             = tmp_adjusted.DELVNO,
                                LOADED_DATE        = DateTime.Now,
                                ACPD_ADJUST        = isadjust ? 1 : 0,
                                ACPD_ADJUST_BY     = User.Identity.Name,
                                ACPD_ADJUST_DATE   = DateTime.Now,
                                ACPD_REASON        = reasonName,
                                ACPD_REASON_ID     = Convert.ToInt32(reasonId),
                                ACPD_REMARK        = remark
                            };
                            //insert waiting ofr approval
                            objBs.acceptedAdjustedBs.Insert(tmp_toInsert);
                            //delete AcceptedDelays
                            objBs.acceptedDelayBs.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.InnerException.InnerException.Message.ToString() }));
                }
                //  return View();
            }
        }
Exemplo n.º 8
0
 //Update
 public void Update(AcceptedAdjusted acceptedAdjusted)
 {
     db.Entry(acceptedAdjusted).State = EntityState.Modified;
     Save();
 }
Exemplo n.º 9
0
 //Insert
 public void Insert(AcceptedAdjusted acceptedAdjusted)
 {
     db.AcceptedAdjusted.Add(acceptedAdjusted);
     Save();
 }