예제 #1
0
        private void cmdGenerateCustomerCode_Click(object sender, EventArgs e)
        {
            Data.ERPConfig clsERPConfig = new Data.ERPConfig();
            BarcodeHelper  ean13        = new BarcodeHelper(BarcodeHelper.CustomerCode_Country_Code, BarcodeHelper.CustomerCode_ManufacturerCode, clsERPConfig.get_LastCustomerCode());

            txtContactCode.Text = ean13.CountryCode + ean13.ManufacturerCode + ean13.ProductCode + ean13.ChecksumDigit;
            clsERPConfig.CommitAndDispose();
        }
예제 #2
0
        private void LoadOption()
        {
            cboTerms.Items.Clear();
            foreach (string str in Enum.GetNames(typeof(ModeOfTerms)))
            {
                cboTerms.Items.Add(str);
            }
            cboTerms.SelectedIndex = 0;

            Data.Salutation clsSalutation = new Data.Salutation();
            System.Data.DataTable dt = clsSalutation.ListAsDataTable();
            clsSalutation.CommitAndDispose();

            cboSalutation.ValueMember = "SalutationCode";
            cboSalutation.DisplayMember = "SalutationName";
            cboSalutation.DataSource = dt.DefaultView;
            cboSalutation.SelectedIndex = 0;
            cboSalutation.SelectedValue = "MR";

            System.Data.DataTable dtSex = new System.Data.DataTable("Sex");
            dtSex.Columns.Add("SexCode"); dtSex.Columns.Add("SexName");

            dtSex.Rows.Add("Male", "Male");
            dtSex.Rows.Add("Female", "Female");

            cboSex.ValueMember = "SexCode";
            cboSex.DisplayMember = "SexName";
            cboSex.DataSource = dtSex.DefaultView;
            cboSex.SelectedIndex = 0;
            cboSex.SelectedValue = "Male";

            if (mContactDetails.ContactID != 0)
            {
                //txtContactCode.Enabled = false;
                txtContactCode.Text = mContactDetails.ContactCode;
                txtAddress.Text = mContactDetails.Address;
                txtTelephoneNo.Text = mContactDetails.TelephoneNo;
                txtRemarks.Text = mContactDetails.Remarks;
                txtTelephoneNo.Tag = mContactDetails.TINNo;
                txtRemarks.Tag = mContactDetails.LTONo;

                // 18Jun2013 : For credit information
                txtCreditLimit.Text = mContactDetails.CreditLimit.ToString("#,##0.#0");
                txtCredit.Text = mContactDetails.Credit.ToString("#,##0.#0");
                txtAvailableCredit.Text = (mContactDetails.CreditLimit - mContactDetails.Credit).ToString("#,##0.#0");
                txtTerms.Text = mContactDetails.Terms.ToString("#,##0");
                cboTerms.SelectedIndex = int.Parse(mContactDetails.ModeOfTerms.ToString("d"));
                chkIsCreditAllowed.Checked = mContactDetails.IsCreditAllowed;

                if (!string.IsNullOrEmpty(mContactDetails.AdditionalDetails.Salutation))
                {
                    cboSalutation.SelectedValue = mContactDetails.AdditionalDetails.Salutation;
                    txtFirstName.Text = mContactDetails.AdditionalDetails.FirstName;
                    txtMiddleName.Text = mContactDetails.AdditionalDetails.MiddleName;
                    txtLastName.Text = mContactDetails.AdditionalDetails.LastName;
                    txtBirthDate.Text = mContactDetails.AdditionalDetails.BirthDate.ToString("yyyy-MM-dd");
                    txtMobileNo.Text = mContactDetails.AdditionalDetails.MobileNo;

                    cboSex.SelectedValue = mContactDetails.AdditionalDetails.Sex.ToString("G");
                    txtAttendingPhysician.Text = mContactDetails.AdditionalDetails.AttendingPhysician;
                }
            }
            else if (mContactDetails.ContactID == 0)
            {
                Data.ERPConfig clsERPConfig = new Data.ERPConfig();
                BarcodeHelper ean13 = new BarcodeHelper(BarcodeHelper.CustomerCode_Country_Code, BarcodeHelper.CustomerCode_ManufacturerCode, clsERPConfig.get_LastCustomerCode());
                txtContactCode.Text = ean13.CountryCode + ean13.ManufacturerCode + ean13.ProductCode + ean13.ChecksumDigit;
                clsERPConfig.CommitAndDispose();

                if (mstCaption == "Please enter customer name for deposit.")
                { txtRemarks.Text = Data.Contacts.DEFAULT_REMARKS_FOR_ADDED_FROM_DEPOSIT; }
                else if (mstCaption == "Quickly add new customer")
                { txtRemarks.Text = Data.Contacts.DEFAULT_REMARKS_FOR_QUICKLY_ADDED_FROM_FE; }
                else if (mContactDetails.ContactID == 0) // means not edit
                { txtRemarks.Text = Data.Contacts.DEFAULT_REMARKS_FOR_ADDED_FROM_CLIENT; }
            }
        }
예제 #3
0
 private void cmdGenerateCustomerCode_Click(object sender, EventArgs e)
 {
     Data.ERPConfig clsERPConfig = new Data.ERPConfig();
     BarcodeHelper ean13 = new BarcodeHelper(BarcodeHelper.CustomerCode_Country_Code, BarcodeHelper.CustomerCode_ManufacturerCode, clsERPConfig.get_LastCustomerCode());
     txtContactCode.Text = ean13.CountryCode + ean13.ManufacturerCode + ean13.ProductCode + ean13.ChecksumDigit;
     clsERPConfig.CommitAndDispose();
 }
예제 #4
0
        private void LoadOption()
        {
            Data.Salutation clsSalutation = new Data.Salutation();
            System.Data.DataTable dt = clsSalutation.ListAsDataTable();
            clsSalutation.CommitAndDispose();

            cboSalutation.ValueMember = "SalutationCode";
            cboSalutation.DisplayMember = "SalutationName";
            cboSalutation.DataSource = dt.DefaultView;
            cboSalutation.SelectedIndex = 0;
            cboSalutation.SelectedValue = "MR";

            if (mContactDetails.ContactID != 0)
            {
                //txtContactCode.Enabled = false;
                txtContactCode.Text = mContactDetails.ContactCode;
                txtContactName.Text = mContactDetails.ContactName;
                txtAddress.Text = mContactDetails.Address;
                txtBusinessName.Text = mContactDetails.BusinessName;
                txtTelephoneNo.Text = mContactDetails.TelephoneNo;
                txtRemarks.Text = mContactDetails.Remarks;
                txtTelephoneNo.Tag = mContactDetails.TINNo;
                txtRemarks.Tag = mContactDetails.LTONo;

                //txtDebit.Text = mContactDetails.Debit.ToString("###0.#0");
                //chkIsCreditAllowed.Checked = mContactDetails.IsCreditAllowed;
                //cboDepartment.SelectedIndex = cboDepartment.Items.IndexOf(cboDepartment.Items.FindByValue(mContactDetails.DepartmentID.ToString()));
                //cboPosition.SelectedIndex = cboPosition.Items.IndexOf(cboPosition.Items.FindByValue(mContactDetails.PositionID.ToString()));

                //txtCreditCardNo.Text = mContactDetails.CreditDetails.CreditCardNo;
                //cboCreditCardType.SelectedIndex = cboCreditCardType.Items.IndexOf(cboCreditCardType.Items.FindByValue(mContactDetails.CreditDetails.CardTypeDetails.CardTypeID.ToString()));
                //txtCreditAwardDate.Text = mContactDetails.CreditDetails.CreditAwardDate.ToString("yyyy-MMM-dd");
                //txtExpiryDate.Text = mContactDetails.CreditDetails.ExpiryDate.ToString("yyyy-MMM-dd");
                //cboCreditCardStatus.SelectedIndex = cboCreditCardStatus.Items.IndexOf(cboCreditCardStatus.Items.FindByValue(mContactDetails.CreditDetails.CreditCardStatus.ToString("d")));
                //lblCreditCardActive.Text = mContactDetails.CreditDetails.CreditActive ? "Active" : "InActive (Hold/Suspended)";
                //txtCreditLimit.Text = mContactDetails.CreditLimit.ToString("###0.#0");
                //txtCredit.Text = mContactDetails.Credit.ToString("###0.#0");
                //txtPaidAmount.Text = "0.00";
                //txtCurrentBalance.Text = (mContactDetails.CreditLimit - mContactDetails.Credit).ToString("###0.#0");
                //lblLastBillingDate.Text = "Last Billing Date:" + mContactDetails.CreditDetails.LastBillingDate.ToString("yyyy-MMM-dd");

                if (!string.IsNullOrEmpty(mContactDetails.AdditionalDetails.Salutation))
                {
                    cboSalutation.SelectedValue = mContactDetails.AdditionalDetails.Salutation;
                    txtFirstName.Text = mContactDetails.AdditionalDetails.FirstName;
                    txtMiddleName.Text = mContactDetails.AdditionalDetails.MiddleName;
                    txtLastName.Text = mContactDetails.AdditionalDetails.LastName;
                    txtBirthDate.Text = mContactDetails.AdditionalDetails.BirthDate.ToString("yyyy-MM-dd");
                    txtMobileNo.Text = mContactDetails.AdditionalDetails.MobileNo;
                }
            }
            else if (mContactDetails.ContactID == 0)
            {
                Data.ERPConfig clsERPConfig = new Data.ERPConfig();
                BarcodeHelper ean13 = new BarcodeHelper(BarcodeHelper.CustomerCode_Country_Code, BarcodeHelper.CustomerCode_ManufacturerCode, clsERPConfig.get_LastCustomerCode());
                txtContactCode.Text = ean13.CountryCode + ean13.ManufacturerCode + ean13.ProductCode + ean13.ChecksumDigit;
                clsERPConfig.CommitAndDispose();

                if (mstCaption == "Please enter customer name for deposit.")
                { txtRemarks.Text = Data.Contacts.DEFAULT_REMARKS_FOR_ADDED_FROM_DEPOSIT; }
                else if (mstCaption == "Quickly add new customer")
                { txtRemarks.Text = Data.Contacts.DEFAULT_REMARKS_FOR_QUICKLY_ADDED_FROM_FE; }
                else if (mContactDetails.ContactID == 0) // means not edit
                { txtRemarks.Text = Data.Contacts.DEFAULT_REMARKS_FOR_ADDED_FROM_CLIENT; }
            }
        }
