예제 #1
0
        public int UpdateTransactionS02006(List <TransactionDataViewModel> listTransactionDataModel)
        {
            int result = 0;

            try
            {
                for (int i = 0; i < listTransactionDataModel.Count; i++)
                {
                    for (int j = 0; j < listTransactionDataModel[i].Data.Length; j++)
                    {
                        //SPLITSTRING
                        S02006ViewModel modelSO2006 = SplitStringS02006(listTransactionDataModel[i].Data[j]);

                        //UPDATE CUSTOMGR
                        CUSTOMGR customGR = entities.CUSTOMGRs.SingleOrDefault(x => x.PONUMBER == modelSO2006.PONumberSERA);

                        //modify by iyan : 01Nov2013
                        ////UPDATE CUSTOMBPKB
                        //CUSTOMBPKB customBPKB = entities.CUSTOMBPKBs.SingleOrDefault(x => x.PONUMBER == modelSO2006.PONumberSERA);
                        //UPDATE CUSTOMPO
                        CUSTOMPO customPO = entities.CUSTOMPOes.SingleOrDefault(x => x.PONUMBER == modelSO2006.PONumberSERA);
                        //end modify

                        //UPDATE CUSTOMIR
                        var customIR = entities.CUSTOMIRs.Where(x => x.PONUMBER == modelSO2006.PONumberSERA).Take(1).ToList();

                        //UPDATE CUSTOM_VENDOR_TRANSACTION
                        CUSTOM_VENDOR_TRANSACTION customVendorTransaction = entities.CUSTOM_VENDOR_TRANSACTION.SingleOrDefault(x => x.PONumber == modelSO2006.PONumberSERA);

                        //jika di 4 table ada,
                        if (customGR != null && customPO != null && customIR.Count > 0 && customVendorTransaction != null)
                        {
                            //cek DownloadDate di custVendorTrans, jika tidak null, cek lagi
                            if (customVendorTransaction.DownloadDate != null)
                            {
                                //cek DownloadDate di custVendorTrans apakah yang baru lebih besar tanggalnya.
                                if (modelSO2006.DownloadDate >= customVendorTransaction.DownloadDate)
                                {
                                    //call sp_UpdateS02006
                                    result = UpdateS02006(modelSO2006);
                                }
                            }
                            //jika null, langsung update
                            else
                            {
                                //call sp_UpdateS02006
                                result = UpdateS02006(modelSO2006);
                            }
                        }
                    }
                }

                //result = 1;
            }
            catch (Exception ex)
            {
                return(result = 0);
            }
            return(result);
        }
예제 #2
0
        public CUSTOMPO UpdateDeliveryCustPO(string poNumber, CUSTOMPO model)
        {
            var dc = new eprocdbDataContext();

            var md = (from c in dc.CUSTOMPOs
                      where c.PONUMBER == poNumber.Trim()
                      select c).SingleOrDefault();

            if (md != null)
            {
                md.HARGADPP_INPUT       = model.HARGADPP_INPUT;
                md.HARGAPPNUNIT_INPUT   = model.HARGAPPNUNIT_INPUT;
                md.HARGABBN_INPUT       = model.HARGABBN_INPUT;
                md.DODATE               = model.DODATE;
                md.DONUMBER             = model.DONUMBER;
                md.CARROSERIEVENDORNAME = model.CARROSERIEVENDORNAME;
                md.ACCESORIESADDRESS    = model.ACCESORIESADDRESS;
                md.REMARKSCARROSSERIE   = model.REMARKSCARROSSERIE;
                md.TGLMASUKKAROSERI     = model.TGLMASUKKAROSERI;
                md.TGLSELESAIKAROSERI   = model.TGLSELESAIKAROSERI;
                md.REMARKS              = model.REMARKS;
                md.MODIFIED_BY          = model.MODIFIED_BY;
                md.MODIFIED_DATE        = model.MODIFIED_DATE;
                dc.SubmitChanges();
                UpdateStatus(poNumber);
            }
            return(model);
        }
예제 #3
0
        public CUSTOMPO UpdateInvoiceCustPO(string poNumber, CUSTOMPO model)
        {
            var dc = new eprocdbDataContext();

            var md = (from c in dc.CUSTOMPOs
                      where c.PONUMBER == poNumber.Trim()
                      select c).SingleOrDefault();

            if (md != null)
            {
                md.TGLGI         = model.TGLGI;
                md.MODIFIED_BY   = model.MODIFIED_BY;
                md.MODIFIED_DATE = model.MODIFIED_DATE;
                dc.SubmitChanges();
                UpdateStatus(poNumber);
            }
            return(model);
        }
