Example #1
0
		private void Upload()
		{
            GLATransaction clsTransactionGLA = new GLATransaction();

            try
            {
                string BatchID = string.Empty;

                List<HttpPostedFile> pfiles = new List<HttpPostedFile>();
                List<string> pfilesName = new List<string>();

                for (int i = 0; i < Request.Files.Count; i++)
                {
                    HttpPostedFile file = Request.Files[i];
                    if (file.ContentLength > 0)
                    {
                        pfiles.Add(file); pfilesName.Add(System.IO.Path.GetFileName(file.FileName.ToLower()));
                    }
                }

                Label1.Text = "";

                #region checking

                // Label1.Text += "Files to upload:";
                //Label1.Text += "      "
                if (pfilesName.IndexOf(Constants.GLA_file_batch_id) < 0)
                    Label1.Text += "<br /><br /><b><font class='ms-error'>Please include the batch file in the upload. Filename: " + Constants.GLA_file_batch_id + "</font></b><br />";
                if (pfilesName.IndexOf(Constants.GLA_file_d_dsc_def) < 0)
                    Label1.Text += "<br /><br /><b><font class='ms-error'>Please include the discount file in the upload. Filename: " + Constants.GLA_file_d_dsc_def + "</font></b><br />";
                if (pfilesName.IndexOf(Constants.GLA_file_d_emp_def) < 0)
                    Label1.Text += "<br /><br /><b><font class='ms-error'>Please include the employees file in the upload. Filename: " + Constants.GLA_file_d_emp_def + "</font></b><br />";
                if (pfilesName.IndexOf(Constants.GLA_file_d_location_def) < 0)
                    Label1.Text += "<br /><br /><b><font class='ms-error'>Please include the location file in the upload. Filename: " + Constants.GLA_file_d_location_def + "</font></b><br />";
                //do not check the item. it's ok not to upload the item
                //if (pfilesName.IndexOf(Constants.GLA_file_d_mi_def) < 0)
                //    Label1.Text += "<br /><br /><b><font class='ms-error'>Please include the menu items file in the upload. Filename: " + Constants.GLA_file_d_mi_def + "</font></b><br />";
                if (pfilesName.IndexOf(Constants.GLA_file_d_svc_def) < 0)
                    Label1.Text += "<br /><br /><b><font class='ms-error'>Please include the service charge file in the upload. Filename: " + Constants.GLA_file_d_svc_def + "</font></b><br />";
                if (pfilesName.IndexOf(Constants.GLA_file_d_tmd_def) < 0)
                    Label1.Text += "<br /><br /><b><font class='ms-error'>Please include the tender definitions file in the upload. Filename: " + Constants.GLA_file_d_tmd_def + "</font></b><br />";
                if (pfilesName.IndexOf(Constants.GLA_file_f_dtl_chk_dsc) < 0)
                    Label1.Text += "<br /><br /><b><font class='ms-error'>Please include the discount details file in the upload. Filename: " + Constants.GLA_file_f_dtl_chk_dsc + "</font></b><br />";
                if (pfilesName.IndexOf(Constants.GLA_file_f_dtl_chk_headers) < 0)
                    Label1.Text += "<br /><br /><b><font class='ms-error'>Please include the check information file in the upload. Filename: " + Constants.GLA_file_f_dtl_chk_headers + "</font></b><br />";
                if (pfilesName.IndexOf(Constants.GLA_file_f_dtl_chk_svc) < 0)
                    Label1.Text += "<br /><br /><b><font class='ms-error'>Please include the service charge file in the upload. Filename: " + Constants.GLA_file_f_dtl_chk_svc + "</font></b><br />";
                if (pfilesName.IndexOf(Constants.GLA_file_f_dtl_chk_tmd) < 0)
                    Label1.Text += "<br /><br /><b><font class='ms-error'>Please include the tender detail file in the upload. Filename: " + Constants.GLA_file_f_dtl_chk_tmd + "</font></b><br />";
                //if (pfilesName.IndexOf(Constants.GLA_file_otntender) < 0)
                //    Label1.Text += "<br /><br /><b><font class='ms-error'>Please include the OTN_Tender file in the upload. Filename: " + Constants.GLA_file_otntender + "</font></b><br />";
                #endregion

                if (!string.IsNullOrEmpty(Label1.Text)) return;

                string strfile = "";
                string strfolder = "/RetailPlus/temp/uploaded/gla/";
                Security.AccessUserDetails clsAccessUserDetails = (Security.AccessUserDetails)Session["AccessUserDetails"];
                DateTime DateCreated = DateTime.Now;
                int iTranCount = 0;

                #region Constants.GLA_file_batch
                if (1==1)    //process batchfile
                {
                    strfile = Server.MapPath(strfolder + Constants.GLA_file_batch_id);

                    if (System.IO.File.Exists(strfile))
                        System.IO.File.Delete(strfile);

                    pfiles[pfilesName.IndexOf(Constants.GLA_file_batch_id)].SaveAs(strfile);

                    using (var reader = new StreamReader(strfile))
                    {
                        string line;
                        while ((line = reader.ReadLine()) != null)
                        {
                            //get the firstline as the batchid
                            BatchID = line;
                            break;
                        }
                    }
                }

                if (string.IsNullOrEmpty(BatchID))
                {
                    Label1.Text += "<br /><br /><b><font class='ms-error'>Cannot get any information from batch file. Please double check the batch file: " + Constants.GLA_file_batch_id + "</font></b><br />";
                    return;
                }

                Label1.Text += "<br /><br /><b><font class='ms-error'>Uploading Batch ID: " + BatchID + "</font></b><br />";
                #endregion

                #region saveallfiles

                // delete the temporary batch file
                if (System.IO.File.Exists(strfile))
                    System.IO.File.Delete(strfile);

                // save it again in a folder
                strfolder = strfolder + BatchID + "/";

                foreach (HttpPostedFile pfile in pfiles)
                {
                    strfile = Server.MapPath(strfolder + System.IO.Path.GetFileName(pfile.FileName));

                    if (!System.IO.Directory.Exists(Server.MapPath(strfolder)))
                        System.IO.Directory.CreateDirectory(Server.MapPath(strfolder));
                    
                    if (System.IO.File.Exists(strfile))
                        System.IO.File.Delete(strfile);

                    pfile.SaveAs(strfile);
                }

                //pfiles[pfilesName.IndexOf(Constants.GLA_file_batch)].SaveAs(strfile);
                //pfiles[pfilesName.IndexOf(Constants.GLA_file_batch)].SaveAs(strfile + Constants.GLA_file_batch);

                #endregion

                #region GLA_file_d_dsc_def
                /***** upload the transaction *****/
                Label1.Text += "Processing " + Constants.GLA_file_d_dsc_def + " ...";
                strfile = Server.MapPath(strfolder + System.IO.Path.GetFileName(Constants.GLA_file_d_dsc_def));

                IList<GLADiscountDetails> lstGLADiscountDetails = new List<GLADiscountDetails>();
                GLADiscountDetails clsGLADiscountDetails = new GLADiscountDetails();
                iTranCount = 0;
                using (var reader = new StreamReader(strfile))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        clsGLADiscountDetails = setDscDetails(line, DateCreated, clsAccessUserDetails.Name, Constants.GLA_file_d_dsc_def, BatchID);
                        lstGLADiscountDetails.Add(clsGLADiscountDetails);

                        iTranCount++;
                    }
                }

                GLADiscount clsGLADiscount = new GLADiscount(clsTransactionGLA.Connection, clsTransactionGLA.Transaction);
                clsGLADiscount.Delete(BatchID);
                foreach (GLADiscountDetails det in lstGLADiscountDetails)
                {
                    clsGLADiscount.Insert(det);
                }
                Label1.Text += "      <b><font class='ms-error'>" + lstGLADiscountDetails.Count.ToString() + " has been successfully uploaded...</font></b><br />";
                
                #endregion

                #region GLA_file_d_emp_def
                /***** upload the transaction *****/
                Label1.Text += "Processing " + Constants.GLA_file_d_emp_def + " ...";
                strfile = Server.MapPath(strfolder + System.IO.Path.GetFileName(Constants.GLA_file_d_emp_def));

                IList<GLAEmployeeDetails> lstGLAEmployeeDetails = new List<GLAEmployeeDetails>();
                GLAEmployeeDetails clsGLAEmployeeDetails = new GLAEmployeeDetails();
                iTranCount = 0;
                using (var reader = new StreamReader(strfile))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        clsGLAEmployeeDetails = setEmpDetails(line, DateCreated, clsAccessUserDetails.Name, Constants.GLA_file_d_emp_def, BatchID);
                        lstGLAEmployeeDetails.Add(clsGLAEmployeeDetails);

                        iTranCount++;
                    }
                }

                GLAEmployee clsGLAEmployee = new GLAEmployee(clsTransactionGLA.Connection, clsTransactionGLA.Transaction);
                clsGLAEmployee.Delete(BatchID);
                foreach (GLAEmployeeDetails det in lstGLAEmployeeDetails)
                {
                    clsGLAEmployee.Insert(det);
                }
                Label1.Text += "      <b><font class='ms-error'>" + lstGLAEmployeeDetails.Count.ToString() + " has been successfully uploaded...</font></b><br />";
                /***** upload the discount end *****/
                #endregion

                #region GLA_file_d_location_def
                /***** upload the transaction *****/
                Label1.Text += "Processing " + Constants.GLA_file_d_location_def + " ...";
                strfile = Server.MapPath(strfolder + System.IO.Path.GetFileName(Constants.GLA_file_d_location_def));

                IList<GLALocationDetails> lstGLALocationDetails = new List<GLALocationDetails>();
                GLALocationDetails clsGLALocationDetails = new GLALocationDetails();
                iTranCount = 0;
                using (var reader = new StreamReader(strfile))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        clsGLALocationDetails = setLocDetails(line, DateCreated, clsAccessUserDetails.Name, Constants.GLA_file_d_location_def, BatchID);
                        lstGLALocationDetails.Add(clsGLALocationDetails);

                        iTranCount++;
                    }
                }

                GLALocation clsGLALocation = new GLALocation(clsTransactionGLA.Connection, clsTransactionGLA.Transaction);
                clsGLALocation.Delete(BatchID);
                foreach (GLALocationDetails det in lstGLALocationDetails)
                {
                    clsGLALocation.Insert(det);
                }
                Label1.Text += "      <b><font class='ms-error'>" + lstGLALocationDetails.Count.ToString() + " has been successfully uploaded...</font></b><br />";
                /***** upload the discount end *****/
                #endregion

                #region GLA_file_d_mi_def
                /***** upload the transaction *****/
                if (pfilesName.IndexOf(Constants.GLA_file_d_mi_def) >= 0)
                {
                    Label1.Text += "Processing " + Constants.GLA_file_d_mi_def + " ...";
                    strfile = Server.MapPath(strfolder + System.IO.Path.GetFileName(Constants.GLA_file_d_mi_def));

                    IList<GLAItemDetails> lstGLAItemDetails = new List<GLAItemDetails>();
                    GLAItemDetails clsGLAItemDetails = new GLAItemDetails();
                    iTranCount = 0;
                    using (var reader = new StreamReader(strfile))
                    {
                        string line;
                        while ((line = reader.ReadLine()) != null)
                        {
                            clsGLAItemDetails = setItemDetails(line, DateCreated, clsAccessUserDetails.Name, Constants.GLA_file_d_mi_def, BatchID);
                            lstGLAItemDetails.Add(clsGLAItemDetails);

                            iTranCount++;
                        }
                    }

                    if (lstGLAItemDetails.Count > 0)
                    {
                        GLAItem clsGLAItem = new GLAItem(clsTransactionGLA.Connection, clsTransactionGLA.Transaction);
                        clsGLAItem.Delete(BatchID);
                        foreach (GLAItemDetails det in lstGLAItemDetails)
                        {
                            clsGLAItem.Insert(det);
                        }
                    }
                    Label1.Text += "      <b><font class='ms-error'>" + lstGLAItemDetails.Count.ToString() + " has been successfully uploaded...</font></b><br />";
                }
                /***** upload the discount end *****/
                #endregion

                #region GLA_file_d_svc_def
                /***** upload the transaction *****/
                Label1.Text += "Processing " + Constants.GLA_file_d_svc_def + " ...";
                strfile = Server.MapPath(strfolder + System.IO.Path.GetFileName(Constants.GLA_file_d_svc_def));

                IList<GLAServiceChargeDetails> lstGLAServiceChargeDetails = new List<GLAServiceChargeDetails>();
                GLAServiceChargeDetails clsGLAServiceChargeDetailss = new GLAServiceChargeDetails();
                iTranCount = 0;
                using (var reader = new StreamReader(strfile))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        clsGLAServiceChargeDetailss = setSvcDetails(line, DateCreated, clsAccessUserDetails.Name, Constants.GLA_file_d_svc_def, BatchID);
                        lstGLAServiceChargeDetails.Add(clsGLAServiceChargeDetailss);

                        iTranCount++;
                    }
                }

                GLAServiceCharge clsGLAServiceCharge = new GLAServiceCharge(clsTransactionGLA.Connection, clsTransactionGLA.Transaction);
                clsGLAServiceCharge.Delete(BatchID);
                foreach (GLAServiceChargeDetails det in lstGLAServiceChargeDetails)
                {
                    clsGLAServiceCharge.Insert(det);
                }
                Label1.Text += "      <b><font class='ms-error'>" + lstGLAServiceChargeDetails.Count.ToString() + " has been successfully uploaded...</font></b><br />";
                /***** upload the discount end *****/
                #endregion

                #region GLA_file_d_tmd_def
                /***** upload the tenders *****/
                Label1.Text += "Processing " + Constants.GLA_file_d_tmd_def + " ...";
                strfile = Server.MapPath(strfolder + System.IO.Path.GetFileName(Constants.GLA_file_d_tmd_def));

                IList<GLATenderDetails> lstGLATenderDetails = new List<GLATenderDetails>();
                GLATenderDetails clsGLATenderDetails = new GLATenderDetails();
                iTranCount = 0;
                using (var reader = new StreamReader(strfile))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        clsGLATenderDetails = setTenderDetails(line, DateCreated, clsAccessUserDetails.Name, Constants.GLA_file_d_tmd_def, BatchID);
                        lstGLATenderDetails.Add(clsGLATenderDetails);

                        iTranCount++;
                    }
                }

                GLATender clsGLATender = new GLATender(clsTransactionGLA.Connection, clsTransactionGLA.Transaction);
                clsGLATender.Delete(BatchID);
                foreach (GLATenderDetails det in lstGLATenderDetails)
                {
                    clsGLATender.Insert(det);
                }
                Label1.Text += "      <b><font class='ms-error'>" + lstGLATenderDetails.Count.ToString() + " has been successfully uploaded...</font></b><br />";
                
                /***** upload the discount end *****/
                #endregion

                #region GLA_file_f_dtl_chk_dsc
                /***** upload the transaction *****/
                Label1.Text += "Processing " + Constants.GLA_file_f_dtl_chk_dsc + " ...";
                strfile = Server.MapPath(strfolder + System.IO.Path.GetFileName(Constants.GLA_file_f_dtl_chk_dsc));

                IList<GLATransactionDiscountDetails> lstGLATransactionDiscountDetails = new List<GLATransactionDiscountDetails>();
                IList<GLATransactionDiscountDetails> lstGLATransactionDiscountDetailsContactCode = new List<GLATransactionDiscountDetails>();
                GLATransactionDiscountDetails clsGLATransactionDiscountDetails = new GLATransactionDiscountDetails();
                iTranCount = 0;
                using (var reader = new StreamReader(strfile))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        clsGLATransactionDiscountDetails = setTranDscDetails(line, DateCreated, clsAccessUserDetails.Name, Constants.GLA_file_f_dtl_chk_dsc, BatchID);
                        lstGLATransactionDiscountDetails.Add(clsGLATransactionDiscountDetails);

                        if (!string.IsNullOrEmpty(clsGLATransactionDiscountDetails.ContactCode)) lstGLATransactionDiscountDetailsContactCode.Add(clsGLATransactionDiscountDetails);
                        iTranCount++;
                    }
                }

                GLATransactionDiscount clsGLATransactionDiscount = new GLATransactionDiscount(clsTransactionGLA.Connection, clsTransactionGLA.Transaction);
                clsGLADiscount.Delete(BatchID);
                foreach (GLATransactionDiscountDetails det in lstGLATransactionDiscountDetails)
                {
                    clsGLATransactionDiscount.Insert(det);
                }
                Label1.Text += "      <b><font class='ms-error'>" + lstGLATransactionDiscountDetails.Count.ToString() + " has been successfully uploaded...</font></b><br />";
                /***** upload the discount end *****/
                #endregion

                #region GLA_file_f_dtl_chk_headers
                /***** upload the transaction *****/
                Label1.Text += "Processing " + Constants.GLA_file_f_dtl_chk_headers + " ...";
                strfile = Server.MapPath(strfolder + System.IO.Path.GetFileName(Constants.GLA_file_f_dtl_chk_headers));

                List<GLATransactionDetails> lstGLATransactionDetails = new List<GLATransactionDetails>();
                GLATransactionDetails clsGLATransactionDetails = new GLATransactionDetails();
                iTranCount = 0;
                using (var reader = new StreamReader(strfile))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        clsGLATransactionDetails = setTranHdrDetails(line, DateCreated, clsAccessUserDetails.Name, Constants.GLA_file_f_dtl_chk_headers, BatchID);
                        lstGLATransactionDetails.Add(clsGLATransactionDetails);

                        iTranCount++;
                    }
                }
                GLATransaction clsGLATransaction = new GLATransaction(clsTransactionGLA.Connection, clsTransactionGLA.Transaction);
                clsGLATransaction.Delete(BatchID);
                foreach (GLATransactionDetails det in lstGLATransactionDetails)
                {
                    clsGLATransaction.Insert(det);
                }
                Label1.Text += "      <b><font class='ms-error'>" + lstGLATransactionDetails.Count.ToString() + " has been successfully uploaded...</font></b><br />";
                /***** upload the transaction end *****/
                #endregion

                #region GLA_file_f_dtl_chk_mi
                /***** upload the transaction *****/
                Label1.Text += "Processing " + Constants.GLA_file_f_dtl_chk_mi + " ...";
                strfile = Server.MapPath(strfolder + System.IO.Path.GetFileName(Constants.GLA_file_f_dtl_chk_mi));

                IList<GLATransactionItemDetails> lstGLATransactionItemDetails = new List<GLATransactionItemDetails>();
                IList<GLATransactionItemDetails> lstGLATransactionItemDetailsContactCode = new List<GLATransactionItemDetails>();
                GLATransactionItemDetails clsGLATransactionItemDetails = new GLATransactionItemDetails();
                iTranCount = 0;
                using (var reader = new StreamReader(strfile))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        clsGLATransactionItemDetails = setTranItemDetails(line, DateCreated, clsAccessUserDetails.Name, Constants.GLA_file_f_dtl_chk_mi, BatchID);
                        lstGLATransactionItemDetails.Add(clsGLATransactionItemDetails);
                        iTranCount++;
                    }
                }

                GLATransactionItem clsGLATransactionItem = new GLATransactionItem(clsTransactionGLA.Connection, clsTransactionGLA.Transaction);
                clsGLATransactionItem.Delete(BatchID);
                foreach (GLATransactionItemDetails det in lstGLATransactionItemDetails)
                {
                    clsGLATransactionItem.Insert(det);
                }
                Label1.Text += "      <b><font class='ms-error'>" + lstGLATransactionItemDetails.Count.ToString() + " has been successfully uploaded...</font></b><br />";
                /***** upload the discount end *****/
                #endregion

                #region GLA_file_f_dtl_chk_svc
                /***** upload the transaction *****/
                Label1.Text += "Processing " + Constants.GLA_file_f_dtl_chk_svc + " ...";
                strfile = Server.MapPath(strfolder + System.IO.Path.GetFileName(Constants.GLA_file_f_dtl_chk_svc));

                IList<GLATransactionSvcDetails> lstGLATransactionSvcDetails = new List<GLATransactionSvcDetails>();
                IList<GLATransactionSvcDetails> lstGLATransactionSvcDetailsContactCode = new List<GLATransactionSvcDetails>();
                GLATransactionSvcDetails clsGLATransactionSvcDetails = new GLATransactionSvcDetails();
                iTranCount = 0;
                using (var reader = new StreamReader(strfile))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        clsGLATransactionSvcDetails = setTranSvcDetails(line, DateCreated, clsAccessUserDetails.Name, Constants.GLA_file_f_dtl_chk_svc, BatchID);
                        lstGLATransactionSvcDetails.Add(clsGLATransactionSvcDetails);
                        iTranCount++;
                    }
                }

                GLATransactionSvc clsGLATransactionSvc = new GLATransactionSvc(clsTransactionGLA.Connection, clsTransactionGLA.Transaction);
                clsGLATransactionSvc.Delete(BatchID);
                foreach (GLATransactionSvcDetails det in lstGLATransactionSvcDetails)
                {
                    clsGLATransactionSvc.Insert(det);
                }
                Label1.Text += "      <b><font class='ms-error'>" + lstGLATransactionSvcDetails.Count.ToString() + " has been successfully uploaded...</font></b><br />";
                /***** upload the discount end *****/
                #endregion

                #region GLA_file_f_dtl_chk_tmd
                /***** upload the transaction *****/
                Label1.Text += "Processing " + Constants.GLA_file_f_dtl_chk_tmd + " ...";
                strfile = Server.MapPath(strfolder + System.IO.Path.GetFileName(Constants.GLA_file_f_dtl_chk_tmd));

                IList<GLATransactionTenderDetails> lstGLATransactionTenderDetails = new List<GLATransactionTenderDetails>();
                IList<GLATransactionTenderDetails> lstGLATransactionTenderDetailsContactCode = new List<GLATransactionTenderDetails>();
                GLATransactionTenderDetails clsGLATransactionTenderDetails = new GLATransactionTenderDetails();
                iTranCount = 0;
                using (var reader = new StreamReader(strfile))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        clsGLATransactionTenderDetails = setTranTenderDetails(line, DateCreated, clsAccessUserDetails.Name, Constants.GLA_file_f_dtl_chk_tmd, BatchID);
                        lstGLATransactionTenderDetails.Add(clsGLATransactionTenderDetails);
                        iTranCount++;
                    }
                }

                GLATransactionTender clsGLATransactionTender = new GLATransactionTender(clsTransactionGLA.Connection, clsTransactionGLA.Transaction);
                clsGLATransactionTender.Delete(BatchID);
                foreach (GLATransactionTenderDetails det in lstGLATransactionTenderDetails)
                {
                    clsGLATransactionTender.Insert(det);
                }
                Label1.Text += "      <b><font class='ms-error'>" + lstGLATransactionTenderDetails.Count.ToString() + " has been successfully uploaded...</font></b><br />";
                /***** upload the discount end *****/
                #endregion

                #region clsTransaction

                Label1.Text += "Processing transactions by members... ";

                Data.SalesTransactions clsTransaction = new SalesTransactions(clsTransactionGLA.Connection, clsTransactionGLA.Transaction);
                clsTransaction.DeleteByDataSource(BatchID);
                clsTransactionGLA.ProcessBatch(BatchID);

                Label1.Text += "      <b><font class='ms-error'>" + lstGLATransactionDiscountDetailsContactCode.Count.ToString() + " has been successfully uploaded...</font></b><br />";
                
                #endregion

                #region GLA_file_otntender
                ///***** upload the otn tender *****/
                //Label1.Text += "Processing " + Constants.GLA_file_otntender + " ...";
                //strfile = Server.MapPath(strfolder + System.IO.Path.GetFileName(Constants.GLA_file_otntender));

                //List<OrderTenderGLADetails> lstOrderTenderGLADetails = new List<OrderTenderGLADetails>();
                //OrderTenderGLADetails clsOrderTenderGLADetails = new OrderTenderGLADetails();
                //iTranCount = 0;
                //using (var reader = new StreamReader(strfile))
                //{
                //    string line;
                //    while ((line = reader.ReadLine()) != null)
                //    {
                //        clsOrderTenderGLADetails = setOrderTenderDetails(line, DateCreated, clsAccessUserDetails.Name, Constants.GLA_file_otntender, BatchID);
                //        lstOrderTenderGLADetails.Add(clsOrderTenderGLADetails);

                //        iTranCount++;
                //    }
                //}

                //OrderTenderGLA clsOrderTenderGLA = new OrderTenderGLA(clsTransactionGLA.Connection, clsTransactionGLA.Transaction);

                //Data.Contacts clsContacts = new Contacts(clsTransactionGLA.Connection, clsTransactionGLA.Transaction);
                //Data.ContactDetails clsContactDetails = new ContactDetails();

                //foreach (OrderTenderGLADetails det in lstOrderTenderGLADetails)
                //{

                //    clsOrderTenderGLA.Insert(det);
                //    clsSalesTransactionDetails = clsTransaction.Details(det.tender_seq.ToString(), Constants.C_DEFAULT_TERMINAL_01, Constants.BRANCH_ID_MAIN);
                        
                //    // update the customer information
                //    clsSalesTransactionDetails = setSalesTransactionDetails(det, clsSalesTransactionDetails);
                //    clsContactDetails = clsContacts.Details(det.auth_acct_no);

                //    clsTransaction.UpdateContact(clsSalesTransactionDetails.TransactionID, clsSalesTransactionDetails.TransactionDate, clsContactDetails);
                        
                //    //clsTransaction.Close(clsSalesTransactionDetails.TransactionID, clsSalesTransactionDetails.SubTotal, clsSalesTransactionDetails.ItemsDiscount, clsSalesTransactionDetails.Discount, clsSalesTransactionDetails.TransDiscount, clsSalesTransactionDetails.TransDiscountType, clsSalesTransactionDetails.VAT, clsSalesTransactionDetails.VatableAmount, clsSalesTransactionDetails.EVAT, clsSalesTransactionDetails.EVatableAmount, clsSalesTransactionDetails.LocalTax, clsSalesTransactionDetails.AmountPaid, clsSalesTransactionDetails.CashPayment, clsSalesTransactionDetails.ChequePayment, clsSalesTransactionDetails.CreditCardPayment, clsSalesTransactionDetails.CreditPayment, clsSalesTransactionDetails.DebitPayment, clsSalesTransactionDetails.RewardPointsPayment, clsSalesTransactionDetails.RewardConvertedPayment, clsSalesTransactionDetails.BalanceAmount, clsSalesTransactionDetails.ChangeAmount, clsSalesTransactionDetails.PaymentType, clsSalesTransactionDetails.DiscountCode, clsSalesTransactionDetails.DiscountRemarks, clsSalesTransactionDetails.Charge, clsSalesTransactionDetails.ChargeAmount, clsSalesTransactionDetails.ChargeCode, clsSalesTransactionDetails.ChargeRemarks, clsSalesTransactionDetails.CashierID, clsSalesTransactionDetails.CashierName);
                //    //clsTransaction.UpdateDateClosed(clsSalesTransactionDetails.TransactionID, clsSalesTransactionDetails.DateClosed);
                //}

                //Label1.Text += "      <b><font class='ms-error'>" + lstOrderTenderGLADetails.Count.ToString() + " has been successfully uploaded...</font></b><br />";
                #endregion

                clsTransactionGLA.CommitAndDispose();
            }
            catch (Exception ex){
                clsTransactionGLA.ThrowException(ex);
                throw ex;
            }
		}
