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(); }
private void LoadRecord() { lblHeader.Text = mstCaption + " for customer : " + mContactDetails.ContactName; txtDOB.Text = DateTime.Now.AddYears(-18).ToString("yyyy-MM-dd"); txtRewardCardNo.Text = mContactDetails.ContactCode.Length > 15 ? mContactDetails.ContactCode.Substring(0, 15) : mContactDetails.ContactCode; txtRewardCardExpiryDate.Text = DateTime.Now.AddYears(1).ToString("yyyy-MM-dd"); Data.ContactReward clsContactReward = new Data.ContactReward(); Data.ContactRewardDetails clsContactRewardDetails = clsContactReward.Details(mContactDetails.ContactID); if (clsContactRewardDetails.ContactID != Constants.ZERO) { txtRewardCardNo.Text = clsContactRewardDetails.RewardCardNo; txtDOB.Text = clsContactRewardDetails.BirthDate.ToString("yyyy-MM-dd"); txtRewardCardExpiryDate.Text = clsContactRewardDetails.ExpiryDate.ToString("yyyy-MM-dd"); } if (TerminalDetails.AutoGenerateRewardCardNo) { if ((mRewardCardStatus == RewardCardStatus.New && clsContactRewardDetails.ContactID == Constants.ZERO) || mRewardCardStatus == RewardCardStatus.Replaced_Lost) { Data.ERPConfig clsERPConfig = new Data.ERPConfig(clsContactReward.Connection, clsContactReward.Transaction); BarcodeHelper ean13 = new BarcodeHelper(BarcodeHelper.RewardCard_Country_Code, BarcodeHelper.RewardCard_ManufacturerCode, clsERPConfig.get_LastRewardCardNo()); txtRewardCardNo.Text = ean13.CountryCode + ean13.ManufacturerCode + ean13.ProductCode + ean13.ChecksumDigit; } } else { txtRewardCardNo.Enabled = true; } clsContactReward.CommitAndDispose(); if (mRewardCardStatus == RewardCardStatus.New && clsContactRewardDetails.ContactID != Constants.ZERO) { txtRewardCardExpiryDate.Enabled = false; this.Refresh(); txtRewardCardNo.Focus(); MessageBox.Show("Reward Card No: " + clsContactRewardDetails.RewardCardNo + " was already issued last " + clsContactRewardDetails.RewardAwardDate.ToString("MMM dd, yyyy") + " to " + mContactDetails.ContactName + "." + Environment.NewLine + "Please select another customer.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (mRewardCardStatus == RewardCardStatus.Lost || mRewardCardStatus == RewardCardStatus.Expired) { txtRewardCardExpiryDate.Enabled = false; txtDOB.Focus(); } else if (mRewardCardStatus == RewardCardStatus.Replaced_Lost || mRewardCardStatus == RewardCardStatus.Replaced_Expired) { txtRewardCardExpiryDate.Enabled = true; txtRewardCardExpiryDate.Focus(); } else if (mRewardCardStatus == RewardCardStatus.Reactivated_Lost) { txtRewardCardNo.Enabled = true; txtRewardCardExpiryDate.Enabled = true; txtRewardCardNo.Focus(); } else if (mRewardCardStatus == RewardCardStatus.ReNew) { txtRewardCardExpiryDate.Enabled = true; txtRewardCardExpiryDate.Focus(); } }
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; } } }
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(); }
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; } } }
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); }
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; } } }
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)"; }
private bool SaveRecord() { bool boRetValue = false; if (string.IsNullOrEmpty(txtCreditCardNo.Text.Trim())) { MessageBox.Show("Sorry please enter a valid credit card no.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return boRetValue; } DateTime dteExpiryDate = DateTime.MinValue; try { dteExpiryDate = DateTime.Parse(txtCreditCardExpiryDate.Text); } catch { MessageBox.Show("Please enter a valid expiry date in the ff format: YYYY-MM-dd ", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return boRetValue; } decimal decCreditLimit = 0; try { decCreditLimit = decimal.Parse(txtCreditLimit.Text); } catch { MessageBox.Show("Please enter a valid credit limit amount.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return boRetValue; } if (mCreditCardStatus == CreditCardStatus.New) { if (MessageBox.Show("Are you sure you want to issue a new credit card to " + mContactDetails.ContactName + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return boRetValue; } } else if (mCreditCardStatus == CreditCardStatus.Lost || mCreditCardStatus == CreditCardStatus.Expired || mCreditCardStatus == RetailPlus.CreditCardStatus.Suspended) { if (MessageBox.Show("Are you sure you want to declare card no: " + txtCreditCardNo.Text + " as " + mCreditCardStatus.ToString("G") + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return boRetValue; } } else if (mCreditCardStatus == CreditCardStatus.Replaced_Lost || mCreditCardStatus == CreditCardStatus.Replaced_Expired) { if (MessageBox.Show("Are you sure you want to replace existing credit card w/ new card no?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return boRetValue; } } else if (mCreditCardStatus == CreditCardStatus.Reactivated_Lost) { if (MessageBox.Show("Are you sure you want to reactivate existing credit card no: " + txtCreditCardNo.Text + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return boRetValue; } } else if (mCreditCardStatus == CreditCardStatus.ReNew) { if (MessageBox.Show("Are you sure you want to renew card no: " + txtCreditCardNo.Text + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return boRetValue; } if (dteExpiryDate < DateTime.Now) { MessageBox.Show("Expiry date must not be less than date today. Please enter a valid expiry date. ", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return boRetValue; } } Data.ContactCreditCardInfos clsContactCreditCardInfos = new Data.ContactCreditCardInfos(); Data.ContactCreditCardInfoDetails clsContactCreditCardInfoDetails = clsContactCreditCardInfos.Details(mContactDetails.ContactID); if (clsContactCreditCardInfoDetails.CustomerID != Constants.ZERO) { txtCreditCardNo.Text = clsContactCreditCardInfoDetails.CreditCardNo; //remove this override //txtCreditCardExpiryDate.Text = clsContactCreditCardInfoDetails.ExpiryDate.ToString("yyyy-MM-dd"); } if (((mCreditCardStatus == CreditCardStatus.New && clsContactCreditCardInfoDetails.CustomerID == Constants.ZERO) || mCreditCardStatus == CreditCardStatus.Replaced_Lost) && (CardTypeDetails.WithGuarantor)) { Data.ERPConfig clsERPConfig = new Data.ERPConfig(clsContactCreditCardInfos.Connection, clsContactCreditCardInfos.Transaction); BarcodeHelper ean13 = new BarcodeHelper(BarcodeHelper.GroupCreditCard_Country_Code, BarcodeHelper.GroupCreditCard_ManufacturerCode, clsERPConfig.get_LastGroupCreditCardNo()); txtCreditCardNo.Text = ean13.CountryCode + ean13.ManufacturerCode + ean13.ProductCode + ean13.ChecksumDigit; } else if ((mCreditCardStatus == CreditCardStatus.New && clsContactCreditCardInfoDetails.CustomerID == Constants.ZERO) || mCreditCardStatus == CreditCardStatus.Replaced_Lost) { Data.ERPConfig clsERPConfig = new Data.ERPConfig(clsContactCreditCardInfos.Connection, clsContactCreditCardInfos.Transaction); BarcodeHelper ean13 = new BarcodeHelper(BarcodeHelper.CreditCard_Country_Code, BarcodeHelper.CreditCard_ManufacturerCode, clsERPConfig.get_LastCreditCardNo()); txtCreditCardNo.Text = ean13.CountryCode + ean13.ManufacturerCode + ean13.ProductCode + ean13.ChecksumDigit; } clsContactCreditCardInfos.CommitAndDispose(); Data.ContactCreditCardInfoDetails clsDetails = new Data.ContactCreditCardInfoDetails(); clsDetails.CustomerID = mContactDetails.ContactID; clsDetails.CardTypeDetails = CardTypeDetails; clsDetails.CreditCardNo = txtCreditCardNo.Text; clsDetails.CreditAwardDate = DateTime.Now; clsDetails.ExpiryDate = dteExpiryDate; clsDetails.CreditLimit = decCreditLimit; clsContactCreditCardInfos = new Data.ContactCreditCardInfos(); clsContactCreditCardInfoDetails = clsContactCreditCardInfos.Details(txtCreditCardNo.Text); if (clsContactCreditCardInfoDetails.CustomerID != Constants.ZERO) { if (mCreditCardStatus == CreditCardStatus.New || (mCreditCardStatus != CreditCardStatus.New && clsContactCreditCardInfoDetails.CustomerID != mContactDetails.ContactID)) { clsContactCreditCardInfos.CommitAndDispose(); MessageBox.Show("Credit Card No: " + clsContactCreditCardInfoDetails.CreditCardNo + " was already issued on " + clsContactCreditCardInfoDetails.CreditAwardDate.ToString("MMM dd, yyyy") + " to another customer." + Environment.NewLine + "Please enter another Credit Card No.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error); txtCreditCardNo.Focus(); txtCreditCardNo.SelectAll(); return boRetValue; } } clsDetails.GuarantorID = clsContactCreditCardInfoDetails.GuarantorID; clsDetails.CardTypeDetails = clsContactCreditCardInfoDetails.CardTypeDetails; if (mCreditCardStatus == CreditCardStatus.New) { clsDetails.CreditActive = true; // override if new clsDetails.GuarantorID = Guarantor.ContactID; clsDetails.CardTypeDetails = CardTypeDetails; } else if (mCreditCardStatus == CreditCardStatus.Lost || mCreditCardStatus == CreditCardStatus.Expired || mCreditCardStatus == RetailPlus.CreditCardStatus.Suspended) { clsDetails.CreditActive = false; } else if (mCreditCardStatus == CreditCardStatus.Replaced_Lost || mCreditCardStatus == CreditCardStatus.Replaced_Expired || mCreditCardStatus == CreditCardStatus.Reactivated_Lost || mCreditCardStatus == CreditCardStatus.ReNew) { clsDetails.CreditActive = true; } clsDetails.CreditCardStatus = mCreditCardStatus; // do an overwride if the date is already expired if (dteExpiryDate < new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59)) { clsDetails.CreditActive = false; clsDetails.CreditCardStatus = CreditCardStatus.Expired; } boRetValue = clsContactCreditCardInfos.Update(clsDetails); Data.Contacts clsContacts = new Data.Contacts(clsContactCreditCardInfos.Connection, clsContactCreditCardInfos.Transaction); clsContacts.UpdateRemarks(clsDetails.CustomerID, txtRemarks.Text, ""); mContactDetails.CreditDetails = clsDetails; clsContactCreditCardInfos.CommitAndDispose(); boRetValue = true; return boRetValue; }
private void LoadRecord() { lblHeader.Text = mstCaption + " for customer : " + mContactDetails.ContactName; txtDOB.Text = DateTime.Now.AddYears(-18).ToString("yyyy-MM-dd"); txtRewardCardNo.Text = mContactDetails.ContactCode; txtRewardCardExpiryDate.Text = DateTime.Now.AddYears(1).ToString("yyyy-MM-dd"); Data.ContactReward clsContactReward = new Data.ContactReward(); Data.ContactRewardDetails clsContactRewardDetails = clsContactReward.Details(mContactDetails.ContactID); if (clsContactRewardDetails.ContactID != Constants.ZERO) { txtRewardCardNo.Text = clsContactRewardDetails.RewardCardNo; txtDOB.Text = clsContactRewardDetails.BirthDate.ToString("yyyy-MM-dd"); txtRewardCardExpiryDate.Text = clsContactRewardDetails.ExpiryDate.ToString("yyyy-MM-dd"); } if (mTerminalDetails.AutoGenerateRewardCardNo == true) { if ((mRewardCardStatus == RewardCardStatus.New && clsContactRewardDetails.ContactID == Constants.ZERO) || mRewardCardStatus == RewardCardStatus.Replaced_Lost) { Data.ERPConfig clsERPConfig = new Data.ERPConfig(clsContactReward.Connection, clsContactReward.Transaction); txtRewardCardNo.Text = clsERPConfig.get_LastRewardCardNo(); } } else { txtRewardCardNo.Enabled = true; } clsContactReward.CommitAndDispose(); if (mRewardCardStatus == RewardCardStatus.New && clsContactRewardDetails.ContactID != Constants.ZERO) { txtRewardCardExpiryDate.Enabled = false; this.Refresh(); txtRewardCardNo.Focus(); MessageBox.Show("Reward Card No: " + clsContactRewardDetails.RewardCardNo + " was already issued last " + clsContactRewardDetails.RewardAwardDate.ToString("MMM dd, yyyy") + " to " + mContactDetails.ContactName + "." + Environment.NewLine + "Please select another customer.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (mRewardCardStatus == RewardCardStatus.Lost || mRewardCardStatus == RewardCardStatus.Expired) { txtRewardCardExpiryDate.Enabled = false; txtDOB.Focus(); } else if (mRewardCardStatus == RewardCardStatus.Replaced_Lost || mRewardCardStatus == RewardCardStatus.Replaced_Expired) { txtRewardCardExpiryDate.Enabled = true; txtRewardCardExpiryDate.Focus(); } else if (mRewardCardStatus == RewardCardStatus.Reactivated_Lost) { txtRewardCardNo.Enabled = true; txtRewardCardExpiryDate.Enabled = true; txtRewardCardNo.Focus(); } else if (mRewardCardStatus == RewardCardStatus.ReNew) { txtRewardCardExpiryDate.Enabled = true; txtRewardCardExpiryDate.Focus(); } }
private bool SaveRecord() { bool boRetValue = false; if (string.IsNullOrEmpty(txtCreditCardNo.Text.Trim())) { MessageBox.Show("Sorry please enter a valid credit card no.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(boRetValue); } DateTime dteExpiryDate = DateTime.MinValue; try { dteExpiryDate = DateTime.Parse(txtCreditCardExpiryDate.Text); } catch { MessageBox.Show("Please enter a valid expiry date in the ff format: YYYY-MM-dd ", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(boRetValue); } decimal decCreditLimit = 0; try { decCreditLimit = decimal.Parse(txtCreditLimit.Text); } catch { MessageBox.Show("Please enter a valid credit limit amount.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(boRetValue); } if (mCreditCardStatus == CreditCardStatus.New) { if (MessageBox.Show("Are you sure you want to issue a new credit card to " + mContactDetails.ContactName + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return(boRetValue); } } else if (mCreditCardStatus == CreditCardStatus.Lost || mCreditCardStatus == CreditCardStatus.Expired) { if (MessageBox.Show("Are you sure you want to declare card no: " + txtCreditCardNo.Text + " as " + mCreditCardStatus.ToString("G") + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return(boRetValue); } } else if (mCreditCardStatus == CreditCardStatus.Replaced_Lost || mCreditCardStatus == CreditCardStatus.Replaced_Expired) { if (MessageBox.Show("Are you sure you want to replace existing credit card w/ new card no?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return(boRetValue); } } else if (mCreditCardStatus == CreditCardStatus.Reactivated_Lost) { if (MessageBox.Show("Are you sure you want to reactivate existing credit card no: " + txtCreditCardNo.Text + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return(boRetValue); } } else if (mCreditCardStatus == CreditCardStatus.ReNew) { if (MessageBox.Show("Are you sure you want to renew card no: " + txtCreditCardNo.Text + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return(boRetValue); } if (dteExpiryDate < DateTime.Now) { MessageBox.Show("Expiry date must not be less than date today. Please enter a valid expiry date. ", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(boRetValue); } } Data.ContactCreditCardInfos clsContactCreditCardInfos = new Data.ContactCreditCardInfos(); Data.ContactCreditCardInfoDetails clsContactCreditCardInfoDetails = clsContactCreditCardInfos.Details(mContactDetails.ContactID); if (clsContactCreditCardInfoDetails.CustomerID != Constants.ZERO) { txtCreditCardNo.Text = clsContactCreditCardInfoDetails.CreditCardNo; txtCreditCardExpiryDate.Text = clsContactCreditCardInfoDetails.ExpiryDate.ToString("yyyy-MM-dd"); } if (((mCreditCardStatus == CreditCardStatus.New && clsContactCreditCardInfoDetails.CustomerID == Constants.ZERO) || mCreditCardStatus == CreditCardStatus.Replaced_Lost) && (CardTypeDetails.WithGuarantor)) { Data.ERPConfig clsERPConfig = new Data.ERPConfig(clsContactCreditCardInfos.Connection, clsContactCreditCardInfos.Transaction); txtCreditCardNo.Text = clsERPConfig.get_LastGroupCreditCardNo(); } else if ((mCreditCardStatus == CreditCardStatus.New && clsContactCreditCardInfoDetails.CustomerID == Constants.ZERO) || mCreditCardStatus == CreditCardStatus.Replaced_Lost) { Data.ERPConfig clsERPConfig = new Data.ERPConfig(clsContactCreditCardInfos.Connection, clsContactCreditCardInfos.Transaction); txtCreditCardNo.Text = clsERPConfig.get_LastCreditCardNo(); } clsContactCreditCardInfos.CommitAndDispose(); Data.ContactCreditCardInfoDetails clsDetails = new Data.ContactCreditCardInfoDetails(); clsDetails.CustomerID = mContactDetails.ContactID; clsDetails.CardTypeDetails = CardTypeDetails; clsDetails.CreditCardNo = txtCreditCardNo.Text; clsDetails.CreditAwardDate = DateTime.Now; clsDetails.ExpiryDate = dteExpiryDate; clsDetails.CreditLimit = decCreditLimit; clsContactCreditCardInfos = new Data.ContactCreditCardInfos(); clsContactCreditCardInfoDetails = clsContactCreditCardInfos.Details(txtCreditCardNo.Text); if (clsContactCreditCardInfoDetails.CustomerID != Constants.ZERO) { if (mCreditCardStatus == CreditCardStatus.New || (mCreditCardStatus != CreditCardStatus.New && clsContactCreditCardInfoDetails.CustomerID != mContactDetails.ContactID)) { clsContactCreditCardInfos.CommitAndDispose(); MessageBox.Show("Credit Card No: " + clsContactCreditCardInfoDetails.CreditCardNo + " was already issued on " + clsContactCreditCardInfoDetails.CreditAwardDate.ToString("MMM dd, yyyy") + " to another customer." + Environment.NewLine + "Please enter another Credit Card No.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error); txtCreditCardNo.Focus(); txtCreditCardNo.SelectAll(); return(boRetValue); } } clsDetails.GuarantorID = clsContactCreditCardInfoDetails.GuarantorID; clsDetails.CardTypeDetails = clsContactCreditCardInfoDetails.CardTypeDetails; if (mCreditCardStatus == CreditCardStatus.New) { clsDetails.CreditActive = true; // override if new clsDetails.GuarantorID = Guarantor.ContactID; clsDetails.CardTypeDetails = CardTypeDetails; } else if (mCreditCardStatus == CreditCardStatus.Lost || mCreditCardStatus == CreditCardStatus.Expired) { clsDetails.CreditActive = false; } else if (mCreditCardStatus == CreditCardStatus.Replaced_Lost || mCreditCardStatus == CreditCardStatus.Replaced_Expired || mCreditCardStatus == CreditCardStatus.Reactivated_Lost || mCreditCardStatus == CreditCardStatus.ReNew) { clsDetails.CreditActive = true; } clsDetails.CreditCardStatus = mCreditCardStatus; boRetValue = clsContactCreditCardInfos.Update(clsDetails); mContactDetails.CreditDetails = clsDetails; clsContactCreditCardInfos.CommitAndDispose(); boRetValue = true; return(boRetValue); }
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); }