예제 #4
0
        public CUSTOMPO UpdateInvoiceCustPO(string poNumber, CUSTOMPO model)
        {
            var dc = new eprocdbDataContext();

            var md = (from c in dc.CUSTOMPOs
                      where c.PONUMBER == poNumber.Trim()
                      select c).SingleOrDefault();

            md.TGLMASUKKAROSERI        = model.TGLMASUKKAROSERI;
            md.DONUMBER                = model.DONUMBER;
            md.DODATE                  = model.DODATE;
            md.REASONREVISEDBYVENDOR   = model.REASONREVISEDBYVENDOR;
            md.ACTUALDATEDELIVEREDUNIT = model.ACTUALDATEDELIVEREDUNIT;
            md.MODIFIED_BY             = model.MODIFIED_BY;
            md.MODIFIED_DATE           = model.MODIFIED_DATE;
            dc.SubmitChanges();
            UpdateStatus(poNumber);
            return(model);
        }
예제 #5
0
        public int UpdateTransactionS02008(List <TransactionDataViewModel> listTransactionDataModel)
        {
            int result = 0;

            try
            {
                for (int i = 0; i < listTransactionDataModel.Count; i++)
                {
                    for (int j = 0; j < listTransactionDataModel[i].Data.Length; j++)
                    {
                        //SPLITSTRING
                        S02008ViewModel modelSO2008 = SplitStringS02008(listTransactionDataModel[i].Data[j]);

                        //UPDATE CUSTOMPO
                        CUSTOMPO customPO = entities.CUSTOMPOes.SingleOrDefault(x => x.PONUMBER == modelSO2008.PONumber);
                        //customPO.TGLMASUKKAROSERI = modelSO2008.DateEntryCarrosserieAccessories;

                        //UPDATE CUSTOMGR
                        CUSTOMGR customGR = entities.CUSTOMGRs.SingleOrDefault(x => x.PONUMBER == modelSO2008.PONumber);
                        //customGR.NOCHASIS_INPUT = modelSO2008.ChassisNumberByVendor;

                        if (customPO != null && customGR != null)
                        {
                            //calling sp_UpdateS02008
                            result = UpdateS02008(modelSO2008);
                        }
                        //entities.SaveChanges();
                    }
                }
                //result = 1;
            }
            catch (Exception ex)
            {
                return(result = 0);
            }
            return(result);
        }
예제 #6
0
        public CUSTOMPO UpdateDeliveryCustPO(string poNumber, CUSTOMPO model)
        {
            var dc = new eprocdbDataContext();

            var md = (from c in dc.CUSTOMPOs
                      where c.PONUMBER == poNumber.Trim()
                      select c).SingleOrDefault();

            md.PURCHASESTATUS       = model.PURCHASESTATUS;
            md.CARROSERIEVENDORNAME = model.CARROSERIEVENDORNAME;
            md.ACCESORIESADDRESS    = model.ACCESORIESADDRESS;
            md.REMARKSCARROSSERIE   = model.REMARKSCARROSSERIE;
            md.PICKAROSERI          = model.PICKAROSERI;
            md.NOTELEPONKAROSERI    = model.NOTELEPONKAROSERI;
            md.BENTUKKAROSERI       = model.BENTUKKAROSERI;
            md.PROMISEDLVDATEPO     = model.PROMISEDLVDATEPO;
            md.TGLSELESAIKAROSERI   = model.TGLSELESAIKAROSERI;
            md.REMARKS       = model.REMARKS;
            md.MODIFIED_BY   = model.MODIFIED_BY;
            md.MODIFIED_DATE = model.MODIFIED_DATE;
            dc.SubmitChanges();
            UpdateStatus(poNumber);
            return(model);
        }
예제 #7
0
        public int UpdateTransactionS02002(List <TransactionDataViewModel> listTransactionDataModel)
        {
            int           result     = 0;
            List <string> errorCatch = new List <string>();

            try
            {
                for (int i = 0; i < listTransactionDataModel.Count; i++)
                {
                    string poNumber = listTransactionDataModel[i].Data[0].Split('|')[1].Trim();
                    if (!string.IsNullOrEmpty(poNumber))
                    {
                        CUSTOMPO   customPO   = entities.CUSTOMPOes.SingleOrDefault(x => x.PONUMBER == poNumber);
                        CUSTOMGR   customGR   = entities.CUSTOMGRs.SingleOrDefault(x => x.PONUMBER == poNumber);
                        CUSTOMBPKB customBPKB = entities.CUSTOMBPKBs.SingleOrDefault(x => x.PONUMBER == poNumber);

                        for (int j = 0; j < listTransactionDataModel[i].Data.Length; j++)
                        {
                            try
                            {
                                S02002ViewModel modelSO2002 = new S02002ViewModel();
                                //switch (j)
                                //{
                                //    case 0:
                                //        S02002ViewModel modelHSSO2002 = SplitStringHSS02002(listTransactionDataModel[i].Data[j]);
                                //        break;
                                //    case 1:
                                //        S02002ViewModel modelISSO2002 = SplitStringISS02002(listTransactionDataModel[i].Data[j]);
                                //        break;
                                //    default:
                                //        break;
                                //}
                                if (listTransactionDataModel[i].Data[j].Split('|')[0].Trim().Contains("HS"))
                                {
                                    modelSO2002 = SplitStringHSS02002(listTransactionDataModel[i].Data[j]);
                                }
                                else if (listTransactionDataModel[i].Data[j].Split('|')[0].Trim().Contains("IS"))
                                {
                                    modelSO2002 = SplitStringISS02002(listTransactionDataModel[i].Data[j]);
                                }

                                //HS-IS update
                                if (listTransactionDataModel[i].Data[j].Split('|')[0].Trim().Contains("HS"))
                                {
                                    result = UpdateS02002HS(poNumber, "HS", modelSO2002);
                                }
                                else if (listTransactionDataModel[i].Data[j].Split('|')[0].Trim().Contains("IS"))
                                {
                                    if (customPO != null && customGR != null && customBPKB != null)
                                    {
                                        result = UpdateS02002IS(poNumber, "IS", modelSO2002);
                                    }
                                }
                                //CustomPO Update
                                if (customGR.ACTUALRECEIVEDUNIT.HasValue && modelSO2002.ActualDateDeliveryUnit.HasValue && customPO.ACTUALDATEDELIVEREDUNIT.HasValue)
                                {
                                    UpdateCustomPOStatusPOId(poNumber, "5");
                                }
                            }
                            catch (Exception ex)
                            {
                                errorCatch.Add(poNumber + " | " + ex.Message);
                                //something
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(result = 0);
            }

            return(result);
        }
예제 #8
0
        public ActionResult Index(HttpPostedFileBase postedFile, CUSTOMFILEUPLOAD model, string DdlForm)
        {
            string filePath = string.Empty;
            List <ErrorUploadViewModel> errorUpload = new List <ErrorUploadViewModel>();

            if (postedFile != null)
            {
                string path = Server.MapPath("~/Uploads/");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                string tahun = DateTime.Now.Year.ToString();
                string bulan = DateTime.Now.Month.ToString();
                string tgl   = DateTime.Now.Day.ToString();
                string jam   = DateTime.Now.Hour.ToString();
                string menit = DateTime.Now.Minute.ToString();
                string detik = DateTime.Now.Second.ToString();

                string tanggalSekarang = "_" + tahun + bulan + tgl + jam + menit + detik;

                string type = "";

                if (DdlForm == "1")
                {
                    type = "Delivery";
                }
                else if (DdlForm == "2")
                {
                    type = "Invoice";
                }
                else if (DdlForm == "3")
                {
                    type = "BPKB";
                }

                string FileName = type + tanggalSekarang + ".xls";
                filePath = path + FileName;

                try
                {
                    postedFile.SaveAs(filePath);

                    IUploadVehicleService svc = new UploadVehicleService();

                    model.ID            = Convert.ToInt32(UploadVehicleService.GenerateID());
                    model.FILEUPLOAD    = FileName;
                    model.MODIFIED_BY   = "namaUser";
                    model.MODIFIED_DATE = DateTime.Now.Date;

                    var result = svc.Add(model);

                    DataTable dt = postedFile.ToDataTable();

                    #region Insert

                    #region Delivery
                    if (type == "Delivery")
                    {
                        int i = 1;
                        foreach (DataRow row in dt.Rows)
                        {
                            IUploadVendorService svcUpldVendor = new UploadVendorService();
                            bool AutheticateData = svcUpldVendor.CheckAutheicatePoNumberByVendorID(row["PONUMBER"].ToString(), System.Web.HttpContext.Current.Session["VendorID"].ToString());
                            //cek row null atau tidak
                            if (row["PONUMBER"] != DBNull.Value)
                            {
                                if (!svcUpldVendor.IfExist(row["PONUMBER"].ToString()))
                                {
                                    //create new model
                                    ErrorUploadViewModel error = new ErrorUploadViewModel();
                                    error.row     = i;
                                    error.column  = "PONUMBER";
                                    error.message = "PONUMBER doesn't exis";
                                    errorUpload.Add(error);
                                }
                                else
                                {
                                    if (System.Web.HttpContext.Current.Session["GroupID"].ToString() == "Super" || System.Web.HttpContext.Current.Session["GroupID"].ToString() == "PROCUREMENT" || !AutheticateData)
                                    {
                                        //create new model
                                        ErrorUploadViewModel error = new ErrorUploadViewModel();
                                        error.row     = i;
                                        error.column  = "PONUMBER";
                                        error.message = "PONUMBER AND VENDOR ID NOT MATCH";
                                        errorUpload.Add(error);
                                    }
                                    else
                                    {
                                        var dc = new eprocdbDataContext();

                                        #region CUSTOMPO
                                        CUSTOMPO customPO = new CUSTOMPO();
                                        customPO.HARGADPP_INPUT     = TryParseNullDouble(row["HARGADPP_INPUT"].ToString());
                                        customPO.HARGAPPNUNIT_INPUT = TryParseNullDouble(row["HARGAPPNUNIT_INPUT"].ToString());;
                                        customPO.HARGABBN_INPUT     = TryParseNullDouble(row["HARGABBN_INPUT"].ToString());

                                        customPO.DODATE = TryParseNull(row["DODATE"].ToString());

                                        customPO.DONUMBER             = row["DONUMBER"].ToString();
                                        customPO.CARROSERIEVENDORNAME = row["CARROSERIEVENDORNAME"].ToString();
                                        customPO.ACCESORIESADDRESS    = row["ACCESORIESADDRESS"].ToString();
                                        customPO.REMARKSCARROSSERIE   = row["REMARKSCARROSSERIE"].ToString();

                                        customPO.TGLMASUKKAROSERI   = TryParseNull(row["TGLMASUKKAROSERI"].ToString());
                                        customPO.TGLSELESAIKAROSERI = TryParseNull(row["TGLSELESAIKAROSERI"].ToString());

                                        customPO.REMARKS       = row["REMARKS"].ToString();
                                        customPO.MODIFIED_BY   = Session["UserID"].ToString();
                                        customPO.MODIFIED_DATE = DateTime.Now.Date;

                                        customPO.ACTUALDATEDELIVEREDUNIT = TryParseNull(row["TANGGALBSTB"].ToString());

                                        var resultPO = svcUpldVendor.UpdateDeliveryCustPO(row["PONUMBER"].ToString(), customPO);
                                        #endregion

                                        #region CUSTOMBPKB
                                        CUSTOMBPKB customBPKB = new CUSTOMBPKB();

                                        customBPKB.NOPOLISI_INPUT = row["NOPOLISI_INPUT"].ToString();
                                        customBPKB.TGLSTNK_INPUT  = TryParseNull(row["TGLSTNK_INPUT"].ToString());
                                        customBPKB.STCKDATE       = TryParseNull(row["STCKDATE"].ToString());
                                        customBPKB.TGLSERAHBPKB   = TryParseNull(row["TGLSERAHBPKB"].ToString());
                                        customPO.MODIFIED_BY      = Session["UserID"].ToString();
                                        customPO.MODIFIED_DATE    = DateTime.Now.Date;

                                        var resultBPKB = svcUpldVendor.UpdateDeliveryCustBPKB(row["PONUMBER"].ToString(), customBPKB);
                                        #endregion

                                        #region CUSTOMGR
                                        CUSTOMGR customGR = new CUSTOMGR();

                                        customGR.NOCHASIS_INPUT = row["NOCHASIS_INPUT"].ToString();
                                        customGR.NOENGINE_INPUT = row["NOENGINE_INPUT"].ToString();
                                        customPO.MODIFIED_BY    = Session["UserID"].ToString();
                                        customPO.MODIFIED_DATE  = DateTime.Now.Date;

                                        var resultGR = svcUpldVendor.UpdateDeliveryCustGR(row["PONUMBER"].ToString(), customGR);
                                        #endregion
                                    }
                                }
                            }
                        }
                        i++;
                    }

                    #endregion

                    #region Invoice
                    if (type == "Invoice")
                    {
                        int i = 1;
                        foreach (DataRow row in dt.Rows)
                        {
                            //cek row null atau tidak
                            if (row["PONUMBER"] != DBNull.Value)
                            {
                                IUploadVendorService svcUpldVendor = new UploadVendorService();
                                bool AutheticateData = svcUpldVendor.CheckAutheicatePoNumberByVendorID(row["PONUMBER"].ToString(), System.Web.HttpContext.Current.Session["VendorID"].ToString());

                                if (!svcUpldVendor.IfExist(row["PONUMBER"].ToString()))
                                {
                                    //create new model
                                    ErrorUploadViewModel error = new ErrorUploadViewModel();
                                    error.row     = i;
                                    error.column  = "PONUMBER";
                                    error.message = "PONUMBER doesn't exist";
                                    errorUpload.Add(error);
                                }
                                else
                                {
                                    if (System.Web.HttpContext.Current.Session["GroupID"].ToString() == "Super" || System.Web.HttpContext.Current.Session["GroupID"].ToString() == "PROCUREMENT" || !AutheticateData)
                                    {
                                        //create new model
                                        ErrorUploadViewModel error = new ErrorUploadViewModel();
                                        error.row     = i;
                                        error.column  = "PONUMBER";
                                        error.message = "PONUMBER AND VENDOR ID NOT MATCH";
                                        errorUpload.Add(error);
                                    }
                                    else
                                    {
                                        var dc = new eprocdbDataContext();

                                        #region CUSTOMPO
                                        CUSTOMPO customPO = new CUSTOMPO();
                                        customPO.TGLGI         = TryParseNull(row["TGLGI"].ToString());
                                        customPO.MODIFIED_BY   = Session["UserID"].ToString();
                                        customPO.MODIFIED_DATE = DateTime.Now.Date;

                                        var resultPO = svcUpldVendor.UpdateInvoiceCustPO(row["PONUMBER"].ToString(), customPO);

                                        #endregion

                                        #region CUSTOMBPKB
                                        CUSTOMBPKB customBpkb = new CUSTOMBPKB();

                                        customBpkb.NOFAKTUR      = row["NOFAKTUR"].ToString();
                                        customBpkb.MODIFIED_BY   = Session["UserID"].ToString();
                                        customBpkb.MODIFIED_DATE = DateTime.Now.Date;

                                        var resultBPKB = svcUpldVendor.UpdateInvoiceCustBpkb(row["PONUMBER"].ToString(), customBpkb);
                                        #endregion

                                        #region CUSTOMGR
                                        CUSTOMGR customGR = new CUSTOMGR();

                                        customGR.STATUSDELIVERYUNIT = row["STATUSDELIVERYUNIT"].ToString();
                                        customGR.MODIFIED_BY        = Session["UserID"].ToString();
                                        customGR.MODIFIED_DATE      = DateTime.Now.Date;

                                        var resultGR = svcUpldVendor.UpdateInvoiceCustGR(row["PONUMBER"].ToString(), customGR);
                                        #endregion

                                        #region CUSTOMIR
                                        CUSTOMIR customIR = new CUSTOMIR();

                                        customIR.INVNO         = row["INVNO"].ToString();
                                        customIR.INVDATE       = TryParseNull(row["INVDATE"].ToString());
                                        customIR.MODIFIED_BY   = Session["UserID"].ToString();
                                        customIR.MODIFIED_DATE = DateTime.Now.Date;

                                        var resultIR = svcUpldVendor.UpdateInvoiceCustIR(row["PONUMBER"].ToString(), customIR);
                                        #endregion
                                    }
                                }
                            }
                            i++;
                        }
                    }
                    #endregion

                    #region Bpkb
                    if (type == "BPKB")
                    {
                        int i = 1;
                        foreach (DataRow row in dt.Rows)
                        {
                            //cek row null atau tidak
                            if (row["PONUMBER"] != DBNull.Value)
                            {
                                IUploadVendorService svcUpldVendor = new UploadVendorService();
                                bool AutheticateData = svcUpldVendor.CheckAutheicatePoNumberByVendorID(row["PONUMBER"].ToString(), System.Web.HttpContext.Current.Session["VendorID"].ToString());
                                if (!svcUpldVendor.IfExist(row["PONUMBER"].ToString()))
                                {
                                    //create new model
                                    ErrorUploadViewModel error = new ErrorUploadViewModel();
                                    error.row     = i;
                                    error.column  = "PONUMBER";
                                    error.message = "PONUMBER doesn't exist";
                                    errorUpload.Add(error);
                                }
                                else
                                {
                                    if (System.Web.HttpContext.Current.Session["GroupID"].ToString() == "Super" || System.Web.HttpContext.Current.Session["GroupID"].ToString() == "PROCUREMENT" || !AutheticateData)
                                    {
                                        //create new model
                                        ErrorUploadViewModel error = new ErrorUploadViewModel();
                                        error.row     = i;
                                        error.column  = "PONUMBER";
                                        error.message = "PONUMBER AND VENDOR ID NOT MATCH";
                                        errorUpload.Add(error);
                                    }
                                    else
                                    {
                                        var dc = new eprocdbDataContext();

                                        #region CUSTOMBPKB
                                        CUSTOMBPKB customBPKB = new CUSTOMBPKB();

                                        customBPKB.ACTUALDELIVERYBPKBTOFINANCE = TryParseNull(row["ACTUALDELIVERYBPKBTOFINANCE"].ToString());
                                        customBPKB.ACTUALRECEIVEDBPKBDICAB     = TryParseNull(row["ACTUALRECEIVEDBPKBDICAB"].ToString());
                                        customBPKB.KETBPKB                      = row["KETBPKB"].ToString();
                                        customBPKB.NOBPKB                       = row["NOBPKB"].ToString();
                                        customBPKB.KETSURATUBAHBENTUK           = row["KETSURATUBAHBENTUK"].ToString();
                                        customBPKB.KETERANGANSURATRUBAHWARNA    = row["KETERANGANSURATRUBAHWARNA"].ToString();
                                        customBPKB.NOFAKTUR                     = row["NOFAKTUR"].ToString();
                                        customBPKB.TGLFAKTUR                    = TryParseNull(row["TGLFAKTUR"].ToString());
                                        customBPKB.NOSERTIFIKAT                 = row["NOSERTIFIKAT"].ToString();
                                        customBPKB.TGLSERTIFIKAT                = TryParseNull(row["TGLSERTIFIKAT"].ToString());
                                        customBPKB.NOFORMULIRA                  = row["NOFORMULIRA"].ToString();
                                        customBPKB.TGLFORMULIRA                 = TryParseNull(row["TGLFORMULIRA"].ToString());
                                        customBPKB.NOSURATUBAHBENTUK            = row["NOSURATUBAHBENTUK"].ToString();
                                        customBPKB.TGLSURATUBAHBENTUK           = TryParseNull(row["TGLSURATUBAHBENTUK"].ToString());
                                        customBPKB.NOSURATRUBAHWARNA            = row["NOSURATRUBAHWARNA"].ToString();
                                        customBPKB.TANGGALSURATRUBAHWARNA       = TryParseNull(row["TANGGALSURATRUBAHWARNA"].ToString());
                                        customBPKB.NOSERTIFIKATREGUJITIPE       = row["NOSERTIFIKATREGUJITIPE"].ToString();
                                        customBPKB.ACTUALRECEIVEDBPKBDIHO       = TryParseNull(row["ACTUALRECEIVEDBPKBDIHO"].ToString());
                                        customBPKB.ACTUALDELIVERYBPKBTOFINANCE  = TryParseNull(row["ACTUALDELIVERYBPKBTOFINANCE"].ToString());
                                        customBPKB.ACTUALRECEIVEDBPKBHOBACK     = TryParseNull(row["ACTUALRECEIVEDBPKBHOBACK"].ToString());
                                        customBPKB.DATEDELIVERYTOBRANCHORVENDOR = TryParseNull(row["DATEDELIVERYTOBRANCHORVENDOR"].ToString());
                                        customBPKB.REMARKSDETAILPROBLEM         = row["REMARKSDETAILPROBLEM"].ToString();
                                        customBPKB.MODIFIED_BY                  = Session["UserID"].ToString();
                                        customBPKB.MODIFIED_DATE                = DateTime.Now.Date;

                                        var resultBPKB = svcUpldVendor.UpdateBpkbCustBPKB(row["PONUMBER"].ToString(), customBPKB);
                                        #endregion
                                    }
                                }
                            }
                            i++;
                        }
                    }
                    #endregion

                    #endregion

                    if (filePath != null || filePath != string.Empty)
                    {
                        if ((System.IO.File.Exists(filePath)))
                        {
                            System.IO.File.Delete(filePath);
                        }
                    }
                    if (errorUpload.Count > 0)
                    {
                        this.AddNotification("File uploaded failed.", NotificationType.ERROR);
                    }
                    else
                    {
                        this.AddNotification("File uploaded successfully.", NotificationType.SUCCESS);
                    }
                }
                catch (Exception ex)
                {
                    general.AddLogError("Upload Vendor", ex.Message, ex.StackTrace);
                    this.AddNotification("File uploaded failed.", NotificationType.ERROR);
                    return(View("~/Views/Upload/Vendor/Index.cshtml"));

                    throw ex;
                }
            }

            IEnumerable <ErrorUploadViewModel> eu = errorUpload;
            return(View("~/Views/Upload/Vendor/Index.cshtml", eu));
        }
예제 #9
0
        public ActionResult Index(HttpPostedFileBase postedFile, CUSTOMFILEUPLOAD model, string DdlForm)
        {
            string filePath = string.Empty;

            if (postedFile != null)
            {
                string path = Server.MapPath("~/Uploads/");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                string tahun = DateTime.Now.Year.ToString();
                string bulan = DateTime.Now.Month.ToString();
                string tgl   = DateTime.Now.Day.ToString();
                string jam   = DateTime.Now.Hour.ToString();
                string menit = DateTime.Now.Minute.ToString();
                string detik = DateTime.Now.Second.ToString();

                string tanggalSekarang = "_" + tahun + bulan + tgl + jam + menit + detik;

                string type = "";

                if (DdlForm == "1")
                {
                    type = "Delivery";
                }
                else if (DdlForm == "2")
                {
                    type = "Invoice";
                }
                else if (DdlForm == "3")
                {
                    type = "BPKB";
                }

                string FileName = type + tanggalSekarang + ".xls";
                filePath = path + FileName;
                string errorPoNumber = string.Empty;
                try
                {
                    postedFile.SaveAs(filePath);

                    IUploadVehicleService svc = new UploadVehicleService();

                    model.ID            = Convert.ToInt32(UploadVehicleService.GenerateID());
                    model.FILEUPLOAD    = FileName;
                    model.MODIFIED_BY   = "namaUser";
                    model.MODIFIED_DATE = DateTime.Now.Date;

                    var result = svc.Add(model);

                    DataTable dt = postedFile.ToDataTable();

                    #region Insert

                    #region Delivery
                    if (type == "Delivery")
                    {
                        foreach (DataRow row in dt.Rows)
                        {
                            //cek row null atau tidak
                            if (row["PONUMBER"] != DBNull.Value)
                            {
                                var dc = new eprocdbDataContext();

                                IUploadVehicleService svcUpldVehicle = new UploadVehicleService();

                                #region CUSTOMPO
                                CUSTOMPO customPO = new CUSTOMPO();

                                customPO.PURCHASESTATUS       = row["PURCHASESTATUS"].ToString();
                                customPO.CARROSERIEVENDORNAME = row["CARROSERIEVENDORNAME"].ToString();
                                customPO.ACCESORIESADDRESS    = row["ACCESORIESADDRESS"].ToString();
                                customPO.REMARKSCARROSSERIE   = row["REMARKSCARROSSERIE"].ToString();
                                customPO.PICKAROSERI          = row["PICKAROSERI"].ToString();
                                customPO.NOTELEPONKAROSERI    = row["NOTELEPONKAROSERI"].ToString();
                                customPO.BENTUKKAROSERI       = row["BENTUKKAROSERI"].ToString();

                                customPO.PROMISEDLVDATEPO   = TryParseNull(row["PROMISEDLVDATEPO"].ToString());
                                customPO.TGLSELESAIKAROSERI = TryParseNull(row["PROMISEDLVDATEPO"].ToString());

                                //DateTime BSTB;
                                //DateTime.TryParse(row["TANGGALBSTB"].ToString(), out BSTB);
                                //customPO.ACTUALDATEDELIVEREDUNIT = BSTB;

                                customPO.REMARKS       = row["REMARKS"].ToString();
                                customPO.MODIFIED_BY   = Session["UserID"].ToString();
                                customPO.MODIFIED_DATE = DateTime.Now.Date;

                                var resultPO = svcUpldVehicle.UpdateDeliveryCustPO(row["PONUMBER"].ToString(), customPO);
                                #endregion
                            }
                        }
                    }
                    #endregion

                    #region Invoice
                    if (type == "Invoice")
                    {
                        foreach (DataRow row in dt.Rows)
                        {
                            //cek row null atau tidak
                            if (row["PONUMBER"] != DBNull.Value)
                            {
                                var dc = new eprocdbDataContext();

                                IUploadVehicleService svcUpldVehicle = new UploadVehicleService();

                                #region CUSTOMPO
                                CUSTOMPO customPO = new CUSTOMPO();
                                customPO.TGLMASUKKAROSERI        = TryParseNull(row["TGLMASUKKAROSERI"].ToString());
                                customPO.DONUMBER                = row["DONUMBER"].ToString();
                                customPO.DODATE                  = TryParseNull(row["DODATE"].ToString());
                                customPO.REASONREVISEDBYVENDOR   = row["REASONREVISEDBYVENDOR"].ToString();
                                customPO.ACTUALDATEDELIVEREDUNIT = TryParseNull(row["TANGGALBSTB"].ToString());
                                customPO.MODIFIED_BY             = Session["UserID"].ToString();
                                customPO.MODIFIED_DATE           = DateTime.Now.Date;

                                var resultPO = svcUpldVehicle.UpdateInvoiceCustPO(row["PONUMBER"].ToString(), customPO);
                                #endregion

                                /*
                                 #region CUSTOMBPKB
                                 * CUSTOMBPKB customBpkb = new CUSTOMBPKB();
                                 *
                                 * customBpkb.NOFAKTUR = row["NOFAKTUR"].ToString();
                                 * customBpkb.MODIFIED_BY = Session["UserID"].ToString();
                                 * customBpkb.MODIFIED_DATE = DateTime.Now.Date;
                                 *
                                 * var resultBPKB = svcUpldVehicle.UpdateInvoiceCustBpkb(row["PONUMBER"].ToString(), customBpkb);
                                 #endregion
                                 *
                                 #region CUSTOMGR
                                 * CUSTOMGR customGR = new CUSTOMGR();
                                 *
                                 * customGR.NOCHASIS_INPUT = row["NOCHASIS_INPUT"].ToString();
                                 * customGR.NOENGINE_INPUT = row["NOENGINE_INPUT"].ToString();
                                 * customGR.ACTUALRECEIVEDUNITINBDEL = TryParseNull(row["ACTUALRECEIVEDUNITINBDEL"].ToString());
                                 * customGR.MODIFIED_BY = Session["UserID"].ToString();
                                 * customGR.MODIFIED_DATE = DateTime.Now.Date;
                                 *
                                 * var resultGR = svcUpldVehicle.UpdateInvoiceCustGR(row["PONUMBER"].ToString(), customGR);
                                 #endregion
                                 *
                                 #region CUSTOMIR
                                 * CUSTOMIR customIR = new CUSTOMIR();
                                 *
                                 * customIR.NOFAKTURPAJAK = row["NOFAKTURPAJAK"].ToString();
                                 * customIR.TERMOFPAYMENT = TryParseNullInt(row["TERMOFPAYMENT"].ToString());
                                 * customIR.TGLSERAHTAGIHAN = TryParseNull(row["TGLSERAHTAGIHAN"].ToString());
                                 * customIR.KETBAYAR = row["KETBAYAR"].ToString();
                                 * customIR.KETTAGIHAN = row["KETTAGIHAN"].ToString();
                                 * customIR.MODIFIED_BY = Session["UserID"].ToString();
                                 * customIR.MODIFIED_DATE = DateTime.Now.Date;
                                 *
                                 * var resultIR = svcUpldVehicle.UpdateInvoiceCustIR(row["PONUMBER"].ToString(), customIR);
                                 #endregion
                                 */
                            }
                        }
                    }
                    #endregion

                    #region Bpkb
                    string        Message      = string.Empty;
                    StringBuilder listPONumber = new StringBuilder();
                    if (type == "BPKB")
                    {
                        foreach (DataRow row in dt.Rows)
                        {
                            //cek row null atau tidak
                            if (row["PONUMBER"] != DBNull.Value)
                            {
                                var dc = new eprocdbDataContext();
                                var md = (from c in dc.CUSTOMBPKBs
                                          where c.PONUMBER == row["PONUMBER"].ToString().Trim()
                                          select c).SingleOrDefault();
                                if (md != null)
                                {
                                    IUploadVehicleService svcUpldVehicle = new UploadVehicleService();

                                    #region CUSTOMBPKB
                                    CUSTOMBPKB customBPKB = new CUSTOMBPKB();

                                    customBPKB.ACTUALRECEIVEDBPKBDIHO = TryParseNull(row["ACTUALRECEIVEDBPKBDIHO"].ToString());

                                    customBPKB.ACTUALRECEIVEDBPKBDICAB = TryParseNull(row["ACTUALRECEIVEDBPKBDICAB"].ToString());

                                    customBPKB.DETAILPROBLEM    = row["DETAILPROBLEM"].ToString();
                                    customBPKB.REASONREVISEBPKB = row["REASONREVISEBPKB"].ToString();

                                    customBPKB.TGLSERAHBPKB = TryParseNull(row["TGLSERAHBPKB"].ToString());

                                    customBPKB.ACTUALDELIVERYBPKBTOFINANCE = TryParseNull(row["ACTUALDELIVERYBPKBTOFINANCE"].ToString());

                                    customBPKB.ACTUALRECEIVEDBPKBHOBACK = TryParseNull(row["ACTUALRECEIVEDBPKBHOBACK"].ToString());

                                    customBPKB.DATEDELIVERYTOBRANCHORVENDOR = TryParseNull(row["DATEDELIVERYTOBRANCHORVENDOR"].ToString());

                                    customBPKB.NOBPKB             = row["NOBPKB"].ToString();
                                    customBPKB.NOFAKTUR           = row["NOFAKTUR"].ToString();
                                    customBPKB.NOSERTIFIKAT       = row["NOSERTIFIKAT"].ToString();
                                    customBPKB.NOFORMULIRA        = row["NOFORMULIRA"].ToString();
                                    customBPKB.KETSURATUBAHBENTUK = row["KETSURATUBAHBENTUK"].ToString();
                                    customBPKB.NOSURATUBAHBENTUK  = row["NOSURATUBAHBENTUK"].ToString();

                                    customBPKB.TGLSURATUBAHBENTUK = TryParseNull(row["TGLSURATUBAHBENTUK"].ToString());

                                    customBPKB.KETERANGANSURATRUBAHWARNA = row["KETERANGANSURATRUBAHWARNA"].ToString();
                                    customBPKB.NOSURATRUBAHWARNA         = row["NOSURATRUBAHWARNA"].ToString();

                                    customBPKB.TANGGALSURATRUBAHWARNA = TryParseNull(row["TANGGALSURATRUBAHWARNA"].ToString());

                                    customBPKB.NOSERTIFIKATREGUJITIPE = row["NOSERTIFIKATREGUJITIPE"].ToString();
                                    customBPKB.REMARKSDETAILPROBLEM   = row["REMARKSDETAILPROBLEM"].ToString();
                                    customBPKB.KETBPKB       = row["KETBPKB"].ToString();
                                    customBPKB.MODIFIED_BY   = Session["UserID"].ToString();
                                    customBPKB.MODIFIED_DATE = DateTime.Now.Date;

                                    var resultBPKB = svcUpldVehicle.UpdateBpkbCustBPKB(row["PONUMBER"].ToString(), customBPKB);
                                    #endregion
                                }
                                else
                                {
                                    Message = "PONUMBER doesn't exist ";
                                    listPONumber.Append(row["PONUMBER"].ToString()).Append(", ");
                                }
                            }
                        }
                    }
                    #endregion

                    #endregion

                    if (filePath != null || filePath != string.Empty)
                    {
                        if ((System.IO.File.Exists(filePath)))
                        {
                            System.IO.File.Delete(filePath);
                        }
                    }
                    if (!string.IsNullOrEmpty(Message))
                    {
                        this.AddNotification("File uploaded failed. " + Message + listPONumber, NotificationType.ERROR);
                    }
                    else
                    {
                        this.AddNotification("File uploaded successfully.", NotificationType.SUCCESS);
                    }
                }
                catch (Exception ex)
                {
                    general.AddLogError("Upload Vehicle", ex.Message, ex.StackTrace);
                    this.AddNotification("File uploaded failed.", NotificationType.ERROR);
                    this.AddNotification("PONumber Tidak ditemukan", NotificationType.ERROR);
                    return(View("~/Views/Upload/Vehicle/Index.cshtml"));

                    throw ex;
                }
            }

            return(View("~/Views/Upload/Vehicle/Index.cshtml"));
        }