예제 #5
0
        private void SaveToDB()
        {
            AceSoft.RetailPlus.Client.MasterDB clsMasterConnection;
			Data.Products clsProducts;
            Data.Inventory clsInventory;
            Data.Database clsDatabase;

            Data.ERPConfig clsERPConfig = new Data.ERPConfig();
            Data.ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();
            string strReferenceNo = Constants.CLOSE_INVENTORY_CODE + CompanyDetails.BECompanyCode + DateTime.Now.Year.ToString() + clsERPConfig.get_LastClosingNo();
            clsERPConfig.CommitAndDispose();

            Data.ProductDetails clsProductDetails;
            Data.InventoryDetails clsInventoryDetails;

            DateTime dtePostingDate = DateTime.Now;

            if (!Directory.Exists("invfiles/backups/")) Directory.CreateDirectory("invfiles/backups/");
            if (File.Exists("invfiles/" + mclsBranchDetails.BranchCode + DateTime.Now.ToString("yyyyMMdd") + ".inv"))
            {
                if (MessageBox.Show("You have already loaded the inventory for this branch today. Please verify the file you are loading. Would you like to continue?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.No)
                {
                    bgwSavetoDB.ReportProgress(100);
                    return;
                }
            }
            else
            {
                System.IO.File.Copy("invfiles/" + mclsBranchDetails.BranchCode + ".inv", "invfiles/" + mclsBranchDetails.BranchCode + DateTime.Now.ToString("yyyyMMdd") + ".inv");
            }

            InvExLog clsInvExLog = new InvExLog();
            clsInvExLog.BranchDetails = mclsBranchDetails;
            if (File.Exists("invfiles/" + mclsBranchDetails.BranchCode + DateTime.Now.ToString("yyyyMMdd") + "_exc.inv"))
            {
                System.IO.File.Copy("invfiles/" + mclsBranchDetails.BranchCode + DateTime.Now.ToString("yyyyMMdd") + "_exc.inv", "invfiles/backups/" + mclsBranchDetails.BranchCode + DateTime.Now.ToString("yyyyMMdd") + "_exc.inv" + "_" + DateTime.Now.ToString("yyyyddMMhhmmss"));
                System.IO.File.Delete("invfiles/" + mclsBranchDetails.BranchCode + DateTime.Now.ToString("yyyyMMdd") + "_exc.inv");
            }

            InvLoadedLog clsInvLoadedLog = new InvLoadedLog();
            clsInvLoadedLog.BranchDetails = mclsBranchDetails;
            if (File.Exists("invfiles/" + mclsBranchDetails.BranchCode + DateTime.Now.ToString("yyyyMMdd") + "_saved.inv"))
            {
                System.IO.File.Copy("invfiles/" + mclsBranchDetails.BranchCode + DateTime.Now.ToString("yyyyMMdd") + "_saved.inv", "invfiles/backups/" + mclsBranchDetails.BranchCode + DateTime.Now.ToString("yyyyMMdd") + "_saved.inv" + "_" + DateTime.Now.ToString("yyyyddMMhhmmss"));
                System.IO.File.Delete("invfiles/" + mclsBranchDetails.BranchCode + DateTime.Now.ToString("yyyyMMdd") + "_saved.inv");
            }

            decimal iCtr = 1, iRows = Decimal.Parse(mdtItems.Rows.Count.ToString());
            foreach (System.Data.DataRow dr in mdtItems.Rows)
			{
                string strBarCode = dr["BarCode"].ToString();
                decimal decQuantity = decimal.Parse(dr["Quantity"].ToString());

                string strUnit = dr["Unit"].ToString();
                string strDescription = dr["Description"].ToString();

                mstStatus = "[" + iCtr.ToString() + "/" + iRows + "]Saving " + strBarCode + strDescription;
                bgwSavetoDB.ReportProgress(int.Parse(Math.Ceiling(iCtr / iRows * 100).ToString()));
                iCtr++;

        back:
                clsMasterConnection = new AceSoft.RetailPlus.Client.MasterDB();
                try
                {
                    clsMasterConnection.GetConnection();

                    clsProducts = new Data.Products(clsMasterConnection.Connection, clsMasterConnection.Transaction);
                    clsInventory = new Data.Inventory(clsMasterConnection.Connection, clsMasterConnection.Transaction);

                    clsProductDetails = clsProducts.Details(mclsBranchDetails.BranchID, strBarCode);
                    if (clsProductDetails.ProductID == 0)
                    {
                        clsInvExLog.AddItem(strBarCode, decQuantity, strUnit, strDescription);
                    }
                    else
                    {
                        clsInvLoadedLog.AddItem(strBarCode, decQuantity, strUnit, strDescription);

                        /*******************************************
                        * Add to Inventory
                        * ****************************************/
                        //clsProduct.AddQuantity(lngProductID, decQuantity);
                        //if (lngVariationMatrixID != 0) { clsProductVariationsMatrix.AddQuantity(lngVariationMatrixID, decQuantity); }
                        // July 26, 2011: change the above codes to the following
                        clsProducts.AddQuantity(mclsBranchDetails.BranchID, clsProductDetails.ProductID, 0, decQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.ADD_INVENTORY_BY_BRANCH) + " /" + clsProductDetails.BaseUnitCode, DateTime.Now, strReferenceNo, "System");


                        //-- STEP 1: Insert to tblInventory for reporting purposes
                        /*******************************************
                            * Add to Inventory Analysis
                            * ****************************************/
                        clsInventoryDetails = new Data.InventoryDetails();
                        clsInventoryDetails.BranchID = mclsBranchDetails.BranchID;
                        clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
                        clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
                        clsInventoryDetails.PostingDate = dtePostingDate;
                        clsInventoryDetails.ReferenceNo = strReferenceNo;
                        clsInventoryDetails.ContactID = clsProductDetails.SupplierID;
                        clsInventoryDetails.ContactCode = clsProductDetails.SupplierCode;
                        clsInventoryDetails.ProductID = clsProductDetails.ProductID;
                        clsInventoryDetails.ProductCode = clsProductDetails.ProductCode;
                        clsInventoryDetails.VariationMatrixID = 0;
                        clsInventoryDetails.MatrixDescription = "";
                        clsInventoryDetails.ClosingQuantity = clsProductDetails.Quantity;
                        clsInventoryDetails.ClosingActualQuantity = decQuantity + clsProductDetails.Quantity;
                        clsInventoryDetails.ClosingCost = (decQuantity + clsProductDetails.Quantity) * clsProductDetails.PurchasePrice;
                        clsInventoryDetails.ClosingVAT = (decQuantity + clsProductDetails.Quantity) * clsProductDetails.PurchasePrice * decimal.Parse("0.12");	// Purchase Cost with VAT
                        clsInventoryDetails.PurchasePrice = clsProductDetails.PurchasePrice;

                        clsInventory.Insert(clsInventoryDetails);
                    }
                    
                    clsMasterConnection.CommitAndDispose();
                }
                catch (Exception ex) 
                {
                    if (ex.Message.Contains("Deadlock found when trying to get lock; try restarting transaction"))
                    { try { clsMasterConnection.ThrowException(ex); } catch { } clsDatabase = new Data.Database(); clsDatabase.FlushHosts(); clsDatabase.CommitAndDispose(); goto back; }
                    else if (ex.InnerException.Message.Contains("Deadlock found when trying to get lock; try restarting transaction"))
                    { try { clsMasterConnection.ThrowException(ex); } catch { } clsDatabase = new Data.Database(); clsDatabase.FlushHosts(); clsDatabase.CommitAndDispose(); goto back; }
                }
			}
            
            bgwSavetoDB.ReportProgress(100);
        }
예제 #6
0
        private void LoadOption()
        {
            Data.Salutation       clsSalutation = new Data.Salutation();
            System.Data.DataTable dt            = clsSalutation.ListAsDataTable();
            clsSalutation.CommitAndDispose();

            cboSalutation.ValueMember   = "SalutationCode";
            cboSalutation.DisplayMember = "SalutationName";
            cboSalutation.DataSource    = dt.DefaultView;
            cboSalutation.SelectedIndex = 0;
            cboSalutation.SelectedValue = "MR";

            if (mContactDetails.ContactID != 0)
            {
                //txtContactCode.Enabled = false;
                txtContactCode.Text  = mContactDetails.ContactCode;
                txtContactName.Text  = mContactDetails.ContactName;
                txtAddress.Text      = mContactDetails.Address;
                txtBusinessName.Text = mContactDetails.BusinessName;
                txtTelephoneNo.Text  = mContactDetails.TelephoneNo;
                txtRemarks.Text      = mContactDetails.Remarks;
                txtTelephoneNo.Tag   = mContactDetails.TINNo;
                txtRemarks.Tag       = mContactDetails.LTONo;

                //txtDebit.Text = mContactDetails.Debit.ToString("###0.#0");
                //chkIsCreditAllowed.Checked = mContactDetails.IsCreditAllowed;
                //cboDepartment.SelectedIndex = cboDepartment.Items.IndexOf(cboDepartment.Items.FindByValue(mContactDetails.DepartmentID.ToString()));
                //cboPosition.SelectedIndex = cboPosition.Items.IndexOf(cboPosition.Items.FindByValue(mContactDetails.PositionID.ToString()));

                //txtCreditCardNo.Text = mContactDetails.CreditDetails.CreditCardNo;
                //cboCreditCardType.SelectedIndex = cboCreditCardType.Items.IndexOf(cboCreditCardType.Items.FindByValue(mContactDetails.CreditDetails.CardTypeDetails.CardTypeID.ToString()));
                //txtCreditAwardDate.Text = mContactDetails.CreditDetails.CreditAwardDate.ToString("yyyy-MMM-dd");
                //txtExpiryDate.Text = mContactDetails.CreditDetails.ExpiryDate.ToString("yyyy-MMM-dd");
                //cboCreditCardStatus.SelectedIndex = cboCreditCardStatus.Items.IndexOf(cboCreditCardStatus.Items.FindByValue(mContactDetails.CreditDetails.CreditCardStatus.ToString("d")));
                //lblCreditCardActive.Text = mContactDetails.CreditDetails.CreditActive ? "Active" : "InActive (Hold/Suspended)";
                //txtCreditLimit.Text = mContactDetails.CreditLimit.ToString("###0.#0");
                //txtCredit.Text = mContactDetails.Credit.ToString("###0.#0");
                //txtPaidAmount.Text = "0.00";
                //txtCurrentBalance.Text = (mContactDetails.CreditLimit - mContactDetails.Credit).ToString("###0.#0");
                //lblLastBillingDate.Text = "Last Billing Date:" + mContactDetails.CreditDetails.LastBillingDate.ToString("yyyy-MMM-dd");

                if (!string.IsNullOrEmpty(mContactDetails.AdditionalDetails.Salutation))
                {
                    cboSalutation.SelectedValue = mContactDetails.AdditionalDetails.Salutation;
                    txtFirstName.Text           = mContactDetails.AdditionalDetails.FirstName;
                    txtMiddleName.Text          = mContactDetails.AdditionalDetails.MiddleName;
                    txtLastName.Text            = mContactDetails.AdditionalDetails.LastName;
                    txtBirthDate.Text           = mContactDetails.AdditionalDetails.BirthDate.ToString("yyyy-MM-dd");
                    txtMobileNo.Text            = mContactDetails.AdditionalDetails.MobileNo;
                }
            }
            else if (mContactDetails.ContactID == 0)
            {
                Data.ERPConfig clsERPConfig = new Data.ERPConfig();
                BarcodeHelper  ean13        = new BarcodeHelper(BarcodeHelper.CustomerCode_Country_Code, BarcodeHelper.CustomerCode_ManufacturerCode, clsERPConfig.get_LastCustomerCode());
                txtContactCode.Text = ean13.CountryCode + ean13.ManufacturerCode + ean13.ProductCode + ean13.ChecksumDigit;
                clsERPConfig.CommitAndDispose();

                if (mstCaption == "Please enter customer name for deposit.")
                {
                    txtRemarks.Text = Data.Contacts.DEFAULT_REMARKS_FOR_ADDED_FROM_DEPOSIT;
                }
                else if (mstCaption == "Quickly add new customer")
                {
                    txtRemarks.Text = Data.Contacts.DEFAULT_REMARKS_FOR_QUICKLY_ADDED_FROM_FE;
                }
                else if (mContactDetails.ContactID == 0) // means not edit
                {
                    txtRemarks.Text = Data.Contacts.DEFAULT_REMARKS_FOR_ADDED_FROM_CLIENT;
                }
            }
        }
예제 #7
0
        private void LoadOption()
        {
            cboTerms.Items.Clear();
            foreach (string str in Enum.GetNames(typeof(ModeOfTerms)))
            {
                cboTerms.Items.Add(str);
            }
            cboTerms.SelectedIndex = 0;

            Data.ContactGroups clsContactGroups = new Data.ContactGroups();
            System.Data.DataTable dtContactGroups = clsContactGroups.ListAsDataTable(Data.ContactGroupCategory.CUSTOMER);
            clsContactGroups.CommitAndDispose();

            bool boContactGroup = false;
            cboGroup.Items.Clear();
            foreach (System.Data.DataRow dr in dtContactGroups.Rows)
            {
                cboGroup.Items.Add(dr["ContactGroupName"].ToString());
                if (mContactDetails.ContactGroupName == dr["ContactGroupName"].ToString())
                {
                    cboGroup.SelectedIndex = cboGroup.Items.Count - 1; boContactGroup = true;
                }
            }

            if (!boContactGroup) cboGroup.SelectedIndex = 0;

            if (mContactDetails.ContactID != 0)
            {
                txtContactCode.Text = mContactDetails.ContactCode;
                txtCustomerName.Text = mContactDetails.ContactName;
                txtBusinessName.Text = mContactDetails.BusinessName;
                txtTelNo.Text = mContactDetails.TelephoneNo;
                txtRemarks.Text = mContactDetails.Remarks;
                txtAddress.Text = mContactDetails.Address;
                txtTINNo.Text = mContactDetails.TINNo;
                txtLTONo.Text = mContactDetails.LTONo;
                txtPriceLevel.Text = mContactDetails.PriceLevel.ToString("G").ToUpper();

                // 18Jun2013 : For credit information
                txtCreditLimit.Text = mContactDetails.CreditLimit.ToString("#,##0.#0");
                txtCredit.Text = mContactDetails.Credit.ToString("#,##0.#0");
                txtAvailableCredit.Text = (mContactDetails.CreditLimit - mContactDetails.Credit).ToString("#,##0.#0");
                txtTerms.Text = mContactDetails.Terms.ToString("#,##0");
                cboTerms.SelectedIndex = int.Parse(mContactDetails.ModeOfTerms.ToString("d"));
                chkIsCreditAllowed.Checked = mContactDetails.IsCreditAllowed;
            }
            else if (mContactDetails.ContactID == 0)
            {
                Data.ERPConfig clsERPConfig = new Data.ERPConfig();
                BarcodeHelper ean13 = new BarcodeHelper(BarcodeHelper.CustomerCode_Country_Code, BarcodeHelper.CustomerCode_ManufacturerCode, clsERPConfig.get_LastCustomerCode());
                txtContactCode.Text = ean13.CountryCode + ean13.ManufacturerCode + ean13.ProductCode + ean13.ChecksumDigit;
                clsERPConfig.CommitAndDispose();

                if (mstCaption == "Please enter customer name for deposit.")
                { txtRemarks.Text = Data.Contacts.DEFAULT_REMARKS_FOR_ADDED_FROM_DEPOSIT; }
                else if (mstCaption == "Quickly add new customer")
                { txtRemarks.Text = Data.Contacts.DEFAULT_REMARKS_FOR_QUICKLY_ADDED_FROM_FE; }
                else if (mContactDetails.ContactID == 0) // means not edit
                { txtRemarks.Text = Data.Contacts.DEFAULT_REMARKS_FOR_ADDED_FROM_CLIENT; }
            }

            if (SysConfigDetails.ContactAddWndType == ContactAddWndType.ContactAddNoLTOWnd)
            {
                labelLTONo.Text = "Additional Info";
            }
            else
                labelLTONo.Text = "LTO No (BFAD No)";
        }
예제 #8
0
        private void SaveToDB()
        {
            AceSoft.RetailPlus.Client.MasterDB clsMasterConnection;
            Data.Products  clsProducts;
            Data.Inventory clsInventory;
            Data.Database  clsDatabase;

            Data.ERPConfig        clsERPConfig        = new Data.ERPConfig();
            Data.ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();
            string strReferenceNo = Constants.CLOSE_INVENTORY_CODE + CompanyDetails.BECompanyCode + DateTime.Now.Year.ToString() + clsERPConfig.get_LastClosingNo();

            clsERPConfig.CommitAndDispose();

            Data.ProductDetails   clsProductDetails;
            Data.InventoryDetails clsInventoryDetails;

            DateTime dtePostingDate = DateTime.Now;

            if (!Directory.Exists("invfiles/backups/"))
            {
                Directory.CreateDirectory("invfiles/backups/");
            }
            if (File.Exists("invfiles/" + mclsBranchDetails.BranchCode + DateTime.Now.ToString("yyyyMMdd") + ".inv"))
            {
                if (MessageBox.Show("You have already loaded the inventory for this branch today. Please verify the file you are loading. Would you like to continue?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.No)
                {
                    bgwSavetoDB.ReportProgress(100);
                    return;
                }
            }
            else
            {
                System.IO.File.Copy("invfiles/" + mclsBranchDetails.BranchCode + ".inv", "invfiles/" + mclsBranchDetails.BranchCode + DateTime.Now.ToString("yyyyMMdd") + ".inv");
            }

            InvExLog clsInvExLog = new InvExLog();

            clsInvExLog.BranchDetails = mclsBranchDetails;
            if (File.Exists("invfiles/" + mclsBranchDetails.BranchCode + DateTime.Now.ToString("yyyyMMdd") + "_exc.inv"))
            {
                System.IO.File.Copy("invfiles/" + mclsBranchDetails.BranchCode + DateTime.Now.ToString("yyyyMMdd") + "_exc.inv", "invfiles/backups/" + mclsBranchDetails.BranchCode + DateTime.Now.ToString("yyyyMMdd") + "_exc.inv" + "_" + DateTime.Now.ToString("yyyyddMMhhmmss"));
                System.IO.File.Delete("invfiles/" + mclsBranchDetails.BranchCode + DateTime.Now.ToString("yyyyMMdd") + "_exc.inv");
            }

            InvLoadedLog clsInvLoadedLog = new InvLoadedLog();

            clsInvLoadedLog.BranchDetails = mclsBranchDetails;
            if (File.Exists("invfiles/" + mclsBranchDetails.BranchCode + DateTime.Now.ToString("yyyyMMdd") + "_saved.inv"))
            {
                System.IO.File.Copy("invfiles/" + mclsBranchDetails.BranchCode + DateTime.Now.ToString("yyyyMMdd") + "_saved.inv", "invfiles/backups/" + mclsBranchDetails.BranchCode + DateTime.Now.ToString("yyyyMMdd") + "_saved.inv" + "_" + DateTime.Now.ToString("yyyyddMMhhmmss"));
                System.IO.File.Delete("invfiles/" + mclsBranchDetails.BranchCode + DateTime.Now.ToString("yyyyMMdd") + "_saved.inv");
            }

            decimal iCtr = 1, iRows = Decimal.Parse(mdtItems.Rows.Count.ToString());

            foreach (System.Data.DataRow dr in mdtItems.Rows)
            {
                string  strBarCode  = dr["BarCode"].ToString();
                decimal decQuantity = decimal.Parse(dr["Quantity"].ToString());

                string strUnit        = dr["Unit"].ToString();
                string strDescription = dr["Description"].ToString();

                mstStatus = "[" + iCtr.ToString() + "/" + iRows + "]Saving " + strBarCode + strDescription;
                bgwSavetoDB.ReportProgress(int.Parse(Math.Ceiling(iCtr / iRows * 100).ToString()));
                iCtr++;

back:
                clsMasterConnection = new AceSoft.RetailPlus.Client.MasterDB();
                try
                {
                    clsMasterConnection.GetConnection();

                    clsProducts  = new Data.Products(clsMasterConnection.Connection, clsMasterConnection.Transaction);
                    clsInventory = new Data.Inventory(clsMasterConnection.Connection, clsMasterConnection.Transaction);

                    clsProductDetails = clsProducts.Details(mclsBranchDetails.BranchID, strBarCode);
                    if (clsProductDetails.ProductID == 0)
                    {
                        clsInvExLog.AddItem(strBarCode, decQuantity, strUnit, strDescription);
                    }
                    else
                    {
                        clsInvLoadedLog.AddItem(strBarCode, decQuantity, strUnit, strDescription);

                        /*******************************************
                         * Add to Inventory
                         * ****************************************/
                        //clsProduct.AddQuantity(lngProductID, decQuantity);
                        //if (lngVariationMatrixID != 0) { clsProductVariationsMatrix.AddQuantity(lngVariationMatrixID, decQuantity); }
                        // July 26, 2011: change the above codes to the following
                        clsProducts.AddQuantity(mclsBranchDetails.BranchID, clsProductDetails.ProductID, 0, decQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.ADD_INVENTORY_BY_BRANCH) + " /" + clsProductDetails.BaseUnitCode, DateTime.Now, strReferenceNo, "System");


                        //-- STEP 1: Insert to tblInventory for reporting purposes

                        /*******************************************
                         * Add to Inventory Analysis
                         * ****************************************/
                        clsInventoryDetails                       = new Data.InventoryDetails();
                        clsInventoryDetails.BranchID              = mclsBranchDetails.BranchID;
                        clsInventoryDetails.PostingDateFrom       = clsERPConfigDetails.PostingDateFrom;
                        clsInventoryDetails.PostingDateTo         = clsERPConfigDetails.PostingDateTo;
                        clsInventoryDetails.PostingDate           = dtePostingDate;
                        clsInventoryDetails.ReferenceNo           = strReferenceNo;
                        clsInventoryDetails.ContactID             = clsProductDetails.SupplierID;
                        clsInventoryDetails.ContactCode           = clsProductDetails.SupplierCode;
                        clsInventoryDetails.ProductID             = clsProductDetails.ProductID;
                        clsInventoryDetails.ProductCode           = clsProductDetails.ProductCode;
                        clsInventoryDetails.VariationMatrixID     = 0;
                        clsInventoryDetails.MatrixDescription     = "";
                        clsInventoryDetails.ClosingQuantity       = clsProductDetails.Quantity;
                        clsInventoryDetails.ClosingActualQuantity = decQuantity + clsProductDetails.Quantity;
                        clsInventoryDetails.ClosingCost           = (decQuantity + clsProductDetails.Quantity) * clsProductDetails.PurchasePrice;
                        clsInventoryDetails.ClosingVAT            = (decQuantity + clsProductDetails.Quantity) * clsProductDetails.PurchasePrice * decimal.Parse("0.12"); // Purchase Cost with VAT
                        clsInventoryDetails.PurchasePrice         = clsProductDetails.PurchasePrice;

                        clsInventory.Insert(clsInventoryDetails);
                    }

                    clsMasterConnection.CommitAndDispose();
                }
                catch (Exception ex)
                {
                    if (ex.Message.Contains("Deadlock found when trying to get lock; try restarting transaction"))
                    {
                        try { clsMasterConnection.ThrowException(ex); } catch { } clsDatabase = new Data.Database(); clsDatabase.FlushHosts(); clsDatabase.CommitAndDispose(); goto back;
                    }
                    else if (ex.InnerException.Message.Contains("Deadlock found when trying to get lock; try restarting transaction"))
                    {
                        try { clsMasterConnection.ThrowException(ex); } catch { } clsDatabase = new Data.Database(); clsDatabase.FlushHosts(); clsDatabase.CommitAndDispose(); goto back;
                    }
                }
            }

            bgwSavetoDB.ReportProgress(100);
        }