Exemple #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);
        }
Exemple #2
0
        public CUSTOMGR UpdateInvoiceCustGR(string poNumber, CUSTOMGR model)
        {
            var dc = new eprocdbDataContext();

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

            md.NOCHASIS_INPUT           = model.NOCHASIS_INPUT;
            md.NOENGINE_INPUT           = model.NOENGINE_INPUT;
            md.ACTUALRECEIVEDUNITINBDEL = model.ACTUALRECEIVEDUNITINBDEL;
            md.MODIFIED_BY   = model.MODIFIED_BY;
            md.MODIFIED_DATE = model.MODIFIED_DATE;
            dc.SubmitChanges();
            UpdateStatus(poNumber);
            return(model);
        }
Exemple #3
0
        public CUSTOMGR UpdateInvoiceCustGR(string poNumber, CUSTOMGR model)
        {
            var dc = new eprocdbDataContext();

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

            if (md != null)
            {
                md.STATUSDELIVERYUNIT = model.STATUSDELIVERYUNIT;
                md.MODIFIED_BY        = model.MODIFIED_BY;
                md.MODIFIED_DATE      = model.MODIFIED_DATE;
                dc.SubmitChanges();
                UpdateStatus(poNumber);
            }
            return(model);
        }
Exemple #4
0
        public CUSTOMGR UpdateDeliveryCustGR(string poNumber, CUSTOMGR model)
        {
            var dc = new eprocdbDataContext();

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

            if (md != null)
            {
                md.NOCHASIS_INPUT = model.NOCHASIS_INPUT;
                md.NOENGINE_INPUT = model.NOENGINE_INPUT;
                md.MODIFIED_BY    = model.MODIFIED_BY;
                md.MODIFIED_DATE  = model.MODIFIED_DATE;
                dc.SubmitChanges();
                UpdateStatus(poNumber);
            }
            return(model);
        }
Exemple #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);
        }
Exemple #6
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);
        }
Exemple #7
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));
        }