Example #2
0
        public Int64 Insert(GLAEmployeeDetails Details)
		{
			try  
			{
                string SQL = "INSERT INTO tblgla_d_emp_def (" +
                                    "Emp_Number," +
                                    "First_Name," +
                                    "Last_Name," +
                                    "Class_Number," +
                                    "Class_Name," +
                                    "DateCreated," +
                                    "CreatedBy," +
                                    "Filename," +
                                    "BatchID" +
								") VALUES (" +
                                    "@Emp_Number," +
                                    "@First_Name," +
                                    "@Last_Name," +
                                    "@Class_Number," +
                                    "@Class_Name," +
                                    "@DateCreated," +
                                    "@CreatedBy," +
                                    "@Filename," +
                                    "@BatchID);";
	 			
				MySqlCommand cmd = new MySqlCommand();
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;

                cmd.Parameters.AddWithValue("@Emp_Number", Details.Emp_Number);
                cmd.Parameters.AddWithValue("@First_Name", Details.First_Name);
                cmd.Parameters.AddWithValue("@Last_Name", Details.Last_Name);
                cmd.Parameters.AddWithValue("@Class_Number", Details.Class_Number);
                cmd.Parameters.AddWithValue("@Class_Name", Details.Class_Name);
                cmd.Parameters.AddWithValue("@DateCreated", Details.DateCreated);
                cmd.Parameters.AddWithValue("@CreatedBy", Details.CreatedBy);
                cmd.Parameters.AddWithValue("@Filename", Details.Filename);
                cmd.Parameters.AddWithValue("@BatchID", Details.BatchID);

				base.ExecuteNonQuery(cmd);

				SQL = "SELECT LAST_INSERT_ID();";
				
				cmd.Parameters.Clear(); 
				cmd.CommandText = SQL;

                System.Data.DataTable dt = new System.Data.DataTable("LAST_INSERT_ID");
                base.MySqlDataAdapterFill(cmd, dt);
                
                Int64 iID = 0;
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    iID = Int64.Parse(dr[0].ToString());
                }

				return iID;
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
Example #3
0
        private GLAEmployeeDetails setEmpDetails(string line, DateTime DateCreated, string CreatedBy, string filename, string BatchID)
        {
            DateTime dteRetvalue = Constants.C_DATE_MIN_VALUE;
            //int intRetValue = 0;
            //decimal decRetValue = 0;
            long lngRetValue = 0;

            GLAEmployeeDetails clsDetails = new GLAEmployeeDetails();

            int iCol = 0;
            foreach (string col in line.Split(','))
            {
                dteRetvalue = Constants.C_DATE_MIN_VALUE;
                //intRetValue = 0;

                switch (iCol)
                {
                    case 0: clsDetails.Emp_Number = long.TryParse(col, out lngRetValue) ? lngRetValue : 0; break;
                    case 1: clsDetails.First_Name = col; break;
                    case 2: clsDetails.Last_Name = col; break;
                    case 3: clsDetails.Class_Number = long.TryParse(col, out lngRetValue) ? lngRetValue : 0; break;
                    case 4: clsDetails.Class_Name = col; break;
                }
                iCol++;
            }
            clsDetails.DateCreated = DateCreated;
            clsDetails.CreatedBy = CreatedBy;
            clsDetails.Filename = filename;
            clsDetails.BatchID = BatchID;

            return clsDetails;
        }
Example #4
0
        public Int64 Insert(GLAEmployeeDetails Details)
        {
            try
            {
                string SQL = "INSERT INTO tblgla_d_emp_def (" +
                             "Emp_Number," +
                             "First_Name," +
                             "Last_Name," +
                             "Class_Number," +
                             "Class_Name," +
                             "DateCreated," +
                             "CreatedBy," +
                             "Filename," +
                             "BatchID" +
                             ") VALUES (" +
                             "@Emp_Number," +
                             "@First_Name," +
                             "@Last_Name," +
                             "@Class_Number," +
                             "@Class_Name," +
                             "@DateCreated," +
                             "@CreatedBy," +
                             "@Filename," +
                             "@BatchID);";

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                cmd.Parameters.AddWithValue("@Emp_Number", Details.Emp_Number);
                cmd.Parameters.AddWithValue("@First_Name", Details.First_Name);
                cmd.Parameters.AddWithValue("@Last_Name", Details.Last_Name);
                cmd.Parameters.AddWithValue("@Class_Number", Details.Class_Number);
                cmd.Parameters.AddWithValue("@Class_Name", Details.Class_Name);
                cmd.Parameters.AddWithValue("@DateCreated", Details.DateCreated);
                cmd.Parameters.AddWithValue("@CreatedBy", Details.CreatedBy);
                cmd.Parameters.AddWithValue("@Filename", Details.Filename);
                cmd.Parameters.AddWithValue("@BatchID", Details.BatchID);

                base.ExecuteNonQuery(cmd);

                SQL = "SELECT LAST_INSERT_ID();";

                cmd.Parameters.Clear();
                cmd.CommandText = SQL;

                System.Data.DataTable dt = new System.Data.DataTable("LAST_INSERT_ID");
                base.MySqlDataAdapterFill(cmd, dt);

                Int64 iID = 0;
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    iID = Int64.Parse(dr[0].ToString());
                }

                return(iID);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }