private void ShowProductTotalQuantity() { try { if (mclsSysConfigDetails.WillShowProductTotalQuantityInItemSelect) { if (dgItems.CurrentRowIndex < 0) { lblProductCode.Visible = false; lblProductQuantity.Visible = false; } else { ProductModel.ProductID = Int64.Parse(dgItems[dgItems.CurrentRowIndex, 1].ToString()); ProductModel.MatrixID = Int64.Parse(dgItems[dgItems.CurrentRowIndex, 2].ToString()); Data.Products clsProduct = new Data.Products(); Data.ProductDetails clsProductDetails = clsProduct.Details(ProductModel.ProductID, ProductModel.MatrixID); lblProductCode.Text = clsProductDetails.ProductCode + " Qty:"; lblProductQuantity.Text = clsProductDetails.ConvertedQuantity; clsProduct.CommitAndDispose(); lblProductCode.Visible = true; lblProductQuantity.Visible = true; } } else { lblProductCode.Visible = false; lblProductQuantity.Visible = false; } } catch { } }
public static Response <bool> save(Products product) { Response <bool> res = new Response <bool>() { Estatus = Estatus.Error }; try { bool saveProduct = new Data.Products(new Data.ConexionBD()).save(product.name, product.description, product.sales_price, product.purchase_price, product.status); if (saveProduct) { res.Datos = true; res.Estatus = Estatus.Exito; } else { res.Datos = false; res.Estatus = Estatus.Advertencia; } } catch (Exception ex) { res.Mensaje = "No se pueden obtener los productos en este momento."; res.MensajeTecnico = ex.Message; } return(res); }
protected void cmdProductCode_Click(object sender, System.Web.UI.ImageClickEventArgs e) { DataClass clsDataClass = new DataClass(); Data.Products clsProduct = new Data.Products(); cboProductCode.DataTextField = "ProductCode"; cboProductCode.DataValueField = "ProductID"; ProductDetails clsSearchKeys = new ProductDetails(); clsSearchKeys.ProductCode = txtProductCode.Text; cboProductCode.DataSource = clsProduct.ListAsDataTable(clsSearchKeys: clsSearchKeys, limit: 100).DefaultView; cboProductCode.DataBind(); clsProduct.CommitAndDispose(); if (cboProductCode.Items.Count == 0) { cboProductCode.Items.Add(new ListItem("No product", "0")); } cboProductCode.SelectedIndex = 0; cboProductCode_SelectedIndexChanged(null, null); }
private void LoadProduct() { string strSearchKey = txtProductCode.Text.Trim(); Data.ProductDetails clsSearchKeys = new Data.ProductDetails(); clsSearchKeys.BarCode = strSearchKey; clsSearchKeys.BarCode2 = strSearchKey; clsSearchKeys.BarCode3 = strSearchKey; clsSearchKeys.ProductCode = strSearchKey; clsSearchKeys.ProductSubGroupID = long.Parse(cboProductSubGroup.SelectedItem.Value); clsSearchKeys.ProductGroupID = long.Parse(cboProductGroup.SelectedItem.Value); Data.Products clsProduct = new Data.Products(); cboProductCode.DataTextField = "ProductCode"; cboProductCode.DataValueField = "ProductID"; cboProductCode.DataSource = clsProduct.ListAsDataTable(clsSearchKeys: clsSearchKeys, limit: 100).DefaultView; cboProductCode.DataBind(); clsProduct.CommitAndDispose(); if (cboProductCode.Items.Count == 0) { cboProductCode.Items.Insert(0, new ListItem(Constants.ALL, Constants.ZERO_STRING)); } cboProductCode.SelectedIndex = 0; cboProductCode_SelectedIndexChanged(null, null); }
protected void cmdProductCode_Click(object sender, System.Web.UI.ImageClickEventArgs e) { DataClass clsDataClass = new DataClass(); Data.Products clsProduct = new Data.Products(); cboProductCode.DataTextField = "ProductCode"; cboProductCode.DataValueField = "ProductID"; string stSearchKey = txtProductCode.Text; cboProductCode.DataSource = clsProduct.ProductIDandCodeDataTable(SearchKey: stSearchKey, limit: 100); cboProductCode.DataBind(); clsProduct.CommitAndDispose(); bool bolShowCommandButtons = false; if (cboProductCode.Items.Count == 0) { cboProductCode.Items.Add(new ListItem("No product", "0")); bolShowCommandButtons = false; } else { bolShowCommandButtons = true; string stParam = "?task=" + Common.Encrypt("add", Session.SessionID); string newWindowUrl = Constants.ROOT_DIRECTORY + "/MasterFiles/_Product/Default.aspx" + stParam; lnkAddProduct.NavigateUrl = newWindowUrl; stParam = "?task=" + Common.Encrypt("add", Session.SessionID) + "&prodid=" + Common.Encrypt(cboProductCode.SelectedItem.Value, Session.SessionID); newWindowUrl = Constants.ROOT_DIRECTORY + "/MasterFiles/_Product/_VariationsMatrix/Default.aspx" + stParam; lnkVariationAdd.NavigateUrl = newWindowUrl; } imgProductHistory.Visible = bolShowCommandButtons; imgProductPriceHistory.Visible = bolShowCommandButtons; imgChangePrice.Visible = bolShowCommandButtons; imgEditNow.Visible = bolShowCommandButtons; lnkAddProduct.Visible = bolShowCommandButtons; cmdVariationSearch.Visible = bolShowCommandButtons; imgVariationQuickAdd.Visible = bolShowCommandButtons; lnkVariationAdd.Visible = bolShowCommandButtons; cboProductCode.SelectedIndex = 0; cboProductCode_SelectedIndexChanged(null, null); }
protected void cmdProductCode_Click(object sender, System.Web.UI.ImageClickEventArgs e) { DataClass clsDataClass = new DataClass(); Data.Products clsProduct = new Data.Products(); cboProductCode.DataTextField = "ProductCode"; cboProductCode.DataValueField = "ProductID"; string stSearchKey = txtProductCode.Text; cboProductCode.DataSource = clsProduct.ProductIDandCodeDataTable(SearchKey: stSearchKey, limit: 100); cboProductCode.DataBind(); clsProduct.CommitAndDispose(); cboProductCode.SelectedIndex = 0; cboProductCode_SelectedIndexChanged(null, null); }
protected void cmdProductCode_Click(object sender, System.Web.UI.ImageClickEventArgs e) { string stSearchKey = txtProductCodeSearch.Text; Data.Products clsProduct = new Data.Products(); cboProductCode.DataTextField = "ProductCode"; cboProductCode.DataValueField = "ProductID"; cboProductCode.DataSource = clsProduct.ProductIDandCodeDataTable(SearchKey: stSearchKey, limit: 100); cboProductCode.DataBind(); clsProduct.CommitAndDispose(); if (cboProductCode.Items.Count == 0) { cboProductCode.Items.Add(new ListItem("No product", "0")); } cboProductCode.SelectedIndex = 0; clsProduct.CommitAndDispose(); cboProductCode_SelectedIndexChanged(null, null); }
public static Response <List <Products> > getProducts() { Response <List <Products> > res = new Response <List <Products> >() { Estatus = Estatus.Error }; List <Products> list = new List <Products>(); try { DataTable items = new Data.Products(new Data.ConexionBD()).getProducts(); if (items.Rows.Count > 0) { foreach (DataRow row in items.Rows) { Products product = new Products(); product.name = row["name"].ToString(); product.description = row["description"].ToString(); product.sales_price = Convert.ToDouble(row["sales_price"]); product.purchase_price = Convert.ToDouble(row["purchase_price"]); product.status = Convert.ToInt32(row["status"]); product.created_at = (DateTime)row["created_at"]; product.updated_at = (DateTime)row["updated_at"]; list.Add(product); } res.Datos = list; res.Estatus = Estatus.Exito; } } catch (Exception ex) { res.Mensaje = "No se pueden obtener los productos en este momento."; res.MensajeTecnico = ex.Message; } return(res); }
private void LoadOptionsProductHistory() { txtStartDate.Text = DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd"); txtEndDate.Text = DateTime.Now.ToString("yyyy-MM-dd"); try { if (Request.QueryString["productcode"].ToString() != null) { txtProductCodeSearch.Text = Common.Decrypt(Request.QueryString["productcode"].ToString(), Session.SessionID); } } catch { } string stSearchKey = txtProductCodeSearch.Text; Data.Products clsProduct = new Data.Products(); cboProductCode.DataTextField = "ProductCode"; cboProductCode.DataValueField = "ProductID"; cboProductCode.DataSource = clsProduct.ProductIDandCodeDataTable(SearchKey: stSearchKey, limit: 100); cboProductCode.DataBind(); clsProduct.CommitAndDispose(); if (cboProductCode.Items.Count == 0) { cboProductCode.Items.Add(new ListItem("No product", "0")); } cboProductCode.SelectedIndex = 0; cboProductCode_SelectedIndexChanged(null, null); try { if (Request.QueryString["productcode"].ToString() != null && cboProductCode.SelectedItem.Value != "0") { GenerateHTML(); } } catch { } }
private void LoadProduct() { string strSearchKey = txtProductCode.Text.Trim(); Data.ProductDetails clsSearchKeys = new Data.ProductDetails(); clsSearchKeys.BarCode = strSearchKey; clsSearchKeys.BarCode2 = strSearchKey; clsSearchKeys.BarCode3 = strSearchKey; clsSearchKeys.ProductCode = strSearchKey; Data.Products clsProduct = new Data.Products(); cboProductCode.DataTextField = "ProductCode"; cboProductCode.DataValueField = "ProductID"; cboProductCode.DataSource = clsProduct.ListAsDataTable(clsSearchKeys: clsSearchKeys, limit: 100); cboProductCode.DataBind(); clsProduct.CommitAndDispose(); if (cboProductCode.Items.Count == 0) { cboProductCode.Items.Insert(0, new ListItem(Constants.PLEASE_SELECT, Constants.ZERO_STRING)); } cboProductCode.SelectedIndex = 0; }
private void ReadBarCode() { try { if (string.IsNullOrEmpty(txtBarCode.Text)) { return; } Data.Products clsProducts = new Data.Products(); Data.ProductDetails clsProductDetails = clsProducts.Details(txtBarCode.Text); clsProducts.CommitAndDispose(); if (clsProductDetails.ProductID == 0) { lblProductDesc.Text = "Item not found in db"; lblProductDesc.Tag = "Item not found in db"; txtUnitCode.Text = "PCS"; } else { if (clsProductDetails.ProductCode != clsProductDetails.ProductDesc) { lblProductDesc.Text = clsProductDetails.ProductCode + ": " + clsProductDetails.ProductDesc; } else { lblProductDesc.Text = clsProductDetails.ProductDesc; } lblProductDesc.Tag = clsProductDetails.ProductCode; txtUnitCode.Text = clsProductDetails.BaseUnitCode; } } catch { } }
protected void cmdProductCode_Click(object sender, System.Web.UI.ImageClickEventArgs e) { DataClass clsDataClass = new DataClass(); Data.Products clsProduct = new Data.Products(); cboProductCode.DataTextField = "ProductCode"; cboProductCode.DataValueField = "ProductID"; string stSearchKey = txtProductCode.Text; cboProductCode.DataSource = clsProduct.ProductIDandCodeDataTable(SearchKey: stSearchKey, limit: 100); cboProductCode.DataBind(); clsProduct.CommitAndDispose(); bool bolShowCommandButtons = false; if (cboProductCode.Items.Count == 0) { cboProductCode.Items.Add(new ListItem("No product", "0")); bolShowCommandButtons = false; } else { bolShowCommandButtons = true; } imgProductHistory.Visible = bolShowCommandButtons; imgProductPriceHistory.Visible = bolShowCommandButtons; imgChangePrice.Visible = bolShowCommandButtons; imgEditNow.Visible = bolShowCommandButtons; cmdVariationSearch.Visible = bolShowCommandButtons; lblPurchasePriceHistory.Visible = bolShowCommandButtons; cboProductCode.SelectedIndex = 0; cboProductCode_SelectedIndexChanged(null, null); }
private void EnterCreditItemizePayment() { if (!SuspendTransactionAndContinue()) return; DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.EnterCreditPayment); if (loginresult == DialogResult.OK) { LoadOptions(); if (!CheckIfOKToSell(true)) return; ContactSelectWnd clsContactWnd = new ContactSelectWnd(); clsContactWnd.EnableContactAddUpdate = GetWriteAccess(mclsSalesTransactionDetails.CashierID, AccessTypes.Contacts) == System.Windows.Forms.DialogResult.OK; clsContactWnd.SysConfigDetails = mclsSysConfigDetails; clsContactWnd.TerminalDetails = mclsTerminalDetails; clsContactWnd.HasCreditOnly = true; clsContactWnd.ShowDialog(this); DialogResult result = clsContactWnd.Result; mclsContactDetails = clsContactWnd.Details; clsContactWnd.Close(); clsContactWnd.Dispose(); if (result == DialogResult.OK) { CreditsItemizeWnd creditWnd = new CreditsItemizeWnd(); creditWnd.TerminalDetails = mclsTerminalDetails; creditWnd.SysConfigDetails = mclsSysConfigDetails; creditWnd.CashierID = mclsSalesTransactionDetails.CashierID; creditWnd.CashierName = mclsSalesTransactionDetails.CashierName; creditWnd.CustomerDetails = mclsContactDetails; creditWnd.ShowDialog(this); Keys keyData = creditWnd.KeyData; string strTransactionNoToReprint = creditWnd.TransactionNoToReprint; string strTerminalNoToReprint = creditWnd.TerminalNoToReprint; decimal AmountPaid = creditWnd.AmountPayment; decimal CashPayment = creditWnd.CashPayment; decimal ChequePayment = creditWnd.ChequePayment; decimal CreditCardPayment = creditWnd.CreditCardPayment; decimal DebitPayment = creditWnd.DebitPayment; decimal BalanceAmount = creditWnd.BalanceAmount; decimal ChangeAmount = creditWnd.ChangeAmount; DataGridViewSelectedRowCollection dgvItemsSelectedRows = creditWnd.dgvItemsSelectedRows; PaymentTypes PaymentType = creditWnd.PaymentType; ArrayList arrCashPaymentDetails = creditWnd.CashPaymentDetails; ArrayList arrChequePaymentDetails = creditWnd.ChequePaymentDetails; ArrayList arrCreditCardPaymentDetails = creditWnd.CreditCardPaymentDetails; ArrayList arrDebitPaymentDetails = creditWnd.DebitPaymentDetails; result = creditWnd.Result; // do not dispose here coz the dgvItemsSelectedRows is also disposed //creditWnd.Close(); //creditWnd.Dispose(); if (result == DialogResult.OK) { if (keyData == Keys.F12) { ReprintTransaction(strTransactionNoToReprint, strTerminalNoToReprint); return; } bool boActivateSuspendedAccount = true; if (!mclsContactDetails.CreditDetails.CreditActive) { if (MessageBox.Show("Account is InActive, would you like to re-activate? Remarks: " + Environment.NewLine + mclsContactDetails.Remarks + Environment.NewLine + Environment.NewLine + "Press [yes] to automatically activate or [no] to disregard activation.", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No) boActivateSuspendedAccount = false; } Int64 iCollectionReceiptNo = 0; if (mclsSysConfigDetails.CreditPaymentType == CreditPaymentType.MPC) { decimal decRetValue = 0; if (ShowNoControl(this, out decRetValue, decimal.Parse(iCollectionReceiptNo.ToString()), "Enter Collection Receipt (CR) No.") != System.Windows.Forms.DialogResult.OK) { MessageBox.Show("Sorry you cannot issue a Credit Payment without the collection receipt no. Please enter CR No first.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { iCollectionReceiptNo = Int64.Parse(decRetValue.ToString()); } } Cursor.Current = Cursors.WaitCursor; try { LocalDB clsLocalDB = new LocalDB(mConnection, mTransaction); mConnection = clsLocalDB.Connection; mTransaction = clsLocalDB.Transaction; mclsSalesTransactionDetails = new Data.SalesTransactionDetails(); mclsSalesTransactionDetails.TransactionItemsList = new System.Collections.Generic.List<Data.SalesTransactionItemDetails>(); mclsSalesTransactionDetails.CustomerDetails = mclsContactDetails; mclsSalesTransactionDetails.TransactionStatus = TransactionStatus.CreditPayment; mclsSalesTransactionDetails.CRNo = iCollectionReceiptNo; Data.Products clsProducts = new Data.Products(mConnection, mTransaction); mConnection = clsProducts.Connection; mTransaction = clsProducts.Transaction; if (clsProducts.Details(Data.Products.DEFAULT_CREDIT_PAYMENT_BARCODE).ProductID == 0) { clsProducts.CREATE_CREDITPAYMENT_PRODUCT(); Methods.InsertAuditLog(mclsTerminalDetails, "System Administrator", AccessTypes.EnterCreditPayment, "CREDIT PAYMENT product has been created coz it's not configured"); } /************** April 21, 2006: added transaction no. ***************/ lblCustomer.Tag = mclsContactDetails.ContactID; lblCustomer.Text = mclsContactDetails.ContactName; clsEvent.AddEvent("[" + lblCashier.Text + "] Creating " + Data.Products.DEFAULT_CREDIT_PAYMENT_BARCODE + " transaction for customer: "); LoadContact(AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER, mclsContactDetails); if (!this.CreateTransaction()) return; txtBarCode.Text = Data.Products.DEFAULT_CREDIT_PAYMENT_BARCODE; ReadBarCode(); int iRow = dgItems.CurrentRowIndex; Data.SalesTransactionItemDetails clsItemDetails = getCurrentRowItemDetails(); clsItemDetails.Price = AmountPaid; clsItemDetails.Amount = AmountPaid; clsItemDetails = ComputeItemTotal(clsItemDetails); // set the grossales, vat, discounts, etc.(Details); Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction); mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction; ApplyChangeQuantityPriceAmountDetails(iRow, clsItemDetails, "Change Quantity, Price, Amount for Credit Payment"); // re-instantiate the status mclsSalesTransactionDetails.TransactionStatus = TransactionStatus.CreditPayment; mclsSalesTransactionDetails.AmountDue = AmountPaid; mclsSalesTransactionDetails.AmountPaid = AmountPaid; mclsSalesTransactionDetails.ChangeAmount = ChangeAmount; mclsSalesTransactionDetails.CashPayment = CashPayment; mclsSalesTransactionDetails.ChequePayment = ChequePayment; mclsSalesTransactionDetails.PaymentType = PaymentType; mclsSalesTransactionDetails.CRNo = iCollectionReceiptNo; // for assignment of payments mclsSalesTransactionDetails.PaymentDetails = AssignArrayListPayments(arrCashPaymentDetails, arrChequePaymentDetails, arrCreditCardPaymentDetails, null, arrDebitPaymentDetails); SavePayments(arrCashPaymentDetails, arrChequePaymentDetails, arrCreditCardPaymentDetails, null, arrDebitPaymentDetails); // save the details of credit payments SaveCreditPayments(dgvItemsSelectedRows, arrCashPaymentDetails, arrChequePaymentDetails, arrCreditCardPaymentDetails, null, arrDebitPaymentDetails, boActivateSuspendedAccount); //OpenDrawerDelegate opendrawerDel = new OpenDrawerDelegate(OpenDrawer); //Invoke(opendrawerDel); OpenDrawer(); //update the transaction table Int64 iTransactionID = Convert.ToInt64(lblTransNo.Tag); string strORNo = ""; // no need to put an OR no for credit payment coz it's already declared before clsSalesTransactions.Close(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.TerminalNo, strORNo, 0, 0, AmountPaid, AmountPaid, AmountPaid, 0, 0, 0, 0, 0, 0, 0, 0, 0, DiscountTypes.NotApplicable, 0, 0, 0, 0, 0, 0, 0, 0, 0, AmountPaid, CashPayment, ChequePayment, CreditCardPayment, 0, DebitPayment, 0, 0, 0, 0, PaymentType, null, null, 0, 0, null, null, mclsSalesTransactionDetails.CashierID, lblCashier.Text, TransactionStatus.CreditPayment); // 05Mar2015 : MPC - Update the CRNo as per Ms. Norma clsSalesTransactions.UpdateCRNo(mclsSalesTransactionDetails.BranchID, mclsSalesTransactionDetails.TerminalNo, mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.CRNo); //UpdateTerminalReportDelegate updateterminalDel = new UpdateTerminalReportDelegate(UpdateTerminalReport); UpdateTerminalReport(TransactionStatus.CreditPayment, 0, 0, AmountPaid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CashPayment, ChequePayment, CreditCardPayment, 0, DebitPayment, 0, 0, PaymentType); //UpdateCashierReportDelegate updatecashierDel = new UpdateCashierReportDelegate(UpdateCashierReport); UpdateCashierReport(TransactionStatus.CreditPayment, 0, 0, AmountPaid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CashPayment, ChequePayment, CreditCardPayment, 0, DebitPayment, 0, 0, PaymentType); // Sep 24, 2014 : update back the LastCheckInDate to min date Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction); mConnection = clsContact.Connection; mTransaction = clsContact.Transaction; clsContact.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, Constants.C_DATE_MIN_VALUE); //enable IsCreditAllowed //already done when paying creditpayment //// 3Nov2014 : automatically deposit the change if credit payment //#region Auto deposit for creditpayment //if (mclsSysConfigDetails.WillDepositChangeOfCreditPayment) //{ // InsertAuditLog(AccessTypes.Deposit, "Auto depositing change of trx #: " + mclsSalesTransactionDetails.TransactionNo + "."); // clsEvent.AddEventLn("Auto depositing change of trx #: " + mclsSalesTransactionDetails.TransactionNo + "."); // Data.Deposits clsDeposit = new Data.Deposits(mConnection, mTransaction); // mConnection = clsDeposit.Connection; mTransaction = clsDeposit.Transaction; // Data.DepositDetails clsDepositDetails = new Data.DepositDetails() // { // BranchDetails = mclsTerminalDetails.BranchDetails, // TerminalNo = mclsTerminalDetails.TerminalNo, // Amount = mclsSalesTransactionDetails.ChangeAmount, // PaymentType = mclsSalesTransactionDetails.PaymentType, // DateCreated = DateTime.Now, // CashierID = mclsSalesTransactionDetails.CashierID, // CashierName = mclsSalesTransactionDetails.CashierName, // ContactID = mclsSalesTransactionDetails.CustomerDetails.ContactID, // ContactName = mclsSalesTransactionDetails.CustomerDetails.ContactName, // Remarks = "Auto deposit from trx #: " + mclsSalesTransactionDetails.TransactionNo + ".", // CreatedOn = DateTime.Now, // LastModified = DateTime.Now // }; // clsDeposit.Insert(clsDepositDetails); // Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction); // mConnection = clsContact.Connection; mTransaction = clsContact.Transaction; // clsContact.AddDebit(clsDepositDetails.ContactID, clsDepositDetails.Amount); // clsDeposit.CommitAndDispose(); // InsertAuditLog(AccessTypes.Deposit, "Deposit: type='" + clsDepositDetails.PaymentType.ToString("G") + "' amount='" + clsDepositDetails.Amount.ToString(",##0.#0") + "'" + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode); // clsEvent.AddEventLn("Done! type=" + clsDepositDetails.PaymentType.ToString("G") + " amount=" + clsDepositDetails.Amount.ToString("#,###.#0")); //} //#endregion clsSalesTransactions.CommitAndDispose(); clsLocalDB.CommitAndDispose(); InsertAuditLog(AccessTypes.CreditPayment, "Pay credit for " + mclsContactDetails.ContactName + "." + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode); if (mclsTerminalDetails.AutoPrint == PrintingPreference.AskFirst) if (MessageBox.Show("Would you like to print this transaction?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, (mclsSysConfigDetails.isDefaultButtonYesInPrintTransaction ? MessageBoxDefaultButton.Button1 : MessageBoxDefaultButton.Button2)) == DialogResult.Yes) mclsTerminalDetails.AutoPrint = PrintingPreference.Normal; // print credit payment as normal transaction if not HP if (mclsSalesTransactionDetails.isConsignment) { // 18Feb2015 : Print DR only if the transaction is consignment clsEvent.AddEventLn(" printing delivery receipt as consginment...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintDeliveryReceipt(); } else if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.OutOfStockCustomerCode && (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoice || mclsTerminalDetails.ReceiptType == TerminalReceiptType.DeliveryReceipt || mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceAndDR)) { clsEvent.AddEventLn(" printing out of stock orders...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintOSReceipt(); } else if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.WalkInCustomerCode && (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoice || mclsTerminalDetails.ReceiptType == TerminalReceiptType.DeliveryReceipt || mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceAndDR)) { clsEvent.AddEventLn(" printing walk-in customer quote form...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintWalkInReceipt(); } else if (mclsSysConfigDetails.CreditPaymentType == CreditPaymentType.Houseware) { // do another report for credit payment if HP PrintCreditPayment(); // do this twice as per request of CN trader's and CS PrintCreditPayment(); } else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoice || mclsTerminalDetails.ReceiptType == TerminalReceiptType.DeliveryReceipt || mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceAndDR) { clsEvent.AddEventLn(" printing sales invoice...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintCollectionReceipt(); } else { // Sep 14, 2014 Control printing in mclsFilePrinter.Write //if (mclsTerminalDetails.AutoPrint == PrintingPreference.Normal) //print items if not yet printed //{ foreach (System.Data.DataRow dr in ItemDataTable.Rows) { if (dr["Quantity"].ToString() != "VOID") { string stItemNo = "" + dr["ItemNo"].ToString(); string stProductCode = "" + dr["ProductCode"].ToString(); if (dr["MatrixDescription"].ToString() != string.Empty && dr["MatrixDescription"].ToString() != null) stProductCode += "-" + dr["MatrixDescription"].ToString(); string stProductUnitCode = "" + dr["ProductUnitCode"].ToString(); decimal decQuantity = Convert.ToDecimal(dr["Quantity"]); decimal decPrice = Convert.ToDecimal(dr["Price"]); decimal decDiscount = Convert.ToDecimal(dr["Discount"]); decimal decAmount = Convert.ToDecimal(dr["Amount"]); decimal decVAT = Convert.ToDecimal(dr["VAT"]); decimal decEVAT = Convert.ToDecimal(dr["EVAT"]); decimal decPromoApplied = Convert.ToDecimal(dr["PromoApplied"]); string stDiscountCode = "" + dr["DiscountCode"].ToString(); DiscountTypes ItemDiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), dr["ItemDiscountType"].ToString()); PrintItem(stItemNo, stProductCode, stProductUnitCode, decQuantity, decPrice, decDiscount, decPromoApplied, decAmount, decVAT, decEVAT, stDiscountCode, ItemDiscountType); } } //} // Sep 14, 2014 Control printing in mclsFilePrinter.Write PrintReportFooterSection(true, TransactionStatus.CreditPayment, 0, 0, AmountPaid, 0, 0, AmountPaid, CashPayment, ChequePayment, CreditCardPayment, 0, DebitPayment, 0, 0, ChangeAmount, arrChequePaymentDetails, arrCreditCardPaymentDetails, null, arrDebitPaymentDetails); } this.LoadOptions(); } catch (Exception ex) { InsertErrorLogToFile(ex, "ERROR!!! Credit payment procedure. Err Description: "); } Cursor.Current = Cursors.Default; } creditWnd.Close(); creditWnd.Dispose(); } } }
private void ChangeQuantity() { int iOldRow = dgItems.CurrentRowIndex; int iRow = dgItems.CurrentRowIndex; if (iRow >= 0) { if (dgItems[iRow, 8].ToString() != "VOID") { if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto) { MessageBox.Show("Sorry you cannot change quantity if Auto-print is ON.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.ChangeQuantity); if (loginresult == DialogResult.OK) { Data.SalesTransactionItemDetails Details = getCurrentRowItemDetails(); decimal oldQuantity = Details.Quantity; ChangeQuantityWnd QtyWnd = new ChangeQuantityWnd(); QtyWnd.Details = Details; QtyWnd.TerminalDetails = mclsTerminalDetails; QtyWnd.ShowDialog(this); DialogResult result = QtyWnd.Result; Details = QtyWnd.Details; QtyWnd.Close(); QtyWnd.Dispose(); if (result == DialogResult.OK && oldQuantity != Details.Quantity) { Data.Products clsProduct = new Data.Products(mConnection, mTransaction); mConnection = clsProduct.Connection; mTransaction = clsProduct.Transaction; if (mboIsRefund == false) { if (lblCustomer.Text.Trim().ToUpper() != Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER) { if (Details.TransactionItemStatus != TransactionItemStatus.Return) { Data.ProductDetails det = clsProduct.Details(Details.ProductID, Details.VariationsMatrixID, mclsTerminalDetails.BranchID); decimal decProductCurrentQuantity = det.Quantity - det.ReservedQuantity + oldQuantity; // 04Sep2014 : Include exception for CreditPayment if (decProductCurrentQuantity < Details.Quantity && mclsTerminalDetails.ShowItemMoreThanZeroQty && Details.BarCode != Data.Products.DEFAULT_CREDIT_PAYMENT_BARCODE && Details.BarCode != Data.Products.DEFAULT_ADVANTAGE_CARD_MEMBERSHIP_FEE_BARCODE && Details.BarCode != Data.Products.DEFAULT_ADVANTAGE_CARD_RENEWAL_FEE_BARCODE && Details.BarCode != Data.Products.DEFAULT_ADVANTAGE_CARD_REPLACEMENT_FEE_BARCODE && Details.BarCode != Data.Products.DEFAULT_CREDIT_CARD_MEMBERSHIP_FEE_BARCODE && Details.BarCode != Data.Products.DEFAULT_CREDIT_CARD_RENEWAL_FEE_BARCODE && Details.BarCode != Data.Products.DEFAULT_SUPER_CARD_MEMBERSHIP_FEE_BARCODE && Details.BarCode != Data.Products.DEFAULT_SUPER_CARD_RENEWAL_FEE_BARCODE && Details.BarCode != Data.Products.DEFAULT_SUPER_CARD_REPLACEMENT_FEE_BARCODE) { clsProduct.CommitAndDispose(); MessageBox.Show("Sorry the quantity you entered is greater than the current stock. " + Environment.NewLine + "Current Stock: " + decProductCurrentQuantity.ToString("#,##0.#0"), "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } } } if (!mboIsRefund) { if (Details.TransactionItemStatus != TransactionItemStatus.Return) { Data.ProductUnit clsProductUnit = new Data.ProductUnit(mConnection, mTransaction); mConnection = clsProductUnit.Connection; mTransaction = clsProductUnit.Transaction; decimal decNewQuantity = clsProductUnit.GetBaseUnitValue(Details.ProductID, Details.ProductUnitID, oldQuantity); clsProduct.SubtractReservedQuantity(mclsTerminalDetails.BranchID, Details.ProductID, Details.VariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.DEDUCT_QTY_RESERVE_AND_COMMIT_CHANGE_QTY), DateTime.Now, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); } } mbodgItemRowClick = true; if (mboIsRefund) ApplyChangeQuantityPriceAmountDetails(iRow, Details, "Change Quantity"); else { Details = ApplyPromo(Details); ApplyChangeQuantityPriceAmountDetails(iRow, Details, "Change Quantity"); System.Data.DataTable dt = (System.Data.DataTable)dgItems.DataSource; for (int x = iRow + 1; x < dt.Rows.Count; x++) { dgItems.CurrentRowIndex = x; Details = getCurrentRowItemDetails(); System.Data.DataRow dr = dt.Rows[x]; if (dr["Quantity"].ToString() != "VOID" && dr["Quantity"].ToString().IndexOf("RETURN") == -1 && dr["Quantity"].ToString().IndexOf("DEMO") == -1 && dr["ProductID"].ToString() == Details.ProductID.ToString()) { Details = ApplyPromo(Details); ApplyChangeQuantityPriceAmountDetails(x, Details, "Change Quantity"); } } if (iOldRow >= 0) { dgItems.CurrentRowIndex = iOldRow; dgItems.Select(iOldRow); } } Details = getCurrentRowItemDetails(); // Added May 7, 2011 to Cater Reserved and Commit functionality // Details.Quantity = -oldQuantity + Details.Quantity; // Jul 26, 2011 Change the AddQuantity and SubtractQuantity ReservedAndCommitItem(Details, Details.TransactionItemStatus); clsProduct.CommitAndDispose(); mbodgItemRowClick = false; DisplayItemToTurretDelegate DisplayItemToTurretDel = new DisplayItemToTurretDelegate(DisplayItemToTurret); DisplayItemToTurretDel.BeginInvoke(Details.Description, Details.ProductUnitCode, Details.Quantity, Details.Price, Details.Discount, Details.PromoApplied, Details.Amount, Details.VAT, Details.EVAT, null, null); } } } } }
private void ReadBarCode() { DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.CreateTransaction); if (loginresult == DialogResult.OK) { if (!string.IsNullOrEmpty(txtBarCode.Text.Trim())) { string stBarcode = txtBarCode.Text.Trim(); decimal decQuantity = 1; // 21Jul2013 : Check if parking ticket and has already an item. if (mclsTerminalDetails.IsParkingTerminal && ItemDataTable.Rows.Count > 1) { txtBarCode.Text = ""; MessageBox.Show("Sorry you can only park 1 vehicle per transaction. ", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } // 18Feb2016 : Do not allow consignment if items > 1 and AllowMoreThan1ItemIfConsignment is FALSE if (mclsSalesTransactionDetails.isConsignment && !mclsSysConfigDetails.AllowMoreThan1ItemIfConsignment && ItemDataTable.Rows.Count >= 1) { txtBarCode.Text = ""; MessageBox.Show("Sorry you cannot tag this transaction is CONSIGNMENT. You are only allowed to consign 1 item, per transaction.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (stBarcode.EndsWith("*")) { MessageBox.Show("Sorry please scan the item after the quantity before you press the enter key.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (stBarcode.IndexOf("*") > -1) { try { decQuantity = Convert.ToDecimal(stBarcode.Substring(0, stBarcode.IndexOf("*")).Trim()); stBarcode = stBarcode.Substring(stBarcode.IndexOf("*") + 1, stBarcode.Length - (stBarcode.IndexOf("*") + 1)); } catch { MessageBox.Show("Sorry the quantity you entered is not valid. Please enter a valid quantity to purchase.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } Data.ProductPackage clsProductPackage = new Data.ProductPackage(mConnection, mTransaction); mConnection = clsProductPackage.Connection; mTransaction = clsProductPackage.Transaction; Data.Products clsProduct = new Data.Products(mConnection, mTransaction); mConnection = clsProduct.Connection; mTransaction = clsProduct.Transaction; Data.ProductPackageDetails clsProductPackageDetails = new Data.ProductPackageDetails(); Data.ProductDetails clsProductDetails = new Data.ProductDetails(); if (ProductModel.PackageID != 0) //PackageID is not zero if selection is used. { clsProductPackageDetails = clsProductPackage.Details(ProductModel.PackageID); clsProductDetails = clsProduct.Details(clsProductPackageDetails.ProductID, clsProductPackageDetails.MatrixID, mclsTerminalDetails.BranchID); } else //PackageID is zero if selection is not used. { // check if the product exist and with quantity clsProductDetails = clsProduct.Details(mclsTerminalDetails.BranchID, stBarcode, mclsTerminalDetails.ShowItemMoreThanZeroQty, decQuantity); // check if the product exist and zero quantity if (clsProductDetails.ProductID == 0) clsProductDetails = clsProduct.Details(stBarcode, mclsTerminalDetails.BranchID); // check if the product is weighted if (clsProductDetails.ProductID == 0) { if (stBarcode.Length == 12) stBarcode = "0" + stBarcode; if (stBarcode.Length > Data.Products.DEFAULT_WEIGHTED_BARCODE_CHARACTER_COUNT + 1) { clsProductDetails = clsProduct.Details(mclsTerminalDetails.BranchID, stBarcode.Remove(Data.Products.DEFAULT_WEIGHTED_BARCODE_CHARACTER_COUNT)); if (clsProductDetails.ProductID != 0) { decQuantity = (decimal.Parse(stBarcode.Remove(stBarcode.Length - 1).Remove(1, Data.Products.DEFAULT_WEIGHTED_BARCODE_CHARACTER_COUNT)) / 100) / clsProductDetails.Price; } } } // 16Apr2015 : Add a new logic for the new weighing machine // if (stBarcode.Length == 11) stBarcode = stBarcode.Remove(stBarcode.Length - 1); // get the package details if (clsProductDetails.ProductID != 0) clsProductPackageDetails = clsProductPackage.Details(clsProductDetails.PackageID); } txtBarCode.Text = ""; ProductModel.Clear(); if (clsProductDetails.ProductID != 0) { // 06Mar2015 : Override the price base on the Price Level if (mclsSysConfigDetails.EnablePriceLevel) { switch (mclsContactDetails.PriceLevel) { case PriceLevel.SRP: clsProductDetails.Price = clsProductPackageDetails.Price; break; case PriceLevel.One: clsProductDetails.Price = clsProductPackageDetails.Price1 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price1; break; case PriceLevel.Two: clsProductDetails.Price = clsProductPackageDetails.Price2 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price2; break; case PriceLevel.Three: clsProductDetails.Price = clsProductPackageDetails.Price3 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price3; break; case PriceLevel.Four: clsProductDetails.Price = clsProductPackageDetails.Price4 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price4; break; case PriceLevel.Five: clsProductDetails.Price = clsProductPackageDetails.Price5 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price5; break; case PriceLevel.WSPrice: clsProductDetails.Price = clsProductPackageDetails.WSPrice == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.WSPrice; break; default: clsProductDetails.Price = clsProductPackageDetails.Price; break; } } // 21Jul2013 Include getting of rates for parking if (mclsTerminalDetails.IsParkingTerminal) { Data.ParkingRates clsParkingRate = new Data.ParkingRates(mConnection, mTransaction); mConnection = clsParkingRate.Connection; mTransaction = clsParkingRate.Transaction; Data.ParkingRateDetails clsParkingRateDetails = clsParkingRate.Details(clsProductDetails.ProductID, DateTime.Now.ToString("dddd")); if (clsParkingRateDetails.ParkingRateID != 0) { clsProductDetails.Price = clsParkingRateDetails.MinimumStayPrice; } } if (lblCustomer.Text.Trim().ToUpper() != Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER && !mboIsRefund && clsProductDetails.Quantity - clsProductDetails.ReservedQuantity < decQuantity && mclsTerminalDetails.ShowItemMoreThanZeroQty && clsProductDetails.BarCode != Data.Products.DEFAULT_CREDIT_PAYMENT_BARCODE && clsProductDetails.BarCode != Data.Products.DEFAULT_ADVANTAGE_CARD_MEMBERSHIP_FEE_BARCODE && clsProductDetails.BarCode != Data.Products.DEFAULT_ADVANTAGE_CARD_RENEWAL_FEE_BARCODE && clsProductDetails.BarCode != Data.Products.DEFAULT_ADVANTAGE_CARD_REPLACEMENT_FEE_BARCODE && clsProductDetails.BarCode != Data.Products.DEFAULT_CREDIT_CARD_MEMBERSHIP_FEE_BARCODE && clsProductDetails.BarCode != Data.Products.DEFAULT_CREDIT_CARD_RENEWAL_FEE_BARCODE && clsProductDetails.BarCode != Data.Products.DEFAULT_SUPER_CARD_MEMBERSHIP_FEE_BARCODE && clsProductDetails.BarCode != Data.Products.DEFAULT_SUPER_CARD_RENEWAL_FEE_BARCODE && clsProductDetails.BarCode != Data.Products.DEFAULT_SUPER_CARD_REPLACEMENT_FEE_BARCODE) { if (clsProductDetails.Quantity >= decQuantity) { clsProductPackage.CommitAndDispose(); MessageBox.Show("Sorry the quantity you entered is already reserved. Current Stock: " + clsProductDetails.Quantity.ToString("#,##0.#0") + " Reserved Stock: " + clsProductDetails.ReservedQuantity.ToString("#,##0.#0"), "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { clsProductPackage.CommitAndDispose(); MessageBox.Show("Sorry the quantity you entered is greater than the current stock. " + Environment.NewLine + "Current Stock: " + clsProductDetails.Quantity.ToString("#,##0.#0"), "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } if (clsProductDetails.IsLock) { clsProductPackage.CommitAndDispose(); MessageBox.Show("Sorry this product is currently LOCKED for inventory. Please advise the inventory officer if you really want to sell this product.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Data.SalesTransactionItemDetails clsItemDetails = new Data.SalesTransactionItemDetails(); clsItemDetails.ProductID = clsProductDetails.ProductID; clsItemDetails.ProductCode = clsProductDetails.ProductCode; clsItemDetails.BarCode = clsProductDetails.BarCode; clsItemDetails.Description = clsProductDetails.ProductDesc; clsItemDetails.ProductGroupID = clsProductDetails.ProductGroupID; clsItemDetails.ProductSubGroupID = clsProductDetails.ProductSubGroupID; clsItemDetails.ProductGroup = clsProductDetails.ProductGroupName; clsItemDetails.ProductSubGroup = clsProductDetails.ProductSubGroupName; clsItemDetails.TransactionItemStatus = TransactionItemStatus.Valid; clsItemDetails.ProductUnitID = clsProductDetails.BaseUnitID; clsItemDetails.ProductUnitCode = clsProductDetails.BaseUnitCode; clsItemDetails.Quantity = decQuantity; clsItemDetails.Price = clsProductDetails.Price; clsItemDetails.Discount = 0; clsItemDetails.ItemDiscount = 0; clsItemDetails.ItemDiscountType = DiscountTypes.NotApplicable; clsItemDetails.Amount = (clsItemDetails.Quantity * clsItemDetails.Price) - (clsItemDetails.Quantity * clsItemDetails.Discount); clsItemDetails.VAT = clsProductDetails.VAT; clsItemDetails.EVAT = clsProductDetails.EVAT; clsItemDetails.LocalTax = clsProductDetails.LocalTax; clsItemDetails.TransactionItemStatus = TransactionItemStatus.Valid; clsItemDetails.PurchasePrice = clsProductDetails.PurchasePrice; clsItemDetails.PurchaseAmount = clsItemDetails.Quantity * clsItemDetails.PurchasePrice; clsItemDetails.IncludeInSubtotalDiscount = clsProductDetails.IncludeInSubtotalDiscount; clsItemDetails.IsCreditChargeExcluded = clsProductDetails.IsCreditChargeExcluded; clsItemDetails.OrderSlipPrinter1 = clsProductDetails.OrderSlipPrinter1; clsItemDetails.OrderSlipPrinter2 = clsProductDetails.OrderSlipPrinter2; clsItemDetails.OrderSlipPrinter3 = clsProductDetails.OrderSlipPrinter3; clsItemDetails.OrderSlipPrinter4 = clsProductDetails.OrderSlipPrinter4; clsItemDetails.OrderSlipPrinter5 = clsProductDetails.OrderSlipPrinter5; clsItemDetails.OrderSlipPrinted = false; clsItemDetails.PercentageCommision = clsProductDetails.PercentageCommision; clsItemDetails.Commision = clsItemDetails.Amount * (clsItemDetails.PercentageCommision / 100); clsItemDetails.RewardPoints = clsProductDetails.RewardPoints; clsItemDetails.ItemRemarks = ""; clsItemDetails.ReturnTransactionItemsID = 0; clsItemDetails.SupplierID = clsProductDetails.SupplierID; clsItemDetails.SupplierCode = clsProductDetails.SupplierCode; clsItemDetails.SupplierName = clsProductDetails.SupplierName; clsItemDetails.ProductPackageID = clsProductPackageDetails.PackageID; clsItemDetails.ProductUnitID = clsProductPackageDetails.UnitID; clsItemDetails.ProductUnitCode = clsProductPackageDetails.UnitCode; if (!mclsTerminalDetails.IsParkingTerminal) { // 06Mar2015 : Override the price base on the Price Level if (mclsSysConfigDetails.EnablePriceLevel) { switch (mclsContactDetails.PriceLevel) { case PriceLevel.SRP: clsItemDetails.Price = clsProductPackageDetails.Price; break; case PriceLevel.One: clsItemDetails.Price = clsProductPackageDetails.Price1 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price1; break; case PriceLevel.Two: clsItemDetails.Price = clsProductPackageDetails.Price2 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price2; break; case PriceLevel.Three: clsItemDetails.Price = clsProductPackageDetails.Price3 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price3; break; case PriceLevel.Four: clsItemDetails.Price = clsProductPackageDetails.Price4 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price4; break; case PriceLevel.Five: clsItemDetails.Price = clsProductPackageDetails.Price5 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price5; break; case PriceLevel.WSPrice: clsItemDetails.Price = clsProductPackageDetails.WSPrice == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.WSPrice; break; default: clsItemDetails.Price = clsProductPackageDetails.Price; break; } if (mclsContactDetails.PriceLevel != PriceLevel.SRP) { InsertAuditLog(AccessTypes.ChangePrice, "Barcode: " + clsItemDetails.BarCode + " ... Product Code:" + clsItemDetails.ProductCode + " ... Price Level:" + mclsContactDetails.PriceLevel.ToString("G") + "... SRP: " + clsProductPackageDetails.Price.ToString("#,###.#0") + " NewPrice: " + clsItemDetails.Price.ToString("#,###.#0")); } } clsItemDetails.PackageQuantity = clsProductPackageDetails.Quantity; clsItemDetails.Amount = (clsItemDetails.Quantity * clsItemDetails.Price) - (clsItemDetails.Quantity * clsItemDetails.Discount); clsItemDetails.Commision = clsItemDetails.Amount * (clsItemDetails.PercentageCommision / 100); } clsItemDetails.MatrixPackageID = clsProductPackageDetails.MatrixID; clsItemDetails.VariationsMatrixID = clsProductDetails.MatrixID; clsItemDetails.MatrixDescription = clsProductDetails.MatrixDescription; clsItemDetails = ComputeItemTotal(clsItemDetails); // set the grossales, vat, discounts, etc.(Details); if (!mboIsInTransaction) { lblTransDate.Text = DateTime.Now.ToString("MMM. dd, yyyy hh:mm:ss tt"); if (!this.CreateTransaction()) { clsProductPackage.CommitAndDispose(); return; } } AddItem(clsItemDetails); } else { MessageBox.Show("Sorry the item is not yet entered in the system. Please select the generic code for this item.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); } clsProductPackage.CommitAndDispose(); } } }
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); }
protected void cmdProductCode_Click(object sender, System.Web.UI.ImageClickEventArgs e) { DataClass clsDataClass = new DataClass(); Data.ProductColumns clsProductColumns = new Data.ProductColumns(); clsProductColumns.ProductID = true; clsProductColumns.ProductCode = true; string strSearchKey = txtProductCode.Text.Trim(); Data.ProductDetails clsSearchKeys = new Data.ProductDetails(); clsSearchKeys.BarCode = strSearchKey; clsSearchKeys.BarCode2 = strSearchKey; clsSearchKeys.BarCode3 = strSearchKey; clsSearchKeys.ProductCode = strSearchKey; Data.Products clsProduct = new Data.Products(); cboProductCode.DataTextField = "ProductCode"; cboProductCode.DataValueField = "ProductID"; cboProductCode.DataSource = clsProduct.ListAsDataTable(clsSearchKeys: clsSearchKeys, limit: 100).DefaultView; cboProductCode.DataBind(); clsProduct.CommitAndDispose(); if (cboProductCode.Items.Count == 0) cboProductCode.Items.Add(new ListItem("No product", "0")); cboProductCode.SelectedIndex = 0; cboProductCode_SelectedIndexChanged(null, null); }
private void CreditCardReplacement(CreditCardStatus pvtCreditCardStatus) { if (mboIsInTransaction) { MessageBox.Show("Sorry you cannot replace a Credit Card while there is an ongoing transaction. Please finish the transaction first.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.CreditCardChange); if (loginresult == DialogResult.OK) { try { DialogResult result; Data.ContactDetails clsContactDetails; ContactSelectWnd clsContactWnd = new ContactSelectWnd(); clsContactWnd.EnableContactAddUpdate = GetWriteAccess(mclsSalesTransactionDetails.CashierID, AccessTypes.Contacts) == System.Windows.Forms.DialogResult.OK; clsContactWnd.SysConfigDetails = mclsSysConfigDetails; clsContactWnd.TerminalDetails = mclsTerminalDetails; clsContactWnd.ContactGroupCategory = AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER; clsContactWnd.Header = "Please select customer for credit card replacement."; clsContactWnd.ShowDialog(this); clsContactDetails = clsContactWnd.Details; result = clsContactWnd.Result; clsContactWnd.Close(); clsContactWnd.Dispose(); if (result != DialogResult.OK) { return; } if (clsContactDetails.ContactID == Constants.ZERO || clsContactDetails.ContactID == Constants.C_RETAILPLUS_CUSTOMERID) { return; } clsEvent.AddEvent("[" + lblCashier.Text + "] Replacing credit card..."); Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction); mConnection = clsContact.Connection; mTransaction = clsContact.Transaction; clsContactDetails = clsContact.Details(clsContactDetails.ContactID); Data.ContactDetails clsGuarantor = clsContact.Details(clsContactDetails.CreditDetails.GuarantorID); clsContact.CommitAndDispose(); if (clsContactDetails.CreditDetails.CreditCardNo == string.Empty || clsContactDetails.CreditDetails.CreditCardNo == null) { clsEvent.AddEventLn("Cancelled!"); clsEvent.AddEventLn(clsContactDetails.ContactName + " has no valid Credit Card yet. "); MessageBox.Show(clsContactDetails.ContactName + " has no valid Credit Card yet. Please select another customer.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } clsEvent.AddEvent("[" + lblCashier.Text + "] Replacing credit card #: " + clsContactDetails.CreditDetails.CreditCardNo + " of " + clsContactDetails.ContactName + " as " + pvtCreditCardStatus.ToString("G")); string strOldCreditCardNo = clsContactDetails.CreditDetails.CreditCardNo; ContactCreditWnd clsContactCreditWnd = new ContactCreditWnd(); if (pvtCreditCardStatus == CreditCardStatus.Replaced_Lost) clsContactCreditWnd.Header = "Credit Card Replacement of LOST CARD "; else if (pvtCreditCardStatus == CreditCardStatus.Replaced_Expired) clsContactCreditWnd.Header = "Credit Card Replacement of EXPIRED CARD "; clsContactCreditWnd.CardTypeDetails = clsContactDetails.CreditDetails.CardTypeDetails; clsContactCreditWnd.Guarantor = clsGuarantor; clsContactCreditWnd.ContactDetails = clsContactDetails; clsContactCreditWnd.CreditCardStatus = pvtCreditCardStatus; clsContactCreditWnd.TerminalDetails = mclsTerminalDetails; clsContactCreditWnd.ShowDialog(this); result = clsContactCreditWnd.Result; clsContactDetails = clsContactCreditWnd.ContactDetails; clsContactCreditWnd.Close(); clsContactCreditWnd.Dispose(); if (result == DialogResult.OK) { Data.Products clsProducts = new Data.Products(mConnection, mTransaction); mConnection = clsProducts.Connection; mTransaction = clsProducts.Transaction; string strProductBarcode = Data.Products.DEFAULT_CREDIT_CARD_REPLACEMENT_FEE_BARCODE; //override if with Guarantor if (clsContactDetails.CreditDetails.CardTypeDetails.WithGuarantor) strProductBarcode = Data.Products.DEFAULT_SUPER_CARD_REPLACEMENT_FEE_BARCODE; if (clsProducts.Details(strProductBarcode).ProductID == 0) { if (!clsContactDetails.CreditDetails.CardTypeDetails.WithGuarantor) clsProducts.CREATE_CREDIT_CARD_REPLACEMENT_FEE_BARCODE_PRODUCT(); else clsProducts.CREATE_SUPER_CARD_REPLACEMENT_FEE_BARCODE_PRODUCT(); Methods.InsertAuditLog(mclsTerminalDetails, "System Administrator", AccessTypes.CreditCardChange, strProductBarcode + " product has been created coz it's not configured"); } clsProducts.CommitAndDispose(); MessageBox.Show("Credit Card No: " + strOldCreditCardNo + " has been replaced with new card #: " + clsContactDetails.CreditDetails.CreditCardNo + ".", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information); clsEvent.AddEventLn("Done!", true); clsEvent.AddEventLn("Credit Card No: " + strOldCreditCardNo + " has been replaced with new card #: " + clsContactDetails.CreditDetails.CreditCardNo + ".", true); LocalDB clsLocalDB = new LocalDB(mConnection, mTransaction); mConnection = clsLocalDB.Connection; mTransaction = clsLocalDB.Transaction; clsEvent.AddEvent("[" + lblCashier.Text + "] Creating " + strProductBarcode + "transaction for customer: "); LoadContact(AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER, clsContactDetails); if (!this.CreateTransaction()) return; txtBarCode.Text = strProductBarcode; ReadBarCode(); int iRow = dgItems.CurrentRowIndex; txtBarCode.Text = ""; CloseTransaction(); clsLocalDB.CommitAndDispose(); } else { clsEvent.AddEventLn("Cancelled!"); } } catch (Exception ex) { InsertErrorLogToFile(ex, "ERROR!!! Replacing internal credit card."); } Cursor.Current = Cursors.Default; } }
/// <summary> /// Returns true : all have purchases /// Returns false : some doesnt have purchases /// </summary> /// <param name="clsContactDetails"></param> /// <param name="decCredit"></param> /// <returns></returns> public bool AutoAdjustCredit(Data.ContactDetails clsContactDetails, decimal decCredit) { bool boRetValue = false; try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; System.Data.DataTable dtT = new System.Data.DataTable("tblTemp"); Int64 intContactID = clsContactDetails.ContactID; // pay all the purchases, we will do the reverse to arrive at equal credit in IC_ICC string SQL = "UPDATE tblCreditPayment SET AmountPaid = Amount WHERE ContactID=@ContactID;"; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@ContactID", intContactID); cmd.CommandText = SQL; base.ExecuteNonQuery(cmd); // do not return, finish all the necessary adjustments //if (decCredit == 0) return true; // return true SQL = "UPDATE tblContacts SET Credit = @Credit WHERE ContactID=@ContactID;"; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@ContactID", intContactID); cmd.Parameters.AddWithValue("@Credit", decCredit); cmd.CommandText = SQL; base.ExecuteNonQuery(cmd); Data.Contacts clsContacts = new Data.Contacts(base.Connection, base.Transaction); Data.ProductDetails clsProductDetails = new Data.Products(base.Connection, base.Transaction).DetailsByCode(1, "IC IMPORTED TRX"); Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(base.Connection, base.Transaction); Data.CreditCardPayments clsCreditCardPayments = new Data.CreditCardPayments(base.Connection, base.Transaction); Data.SalesTransactionDetails clsSalesTransactionDetails; string strTerminalNo = "9995"; Int32 intBranchID = 1; string TransactionNo = DateTime.Now.ToString("yyyyMmddHHmmss").PadLeft(14, '0'); DateTime CreatedOn = new DateTime(2014, 01, 01); DateTime TransactionDate = new DateTime(2014, 01, 01); DateTime DateClosed = new DateTime(2014, 01, 01); SQL = "SELECT * FROM tblCreditPayment WHERE ContactID=@ContactID AND CreditReasonID <> 8 ORDER BY CreditDate DESC;"; //8=deposits cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@ContactID", intContactID); cmd.CommandText = SQL; dtT = new System.Data.DataTable("tblTemp"); base.MySqlDataAdapterFill(cmd, dtT); Int32 dtTRowsCount = dtT.Rows.Count; //use this when reinsert is called below ReInsert: if (dtTRowsCount == 0) { // no purchases but with credit decimal SubTotal = decCredit; TransactionNo = DateTime.Now.ToString("yyyyMmddHHmmss").PadLeft(14, '0'); //#region Insert to tblTransactions SQL = "INSERT INTO tblTransactions(TransactionNo, CustomerID, CustomerName, CashierID, CashierName, TerminalNo, BranchID, BranchCode, TransactionDate, " + "DateSuspended, DateResumed, TransactionStatus, SubTotal, " + "AmountPaid, CashPayment, ChequePayment, " + "CreditCardPayment, CreditPayment, DateClosed, PaymentType, " + "WaiterID, WaiterName, AgentID, AgentName, CreatedByID, CreatedByName, " + "AgentDepartmentName, AgentPositionName, ReleasedDate, RewardPointsPayment, " + "RewardConvertedPayment, PaxNo, CreditChargeAmount, TransactionType, isConsignment, " + "DataSource, CustomerGroupName, CreatedOn, ORNo, " + "NetSales, ChargeType, ItemSold, QuantitySold, " + "ContactCheckInDate, GrossSales)VALUES("; SQL += "@TransactionNo, @CustomerID, @CustomerName, @CashierID, @CashierName, @TerminalNo, @BranchID, @BranchCode, @TransactionDate, " + "@DateSuspended, @DateResumed, @TransactionStatus, @SubTotal, " + "@AmountPaid, @CashPayment, @ChequePayment, " + "@CreditCardPayment, @CreditPayment, @DateClosed, @PaymentType, " + "@WaiterID, @WaiterName, @AgentID, @AgentName, @CreatedByID, @CreatedByName, " + "@AgentDepartmentName, @AgentPositionName, @ReleasedDate, @RewardPointsPayment, " + "@RewardConvertedPayment, @PaxNo, @CreditChargeAmount, @TransactionType, @isConsignment, " + "@DataSource, @CustomerGroupName, @CreatedOn, @ORNo, " + "@NetSales, @ChargeType, @ItemSold, @QuantitySold, " + "@ContactCheckInDate, @GrossSales)"; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@TransactionNo", TransactionNo); cmd.Parameters.AddWithValue("@CustomerID", clsContactDetails.ContactID); cmd.Parameters.AddWithValue("@CustomerName", clsContactDetails.ContactName); cmd.Parameters.AddWithValue("@CashierID", 1); cmd.Parameters.AddWithValue("@CashierName", "Auto AdjUser"); cmd.Parameters.AddWithValue("@TerminalNo", strTerminalNo); cmd.Parameters.AddWithValue("@BranchID", intBranchID); cmd.Parameters.AddWithValue("@BranchCode", "Main"); cmd.Parameters.AddWithValue("@TransactionDate", TransactionDate); cmd.Parameters.AddWithValue("@DateSuspended", Constants.C_DATE_MIN_VALUE); cmd.Parameters.AddWithValue("@DateResumed", Constants.C_DATE_MIN_VALUE); cmd.Parameters.AddWithValue("@TransactionStatus", 1); cmd.Parameters.AddWithValue("@SubTotal", SubTotal); cmd.Parameters.AddWithValue("@AmountPaid", SubTotal); cmd.Parameters.AddWithValue("@CashPayment", 0); cmd.Parameters.AddWithValue("@ChequePayment", 0); cmd.Parameters.AddWithValue("@CreditCardPayment", SubTotal); cmd.Parameters.AddWithValue("@CreditPayment", 0); cmd.Parameters.AddWithValue("@DateClosed", DateClosed); cmd.Parameters.AddWithValue("@PaymentType", 2); cmd.Parameters.AddWithValue("@WaiterID", 2); cmd.Parameters.AddWithValue("@WaiterName", "RetailPlus Default"); cmd.Parameters.AddWithValue("@AgentID", 1); cmd.Parameters.AddWithValue("@AgentName", "RetailPlus Agent â„¢"); cmd.Parameters.AddWithValue("@CreatedByID", 1); cmd.Parameters.AddWithValue("@CreatedByName", "Auto AdjUser"); cmd.Parameters.AddWithValue("@AgentDepartmentName", "System Default Department"); cmd.Parameters.AddWithValue("@AgentPositionName", "System Default Position"); cmd.Parameters.AddWithValue("@ReleasedDate", Constants.C_DATE_MIN_VALUE); cmd.Parameters.AddWithValue("@RewardPointsPayment", 0); cmd.Parameters.AddWithValue("@RewardConvertedPayment", 0); cmd.Parameters.AddWithValue("@PaxNo", 1); cmd.Parameters.AddWithValue("@CreditChargeAmount", 0); cmd.Parameters.AddWithValue("@TransactionType", 0); cmd.Parameters.AddWithValue("@isConsignment", 0); cmd.Parameters.AddWithValue("@DataSource", "IC_NO_ITN"); cmd.Parameters.AddWithValue("@CustomerGroupName", clsContactDetails.ContactGroupName); cmd.Parameters.AddWithValue("@CreatedOn", CreatedOn); cmd.Parameters.AddWithValue("@ORNo", TransactionNo); cmd.Parameters.AddWithValue("@NetSales", SubTotal); cmd.Parameters.AddWithValue("@ChargeType", 0); cmd.Parameters.AddWithValue("@ItemSold", 1); cmd.Parameters.AddWithValue("@QuantitySold", 1); cmd.Parameters.AddWithValue("@ContactCheckInDate", CreatedOn); cmd.Parameters.AddWithValue("@GrossSales", SubTotal); cmd.CommandText = SQL; base.ExecuteNonQuery(cmd); //#endregion clsSalesTransactionDetails = clsSalesTransactions.Details(TransactionNo, strTerminalNo, intBranchID); //#region Insert to tblTransactionItems SQL = "SELECT * FROM tblTransactionItems WHERE TransactionID=@TransactionID LIMIT 1;"; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@TransactionID", clsSalesTransactionDetails.TransactionID); cmd.CommandText = SQL; dtT = new System.Data.DataTable("tblTemp"); base.MySqlDataAdapterFill(cmd, dtT); if (dtT.Rows.Count == 0) { SQL = "INSERT INTO tblTransactionItems(TransactionID, ProductID, ProductCode, BarCode, Description, ProductUnitID, ProductUnitCode, " + "Quantity, Price, SellingPrice, Discount, ItemDiscount, ItemDiscountType, Amount, " + "ProductGroup, ProductSubGroup, TransactionItemStatus, DiscountCode, DiscountRemarks, ProductPackageID, " + "PackageQuantity, DataSource, CreatedOn, GrossSales)VALUES("; SQL += "@TransactionID, @ProductID, @ProductCode, @BarCode, @Description, @ProductUnitID, @ProductUnitCode, " + "@Quantity, @Price, @SellingPrice, @Discount, @ItemDiscount, @ItemDiscountType, @Amount, " + "@ProductGroup, @ProductSubGroup, @TransactionItemStatus, @DiscountCode, @DiscountRemarks, @ProductPackageID, " + "@PackageQuantity, @DataSource, @CreatedOn, @GrossSales)"; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@TransactionID", clsSalesTransactionDetails.TransactionID); cmd.Parameters.AddWithValue("@ProductID", clsProductDetails.ProductID); cmd.Parameters.AddWithValue("@ProductCode", clsProductDetails.ProductCode); cmd.Parameters.AddWithValue("@BarCode", clsProductDetails.BarCode); cmd.Parameters.AddWithValue("@Description", clsProductDetails.ProductDesc); cmd.Parameters.AddWithValue("@ProductUnitID", clsProductDetails.BaseUnitID); cmd.Parameters.AddWithValue("@ProductUnitCode", clsProductDetails.BaseUnitCode); cmd.Parameters.AddWithValue("@Quantity", 1); cmd.Parameters.AddWithValue("@Price", SubTotal); cmd.Parameters.AddWithValue("@SellingPrice", SubTotal); cmd.Parameters.AddWithValue("@Discount", 0); cmd.Parameters.AddWithValue("@ItemDiscount", 0); cmd.Parameters.AddWithValue("@ItemDiscountType", 0); cmd.Parameters.AddWithValue("@Amount", SubTotal); cmd.Parameters.AddWithValue("@ProductGroup", clsProductDetails.ProductGroupName); cmd.Parameters.AddWithValue("@ProductSubGroup", clsProductDetails.ProductSubGroupCode); cmd.Parameters.AddWithValue("@TransactionItemStatus", 0); cmd.Parameters.AddWithValue("@DiscountCode", ""); cmd.Parameters.AddWithValue("@DiscountRemarks", ""); cmd.Parameters.AddWithValue("@ProductPackageID", clsProductDetails.PackageID); cmd.Parameters.AddWithValue("@PackageQuantity", 1); cmd.Parameters.AddWithValue("@DataSource", "AutoAdjust"); cmd.Parameters.AddWithValue("@CreatedOn", CreatedOn); cmd.Parameters.AddWithValue("@GrossSales", SubTotal); cmd.CommandText = SQL; base.ExecuteNonQuery(cmd); } //#endregion //#region Insert to tblCreditCardPayment SQL = "SELECT * FROM tblCreditCardPayment WHERE BranchID=@BranchID AND TransactionNo=@TransactionNo AND TerminalNo=@TerminalNo LIMIT 1;"; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@TransactionNo", clsSalesTransactionDetails.TransactionNo); cmd.Parameters.AddWithValue("@TerminalNo", clsSalesTransactionDetails.TerminalNo); cmd.Parameters.AddWithValue("@BranchID", clsSalesTransactionDetails.BranchID); cmd.CommandText = SQL; dtT = new System.Data.DataTable("tblTemp"); base.MySqlDataAdapterFill(cmd, dtT); if (dtT.Rows.Count == 0) { SQL = "INSERT INTO tblCreditCardPayment(TransactionID, Amount, CardTypeID, CardTypeCode, CardTypeName, CardNo, CardHolder, ValidityDates, " + "Remarks, TransactionNo, CreatedOn, TerminalNo, BranchID, AdditionalCharge, " + "ContactID, GuarantorID, TransactionDate, CashierName)VALUES("; SQL += "@TransactionID, @Amount, @CardTypeID, @CardTypeCode, @CardTypeName, @CardNo, @CardHolder, @ValidityDates, " + "@Remarks, @TransactionNo, @CreatedOn, @TerminalNo, @BranchID, @AdditionalCharge, " + "@ContactID, @GuarantorID, @TransactionDate, @CashierName)"; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@TransactionID", clsSalesTransactionDetails.TransactionID); cmd.Parameters.AddWithValue("@Amount", SubTotal); cmd.Parameters.AddWithValue("@CardTypeID", clsContactDetails.CreditDetails.CardTypeDetails.CardTypeID); cmd.Parameters.AddWithValue("@CardTypeCode", clsContactDetails.CreditDetails.CardTypeDetails.CardTypeCode); cmd.Parameters.AddWithValue("@CardTypeName", clsContactDetails.CreditDetails.CardTypeDetails.CardTypeName); cmd.Parameters.AddWithValue("@CardNo", clsContactDetails.CreditDetails.CreditCardNo); cmd.Parameters.AddWithValue("@CardHolder", clsContactDetails.ContactName); cmd.Parameters.AddWithValue("@ValidityDates", clsContactDetails.CreditDetails.ExpiryDate.ToString("MMddyy")); cmd.Parameters.AddWithValue("@Remarks", ""); cmd.Parameters.AddWithValue("@TransactionNo", TransactionNo); cmd.Parameters.AddWithValue("@CreatedOn", CreatedOn); cmd.Parameters.AddWithValue("@TerminalNo", strTerminalNo); cmd.Parameters.AddWithValue("@BranchID", intBranchID); cmd.Parameters.AddWithValue("@AdditionalCharge", 0); cmd.Parameters.AddWithValue("@ContactID", clsContactDetails.ContactID); cmd.Parameters.AddWithValue("@GuarantorID", clsContactDetails.CreditDetails.GuarantorID); cmd.Parameters.AddWithValue("@TransactionDate", TransactionDate); cmd.Parameters.AddWithValue("@CashierName", clsSalesTransactionDetails.CashierName); cmd.CommandText = SQL; base.ExecuteNonQuery(cmd); } //#endregion //#region Insert to tblCreditPayment SQL = "SELECT * FROM tblCreditPayment WHERE BranchID=@BranchID AND TransactionNo=@TransactionNo AND TerminalNo = @TerminalNo LIMIT 1;"; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@TransactionNo", clsSalesTransactionDetails.TransactionNo); cmd.Parameters.AddWithValue("@TerminalNo", clsSalesTransactionDetails.TerminalNo); cmd.Parameters.AddWithValue("@BranchID", clsSalesTransactionDetails.BranchID); cmd.CommandText = SQL; dtT = new System.Data.DataTable("tblTemp"); base.MySqlDataAdapterFill(cmd, dtT); if (dtT.Rows.Count == 0) { CreditCardPaymentDetails[] clsCreditCardPaymentDetails = clsCreditCardPayments.Details(1, strTerminalNo, clsSalesTransactionDetails.TransactionID); SQL = "INSERT INTO tblCreditPayment(TransactionID, Amount, ContactID, Remarks, AmountPaid, " + "TransactionNo, CreditDate, CreditBefore, CreditAfter, " + "CreditReason, TerminalNo, CashierName, AmountPaidCuttOffMonth, " + "CreatedOn, BranchID, CreditCardPaymentID, CreditCardTypeID, CreditReasonID)VALUES("; SQL += "@TransactionID, @Amount, @ContactID, @Remarks, @AmountPaid, " + "@TransactionNo, @CreditDate, @CreditBefore, @CreditAfter, " + "@CreditReason, @TerminalNo, @CashierName, @AmountPaidCuttOffMonth, " + "@CreatedOn, @BranchID, @CreditCardPaymentID, @CreditCardTypeID, @CreditReasonID)"; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@TransactionID", clsSalesTransactionDetails.TransactionID); cmd.Parameters.AddWithValue("@Amount", SubTotal); cmd.Parameters.AddWithValue("@ContactID", clsContactDetails.ContactID); cmd.Parameters.AddWithValue("@Remarks", "Deliquent purchases before 2014May "); cmd.Parameters.AddWithValue("@AmountPaid", 0); cmd.Parameters.AddWithValue("@TransactionNo", TransactionNo); cmd.Parameters.AddWithValue("@CreditDate", CreatedOn); cmd.Parameters.AddWithValue("@CreditBefore", 0); cmd.Parameters.AddWithValue("@CreditAfter", SubTotal); cmd.Parameters.AddWithValue("@CreditReason", "Deliquent purchases before 2014May "); cmd.Parameters.AddWithValue("@TerminalNo", strTerminalNo); cmd.Parameters.AddWithValue("@CashierName", clsSalesTransactionDetails.CashierName); cmd.Parameters.AddWithValue("@AmountPaidCuttOffMonth", 0); cmd.Parameters.AddWithValue("@CreatedOn", CreatedOn); cmd.Parameters.AddWithValue("@BranchID", intBranchID); cmd.Parameters.AddWithValue("@CreditCardPaymentID", clsCreditCardPaymentDetails[0].CreditCardPaymentID); cmd.Parameters.AddWithValue("@CreditCardTypeID", clsContactDetails.CreditDetails.CardTypeDetails.CardTypeID); cmd.Parameters.AddWithValue("@CreditReasonID", 0); cmd.CommandText = SQL; base.ExecuteNonQuery(cmd); boRetValue = false; } } else { foreach (System.Data.DataRow drCredit in dtT.Rows) { decimal decTrxCredit = decimal.Parse(drCredit["Amount"].ToString()); Int64 CreditPaymentID = Int64.Parse(drCredit["CreditPaymentID"].ToString()); if (decCredit > decTrxCredit) { SQL = "UPDATE tblCreditPayment SET AmountPaid=(AmountPaid - @AmountPaid) WHERE ContactID=@ContactID AND CreditPaymentID=@CreditPaymentID;"; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@AmountPaid", decTrxCredit); cmd.Parameters.AddWithValue("@ContactID", intContactID); cmd.Parameters.AddWithValue("@CreditPaymentID", CreditPaymentID); cmd.CommandText = SQL; base.ExecuteNonQuery(cmd); decCredit -= decTrxCredit; } else { SQL = "UPDATE tblCreditPayment SET AmountPaid= (AmountPaid - @AmountPaid) WHERE ContactID=@ContactID AND CreditPaymentID=@CreditPaymentID;"; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@AmountPaid", decCredit); cmd.Parameters.AddWithValue("@ContactID", intContactID); cmd.Parameters.AddWithValue("@CreditPaymentID", CreditPaymentID); cmd.CommandText = SQL; base.ExecuteNonQuery(cmd); boRetValue = true; decCredit = 0; break; } } // meaning there is still credit but no purchases if (decCredit > 0) { dtTRowsCount = 0; goto ReInsert; //#endregion } } } catch (Exception ex) { throw base.ThrowException(ex); } return boRetValue; }
public void CloseTransaction(Data.SalesTransactionItemDetails mTopItemDetails, decimal AmountPaid, decimal ChangeAmount, decimal BalanceAmount, decimal CashPayment, decimal ChequePayment, decimal CreditCardPayment, decimal CreditPayment, decimal CreditChargeAmount, decimal DebitPayment, decimal RewardConvertedPayment, decimal RewardPointsPayment, PaymentTypes PaymentType, ArrayList arrCashPaymentDetails, ArrayList arrChequePaymentDetails, ArrayList arrCreditCardPaymentDetails, ArrayList arrCreditPaymentDetails, ArrayList arrDebitPaymentDetails) { mclsSalesTransactionDetails.AmountPaid = AmountPaid; mclsSalesTransactionDetails.ChangeAmount = ChangeAmount; mclsSalesTransactionDetails.CashPayment = CashPayment; mclsSalesTransactionDetails.ChequePayment = ChequePayment; mclsSalesTransactionDetails.CreditCardPayment = CreditCardPayment; mclsSalesTransactionDetails.CreditPayment = CreditPayment; // include credit charge amount mclsSalesTransactionDetails.CreditChargeAmount = CreditChargeAmount; mclsSalesTransactionDetails.AmountDue += mclsSalesTransactionDetails.CreditChargeAmount; mclsSalesTransactionDetails.DebitPayment = DebitPayment; mclsSalesTransactionDetails.RewardPointsPayment = RewardConvertedPayment; /*** * Nov 04, 2011 : for payments using reward points ***/ mclsSalesTransactionDetails.RewardPointsPayment = RewardPointsPayment; mclsSalesTransactionDetails.RewardConvertedPayment = RewardConvertedPayment; /*** * Oct 17, 2011 : Move this code here. * check if will print transaction or not before opening any connection to database. ***/ mboDoNotPrintTransactionDate = false; if (mclsTerminalDetails.AutoPrint == PrintingPreference.AskFirst) { if (MessageBox.Show("Would you like to print this transaction?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, (mclsSysConfigDetails.isDefaultButtonYesInPrintTransaction ? MessageBoxDefaultButton.Button1 : MessageBoxDefaultButton.Button2)) == DialogResult.Yes) { mclsTerminalDetails.AutoPrint = PrintingPreference.Normal; if (mclsSysConfigDetails.WillAskDoNotPrintTransactionDate) if (MessageBox.Show("Would you like the system NOT to print the transaction date?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes) mboDoNotPrintTransactionDate = true; } } // Mar 17, 2009 // open drawer first before printing. //OpenDrawerDelegate opendrawerDel = new OpenDrawerDelegate(OpenDrawer); //Invoke(opendrawerDel); OpenDrawer(); Cursor.Current = Cursors.WaitCursor; clsEvent.AddEventLn("[" + mclsSalesTransactionDetails.CashierName + "] saving payments...", true); // for assignment of payments mclsSalesTransactionDetails.PaymentDetails = AssignArrayListPayments(arrCashPaymentDetails, arrChequePaymentDetails, arrCreditCardPaymentDetails, arrCreditPaymentDetails, arrDebitPaymentDetails); // start a connection for the database. //update the transaction table Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction); mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction; SavePayments(arrCashPaymentDetails, arrChequePaymentDetails, arrCreditCardPaymentDetails, arrCreditPaymentDetails, arrDebitPaymentDetails); if (mclsSalesTransactionDetails.CreditChargeAmount != 0) { //Aug 30, 2014 delete need to move this from here to mainwnd clsSalesTransactions.UpdateCreditChargeAmount(mclsSalesTransactionDetails.BranchID, mclsSalesTransactionDetails.TerminalNo, mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.CreditChargeAmount); } Data.Products clsProduct = new Data.Products(mConnection, mTransaction); mConnection = clsProduct.Connection; mTransaction = clsProduct.Transaction; TransactionStatus clsTransactionStatus = TransactionStatus.Closed; if (mTopItemDetails.BarCode == Data.Products.DEFAULT_CREDIT_PAYMENT_BARCODE) { clsTransactionStatus = TransactionStatus.CreditPayment; } else if (mboIsRefund) { clsTransactionStatus = TransactionStatus.Refund; if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.OutOfStockCustomerCode) { clsTransactionStatus = TransactionStatus.ClosedOutOfStockRefund; } else if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.WalkInCustomerCode) { clsTransactionStatus = TransactionStatus.ClosedWalkInRefund; } else if (mclsSalesTransactionDetails.isConsignment) { clsTransactionStatus = TransactionStatus.ConsignmentRefund; } } else if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.OutOfStockCustomerCode) { clsTransactionStatus = TransactionStatus.ClosedOutOfStock; } else if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.WalkInCustomerCode) { clsTransactionStatus = TransactionStatus.ClosedWalkIn; } else if (mclsSalesTransactionDetails.isConsignment) { clsTransactionStatus = TransactionStatus.Consignment; } if (mboIsRefund && !mclsTerminalDetails.IsParkingTerminal) { #region mboIsRefund clsEvent.AddEventLn("[" + mclsSalesTransactionDetails.CashierName + "] updating refund terminal no...", true, mclsSysConfigDetails.WillWriteSystemLog); clsSalesTransactions.UpdateTerminalNo(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.TerminalNo); if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.OutOfStockCustomerCode || mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.WalkInCustomerCode) { // 20Feb2015 : Added as an exemption clsEvent.AddEventLn(" no need to apply an ORNo. Customer is " + mclsSalesTransactionDetails.CustomerDetails.ContactCode, true, mclsSysConfigDetails.WillWriteSystemLog); } else if (!mclsSalesTransactionDetails.isConsignment) { // 04Sep2014 : Added to put as OR No - Void NO-OR mclsSalesTransactionDetails.ORNo = clsSalesTransactions.CreateORNo(mclsTerminalDetails.ORSeriesBranchID, mclsTerminalDetails.ORSeriesTerminalNo); clsEvent.AddEventLn(" applying ORNo".PadRight(15) + ":" + mclsSalesTransactionDetails.ORNo, true, mclsSysConfigDetails.WillWriteSystemLog); } clsSalesTransactions.Refund(clsTransactionStatus, mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.ORNo, -mclsSalesTransactionDetails.ItemSold, -mclsSalesTransactionDetails.QuantitySold, -mclsSalesTransactionDetails.GrossSales, -mclsSalesTransactionDetails.SubTotal, -mclsSalesTransactionDetails.NetSales, -mclsSalesTransactionDetails.ItemsDiscount, -mclsSalesTransactionDetails.SNRItemsDiscount, -mclsSalesTransactionDetails.PWDItemsDiscount, -mclsSalesTransactionDetails.OtherItemsDiscount, -mclsSalesTransactionDetails.Discount, -mclsSalesTransactionDetails.SNRDiscount, -mclsSalesTransactionDetails.PWDDiscount, -mclsSalesTransactionDetails.OtherDiscount, mclsSalesTransactionDetails.TransDiscount, mclsSalesTransactionDetails.TransDiscountType, -mclsSalesTransactionDetails.VAT, -mclsSalesTransactionDetails.VATableAmount, -mclsSalesTransactionDetails.ZeroRatedSales, - mclsSalesTransactionDetails.NonVATableAmount, -mclsSalesTransactionDetails.VATExempt, -mclsSalesTransactionDetails.EVAT, -mclsSalesTransactionDetails.EVATableAmount, -mclsSalesTransactionDetails.NonEVATableAmount, -mclsSalesTransactionDetails.LocalTax, -mclsSalesTransactionDetails.AmountPaid, -CashPayment, -ChequePayment, -CreditCardPayment, -CreditPayment, -DebitPayment, -RewardPointsPayment, -RewardConvertedPayment, -BalanceAmount, -ChangeAmount, PaymentType, mclsSalesTransactionDetails.DiscountCode, mclsSalesTransactionDetails.DiscountRemarks, -mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.ChargeAmount, mclsSalesTransactionDetails.ChargeCode, mclsSalesTransactionDetails.ChargeRemarks, mclsSalesTransactionDetails.CashierID, mclsSalesTransactionDetails.CashierName); //UpdateTerminalReportDelegate updateterminalDel = new UpdateTerminalReportDelegate(UpdateTerminalReport); clsEvent.AddEventLn("[" + mclsSalesTransactionDetails.CashierName + "] updating refund terminal report...", true, mclsSysConfigDetails.WillWriteSystemLog); UpdateTerminalReport(clsTransactionStatus, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, CashPayment, ChequePayment, CreditCardPayment, CreditPayment, DebitPayment, RewardPointsPayment, RewardConvertedPayment, PaymentType); //UpdateCashierReportDelegate updatecashierDel = new UpdateCashierReportDelegate(UpdateCashierReport); clsEvent.AddEventLn("[" + mclsSalesTransactionDetails.CashierName + "] updating redunf cashier report...", true, mclsSysConfigDetails.WillWriteSystemLog); UpdateCashierReport(clsTransactionStatus, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, CashPayment, ChequePayment, CreditCardPayment, CreditPayment, DebitPayment, RewardPointsPayment, RewardConvertedPayment, PaymentType); // Sep 24, 2014 : update back the LastCheckInDate to min date Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction); mConnection = clsContact.Connection; mTransaction = clsContact.Transaction; clsContact.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, Constants.C_DATE_MIN_VALUE); // Sep 14, 2014 Control printing in mclsFilePrinter.Write //if (mclsTerminalDetails.AutoPrint == PrintingPreference.Normal) //print items if not yet printed //{ clsEvent.AddEventLn("[" + mclsSalesTransactionDetails.CashierName + "] printing refund items...", true, mclsSysConfigDetails.WillWriteSystemLog); foreach (System.Data.DataRow dr in ItemDataTable.Rows) { if (dr["Quantity"].ToString() != "VOID") { string stItemNo = "" + dr["ItemNo"].ToString(); string stProductCode = "" + dr["ProductCode"].ToString(); if (dr["MatrixDescription"].ToString() != string.Empty && dr["MatrixDescription"].ToString() != null) stProductCode += "-" + dr["MatrixDescription"].ToString(); string stProductUnitCode = "" + dr["ProductUnitCode"].ToString(); decimal decQuantity = Convert.ToDecimal(dr["Quantity"]); decimal decPrice = Convert.ToDecimal(dr["Price"]); decimal decDiscount = Convert.ToDecimal(dr["Discount"]); decimal decAmount = Convert.ToDecimal(dr["Amount"]); decimal decVAT = Convert.ToDecimal(dr["VAT"]); decimal decEVAT = Convert.ToDecimal(dr["EVAT"]); decimal decPromoApplied = Convert.ToDecimal(dr["PromoApplied"]); string stDiscountCode = "" + dr["DiscountCode"].ToString(); DiscountTypes ItemDiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), dr["ItemDiscountType"].ToString()); if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default) PrintItem(stItemNo, stProductCode, stProductUnitCode, decQuantity, decPrice, decDiscount, decPromoApplied, decAmount, decVAT, decEVAT, stDiscountCode, ItemDiscountType); } } if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default) PrintReportFooterSection(true, TransactionStatus.Refund, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.AmountPaid, CashPayment, ChequePayment, CreditCardPayment, CreditPayment, DebitPayment, RewardPointsPayment, RewardConvertedPayment, ChangeAmount, arrChequePaymentDetails, arrCreditCardPaymentDetails, arrCreditPaymentDetails, arrDebitPaymentDetails); //} // Sep 14, 2014 Control printing in mclsFilePrinter.Write // Sep 24, 2011 Lemuel E. Aceron // Added order slip wherein all punch items will not change sales and inventory // a customer named ORDER SLIP should be defined in contacts // lblCustomer.Text.Trim().ToUpper() != Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER // Added May 7, 2011 to Cater Reserved and Commit functionality // !mclsTerminalDetails.ReservedAndCommit // Sep 14, 2013: Remove the reserved and commit. //if (lblCustomer.Text.Trim().ToUpper() != Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER && !mclsTerminalDetails.ReservedAndCommit && !mclsTerminalDetails.IsParkingTerminal) if (mclsSalesTransactionDetails.CustomerName.Trim().ToUpper() != Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER && !mclsTerminalDetails.IsParkingTerminal && mclsSalesTransactionDetails.CustomerDetails.ContactCode.Trim() != mclsSysConfigDetails.OutOfStockCustomerCode) // do not change the inventory if OUT_OF_STOCK_CUSTOMER_CODE { clsEvent.AddEventLn("[" + mclsSalesTransactionDetails.CashierName + "] adding the refund items quantity to inv...", true, mclsSysConfigDetails.WillWriteSystemLog); Data.ProductUnit clsProductUnit = new Data.ProductUnit(mConnection, mTransaction); mConnection = clsProductUnit.Connection; mTransaction = clsProductUnit.Transaction; foreach (System.Data.DataRow dr in ItemDataTable.Rows) { Int64 lProductID = Convert.ToInt64(dr["ProductID"]); Int64 lVariationsMatrixID = Convert.ToInt64(dr["VariationsMatrixID"]); Int32 iProductUnitID = Convert.ToInt32(dr["ProductUnitID"]); decimal decQuantity = 0; decimal decPackageQuantity = 0; decimal decNewQuantity = 0; if (dr["Quantity"].ToString().IndexOf("RETURN") != -1) { decimal decPrice = Convert.ToDecimal(dr["Price"]); decimal decPurchasePrice = Convert.ToDecimal(dr["PurchasePrice"]); decimal decDiscount = Convert.ToDecimal(dr["Discount"]); decimal decAmount = -Convert.ToDecimal(dr["Amount"]); decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - RETURN", "").Trim()); decPackageQuantity = Convert.ToDecimal(dr["PackageQuantity"]); decNewQuantity = clsProductUnit.GetBaseUnitValue(lProductID, iProductUnitID, decQuantity * decPackageQuantity); decNewQuantity = -decNewQuantity; clsEvent.AddEventLn(" subtracting refund-return item: prdid-" + lProductID.ToString() + " to inv: qty-" + decNewQuantity.ToString() + "...", true, mclsSysConfigDetails.WillWriteSystemLog); clsProduct.SubtractQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.DEDUCT_REFUND_RETURN) + " @ " + (decAmount / decNewQuantity).ToString("#,##0.#0") + " Buying: " + decPurchasePrice.ToString("#,##0.#0") + " Orig Selling: " + decPrice.ToString("#,##0.#0") + " Discount: " + (decPrice - (decAmount / decNewQuantity)).ToString("#,##0.#0") + " to " + mclsSalesTransactionDetails.CustomerName + " Ter#: " + mclsTerminalDetails.TerminalNo, DateTime.Now, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); } else if (dr["Quantity"].ToString().IndexOf("DEMO") != -1) { decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - DEMO", "").Trim()); decPackageQuantity = Convert.ToDecimal(dr["PackageQuantity"]); decNewQuantity = clsProductUnit.GetBaseUnitValue(lProductID, iProductUnitID, decQuantity * decPackageQuantity); clsEvent.AddEventLn(" adding refund-demo item: prdid-" + lProductID.ToString() + " from inv/rsrvd: qty-" + decNewQuantity.ToString() + "...", true, mclsSysConfigDetails.WillWriteSystemLog); clsProduct.AddQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.ADD_REFUND_DEMO_ITEM) + " Ter#: " + mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.TransactionDate, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); } else if (dr["Quantity"].ToString() != "VOID") { decQuantity = Convert.ToDecimal(dr["Quantity"]); decPackageQuantity = Convert.ToDecimal(dr["PackageQuantity"]); decNewQuantity = clsProductUnit.GetBaseUnitValue(lProductID, iProductUnitID, decQuantity * decPackageQuantity); clsEvent.AddEventLn(" adding refund item: prdid-" + lProductID.ToString() + " from inv/rsrvd: qty-" + decNewQuantity.ToString() + "...", true, mclsSysConfigDetails.WillWriteSystemLog); clsProduct.AddQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.ADD_REFUND_ITEM) + " Ter#: " + mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.TransactionDate, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); } } } #endregion } else if (!mboIsRefund) { #region Normal and ParkingTerminal clsEvent.AddEventLn(" closing transaction...", true, mclsSysConfigDetails.WillWriteSystemLog); if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.OutOfStockCustomerCode || mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.WalkInCustomerCode) { // 20Feb2015 : Added as an exemption clsEvent.AddEventLn(" no need to apply an ORNo. Customer is " + mclsSalesTransactionDetails.CustomerDetails.ContactCode, true, mclsSysConfigDetails.WillWriteSystemLog); } else if (!mclsSalesTransactionDetails.isConsignment) { // 04Sep2014 : Added to put as OR No - Void NO-OR if (mTopItemDetails.BarCode == Data.Products.DEFAULT_CREDIT_PAYMENT_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_ADVANTAGE_CARD_MEMBERSHIP_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_ADVANTAGE_CARD_RENEWAL_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_ADVANTAGE_CARD_REPLACEMENT_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_CREDIT_CARD_MEMBERSHIP_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_CREDIT_CARD_RENEWAL_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_SUPER_CARD_MEMBERSHIP_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_SUPER_CARD_RENEWAL_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_SUPER_CARD_REPLACEMENT_FEE_BARCODE) { clsEvent.AddEventLn(" no need to apply an ORNo. Product is " + mTopItemDetails.BarCode, true, mclsSysConfigDetails.WillWriteSystemLog); } else { mclsSalesTransactionDetails.ORNo = clsSalesTransactions.CreateORNo(mclsTerminalDetails.ORSeriesBranchID, mclsTerminalDetails.ORSeriesTerminalNo); clsEvent.AddEventLn(" applying ORNo".PadRight(15) + ":" + mclsSalesTransactionDetails.ORNo, true, mclsSysConfigDetails.WillWriteSystemLog); } } // clsSalesTransactions.UpdateTerminalNo(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.TerminalNo); // remove the above. Include the TerminalNo in clsSalesTransactions.Close below clsSalesTransactions.Close(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.TerminalNo, mclsSalesTransactionDetails.ORNo, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.GrossSales, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.NetSales, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.SNRDiscount, mclsSalesTransactionDetails.PWDDiscount, mclsSalesTransactionDetails.OtherDiscount, mclsSalesTransactionDetails.TransDiscount, mclsSalesTransactionDetails.TransDiscountType, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, mclsSalesTransactionDetails.AmountPaid, CashPayment, ChequePayment, CreditCardPayment, CreditPayment, DebitPayment, RewardPointsPayment, RewardConvertedPayment, BalanceAmount, ChangeAmount, PaymentType, mclsSalesTransactionDetails.DiscountCode, mclsSalesTransactionDetails.DiscountRemarks, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.ChargeAmount, mclsSalesTransactionDetails.ChargeCode, mclsSalesTransactionDetails.ChargeRemarks, mclsSalesTransactionDetails.CashierID, mclsSalesTransactionDetails.CashierName, clsTransactionStatus); //UpdateTerminalReportDelegate updateterminalDel = new UpdateTerminalReportDelegate(UpdateTerminalReport); clsEvent.AddEventLn(" updating terminal report...", true, mclsSysConfigDetails.WillWriteSystemLog); UpdateTerminalReport(clsTransactionStatus, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, CashPayment, ChequePayment, CreditCardPayment, CreditPayment, DebitPayment, RewardPointsPayment, RewardConvertedPayment, PaymentType); //UpdateCashierReportDelegate updatecashierDel = new UpdateCashierReportDelegate(UpdateCashierReport); clsEvent.AddEventLn(" updating cashier's report...", true, mclsSysConfigDetails.WillWriteSystemLog); UpdateCashierReport(clsTransactionStatus, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, CashPayment, ChequePayment, CreditCardPayment, CreditPayment, DebitPayment, RewardPointsPayment, RewardConvertedPayment, PaymentType); // Sep 24, 2014 : update back the LastCheckInDate to min date Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction); mConnection = clsContact.Connection; mTransaction = clsContact.Transaction; clsContact.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, Constants.C_DATE_MIN_VALUE); // Sep 24, 2011 Lemuel E. Aceron // Added order slip wherein all punch items will not change sales and inventory // a customer named ORDER SLIP should be defined in contacts //if (lblCustomer.Text.Trim().ToUpper() != Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER) // Added May 7, 2011 to Cater Reserved and Commit functionality // !mclsTerminalDetails.ReservedAndCommit if (mclsTerminalDetails.IsParkingTerminal) { clsEvent.AddEventLn(" adding back the parking slot to inv...", true, mclsSysConfigDetails.WillWriteSystemLog); Data.ProductUnit clsProductUnit = new Data.ProductUnit(mConnection, mTransaction); mConnection = clsProductUnit.Connection; mTransaction = clsProductUnit.Transaction; Data.ProductVariationsMatrix clsProductVariationsMatrix = new Data.ProductVariationsMatrix(mConnection, mTransaction); foreach (System.Data.DataRow dr in ItemDataTable.Rows) { long lProductID = Convert.ToInt64(dr["ProductID"]); long lVariationsMatrixID = Convert.ToInt64(dr["VariationsMatrixID"]); int iProductUnitID = Convert.ToInt32(dr["ProductUnitID"]); decimal decQuantity = 0; decimal decPackageQuantity = 0; decimal decNewQuantity = 0; decimal decPrice = Convert.ToDecimal(dr["Price"]); decimal decPurchasePrice = Convert.ToDecimal(dr["PurchasePrice"]); if ((dr["Quantity"].ToString().IndexOf("RETURN") == -1) && (dr["Quantity"].ToString() != "VOID")) { decQuantity = Convert.ToDecimal(dr["Quantity"]); decPackageQuantity = Convert.ToDecimal(dr["PackageQuantity"]); decNewQuantity = clsProductUnit.GetBaseUnitValue(lProductID, iProductUnitID, decQuantity * decPackageQuantity); clsProduct.AddQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.PARKING_OUT), mclsSalesTransactionDetails.TransactionDate, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); } } } else if (mclsSalesTransactionDetails.CustomerName.Trim().ToUpper() != Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER && !mclsTerminalDetails.IsParkingTerminal && mclsSalesTransactionDetails.CustomerDetails.ContactCode.Trim() != mclsSysConfigDetails.OutOfStockCustomerCode) // do not change the inventory if OUT_OF_STOCK_CUSTOMER_CODE { Data.ProductUnit clsProductUnit = new Data.ProductUnit(mConnection, mTransaction); mConnection = clsProductUnit.Connection; mTransaction = clsProductUnit.Transaction; Data.ProductVariationsMatrix clsProductVariationsMatrix = new Data.ProductVariationsMatrix(mConnection, mTransaction); Data.SalesTransactionItems clsSalesTransactionItems = new Data.SalesTransactionItems(mConnection, mTransaction); foreach (System.Data.DataRow dr in ItemDataTable.Rows) { long lProductID = Convert.ToInt64(dr["ProductID"]); long lVariationsMatrixID = Convert.ToInt64(dr["VariationsMatrixID"]); int iProductUnitID = Convert.ToInt32(dr["ProductUnitID"]); decimal decQuantity = 0; decimal decPackageQuantity = 0; decimal decNewQuantity = 0; decimal decPrice = Convert.ToDecimal(dr["Price"]); decimal decPurchasePrice = Convert.ToDecimal(dr["PurchasePrice"]); decimal decDiscount = Convert.ToDecimal(dr["Discount"]); decimal decAmount = Convert.ToDecimal(dr["Amount"]); if (dr["Quantity"].ToString().IndexOf("RETURN") != -1) { decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - RETURN", "").Trim()); decPackageQuantity = Convert.ToDecimal(dr["PackageQuantity"]); decNewQuantity = clsProductUnit.GetBaseUnitValue(lProductID, iProductUnitID, decQuantity * decPackageQuantity); clsEvent.AddEventLn(" adding return item: prdid-" + lProductID.ToString() + " to inv: qty-" + decNewQuantity.ToString() + "...", true, mclsSysConfigDetails.WillWriteSystemLog); clsProduct.AddQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.ADD_RETURN_ITEM) + " Ter#: " + mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.TransactionDate, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); // 28JUn2015 : Add the RefReturnTransactionItemsID to the Int64 intReturnTransactionItemsID = Convert.ToInt64(dr["ReturnTransactionItemsID"]); Int64 intTransactionItemsID = Convert.ToInt64(dr["TransactionItemsID"]); clsSalesTransactionItems.UpdateRefReturnTransactionItemsID(intReturnTransactionItemsID, intTransactionItemsID); } else if (dr["Quantity"].ToString().IndexOf("DEMO") != -1) { decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - DEMO", "").Trim()); decPackageQuantity = Convert.ToDecimal(dr["PackageQuantity"]); decNewQuantity = clsProductUnit.GetBaseUnitValue(lProductID, iProductUnitID, decQuantity * decPackageQuantity); clsEvent.AddEventLn(" subtracting demo item: prdid-" + lProductID.ToString() + " from inv/rsrvd: qty-" + decNewQuantity.ToString() + "...", true, mclsSysConfigDetails.WillWriteSystemLog); clsProduct.SubtractQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.DEDUCT_DEMO_RETAIL) + " @ " + (decAmount / decNewQuantity).ToString("#,##0.#0") + " Buying: " + decPurchasePrice.ToString("#,##0.#0") + " Orig Selling: " + decPrice.ToString("#,##0.#0") + " Discount: " + (decPrice - (decAmount / decNewQuantity)).ToString("#,##0.#0") + " to " + mclsSalesTransactionDetails.CustomerName + " Ter#: " + mclsTerminalDetails.TerminalNo, DateTime.Now, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); clsProduct.SubtractReservedQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.DEDUCT_DEMO_RETAIL) + " @ " + (decAmount / decNewQuantity).ToString("#,##0.#0") + " Buying: " + decPurchasePrice.ToString("#,##0.#0") + " Orig Selling: " + decPrice.ToString("#,##0.#0") + " Discount: " + (decPrice - (decAmount / decNewQuantity)).ToString("#,##0.#0") + " to " + mclsSalesTransactionDetails.CustomerName + " Ter#: " + mclsTerminalDetails.TerminalNo, DateTime.Now, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); } else if (dr["Quantity"].ToString() != "VOID") { decQuantity = Convert.ToDecimal(dr["Quantity"]); decPackageQuantity = Convert.ToDecimal(dr["PackageQuantity"]); decNewQuantity = clsProductUnit.GetBaseUnitValue(lProductID, iProductUnitID, decQuantity * decPackageQuantity); clsEvent.AddEventLn(" subtracting sold item: prdid-" + lProductID.ToString() + " from inv/rsrvd: qty-" + decNewQuantity.ToString() + "...", true, mclsSysConfigDetails.WillWriteSystemLog); clsProduct.SubtractQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.DEDUCT_SOLD_RETAIL) + " @ " + (decAmount / decNewQuantity).ToString("#,##0.#0") + " Buying: " + decPurchasePrice.ToString("#,##0.#0") + " Orig Selling: " + decPrice.ToString("#,##0.#0") + " Discount: " + (decPrice - (decAmount / decNewQuantity)).ToString("#,##0.#0") + " to " + mclsSalesTransactionDetails.CustomerName + " Ter#: " + mclsTerminalDetails.TerminalNo, DateTime.Now, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); clsProduct.SubtractReservedQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.DEDUCT_SOLD_RETAIL) + " @ " + (decAmount / decNewQuantity).ToString("#,##0.#0") + " Buying: " + decPurchasePrice.ToString("#,##0.#0") + " Orig Selling: " + decPrice.ToString("#,##0.#0") + " Discount: " + (decPrice - (decAmount / decNewQuantity)).ToString("#,##0.#0") + " to " + mclsSalesTransactionDetails.CustomerName + " Ter#: " + mclsTerminalDetails.TerminalNo, DateTime.Now, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); } } } // Nov 1, 2011 : Lemu - disabled reward points if product is exempted clsEvent.AddEventLn(" checking if rewards is enabled...", true, mclsSysConfigDetails.WillWriteSystemLog); if (mclsSalesTransactionDetails.RewardCardActive && mclsTerminalDetails.RewardPointsDetails.EnableRewardPoints) { // Note: mTopItemDetails is already set in the MainWnd.CloseTransaction() if (mTopItemDetails.BarCode == Data.Products.DEFAULT_CREDIT_PAYMENT_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_ADVANTAGE_CARD_MEMBERSHIP_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_ADVANTAGE_CARD_RENEWAL_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_ADVANTAGE_CARD_REPLACEMENT_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_CREDIT_CARD_MEMBERSHIP_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_CREDIT_CARD_RENEWAL_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_SUPER_CARD_MEMBERSHIP_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_SUPER_CARD_RENEWAL_FEE_BARCODE || mTopItemDetails.BarCode == Data.Products.DEFAULT_SUPER_CARD_REPLACEMENT_FEE_BARCODE) { mclsTerminalDetails.RewardPointsDetails.EnableRewardPoints = false; } } #endregion } // Oct 23, 2011 : Lemu - Added Reward Points #region Reward Payment if (mclsSalesTransactionDetails.RewardPointsPayment != 0) { clsEvent.AddEventLn(" deducting rewards payment...", true, mclsSysConfigDetails.WillWriteSystemLog); // this should comes before earning of points otherwise this will be wrong. Data.ContactReward clsContactReward = new Data.ContactReward(mConnection, mTransaction); mConnection = clsContactReward.Connection; mTransaction = clsContactReward.Transaction; clsContactReward.DeductPoints(mclsSalesTransactionDetails.CustomerID, mclsSalesTransactionDetails.RewardPointsPayment); string strReason = "Redeemed " + mclsSalesTransactionDetails.RewardPointsPayment + " using Reward Card #: " + mclsSalesTransactionDetails.RewardCardNo; clsContactReward.AddMovement(mclsSalesTransactionDetails.CustomerID, mclsSalesTransactionDetails.TransactionDate, mclsSalesTransactionDetails.RewardCurrentPoints, -mclsSalesTransactionDetails.RewardPointsPayment, mclsSalesTransactionDetails.RewardCurrentPoints - mclsSalesTransactionDetails.RewardPointsPayment, mclsSalesTransactionDetails.RewardCardExpiry, strReason, mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.CashierName, mclsSalesTransactionDetails.TransactionNo); mclsSalesTransactionDetails.RewardPreviousPoints = mclsSalesTransactionDetails.RewardCurrentPoints; mclsSalesTransactionDetails.RewardCurrentPoints -= mclsSalesTransactionDetails.RewardPointsPayment; mclsSalesTransactionDetails.RewardEarnedPoints = 0; clsEvent.AddEventLn(" printing rewards slip...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintRewardsRedemptionSlip(); // do this after printing so that it will be equal mclsSalesTransactionDetails.RewardPreviousPoints = mclsSalesTransactionDetails.RewardCurrentPoints; } #endregion #region Add reward points to customer if (mclsTerminalDetails.RewardPointsDetails.EnableRewardPoints && mclsSalesTransactionDetails.RewardCardActive && mclsSalesTransactionDetails.RewardsCustomerID != Constants.C_RETAILPLUS_CUSTOMERID && mclsTerminalDetails.RewardPointsDetails.RewardPointsMinimum <= mclsSalesTransactionDetails.AmountDue) { decimal decRewardPoints = 0; try { decRewardPoints = (mclsSalesTransactionDetails.AmountDue - mclsSalesTransactionDetails.RewardConvertedPayment) / mclsTerminalDetails.RewardPointsDetails.RewardPointsEvery * mclsTerminalDetails.RewardPointsDetails.RewardPoints; // round down points if RoundDown is enabled if (mclsTerminalDetails.RewardPointsDetails.RoundDownRewardPoints) decRewardPoints = decimal.Floor(decRewardPoints); //Data.Product clsProduct //long lngProductID = 0; foreach (System.Data.DataRow dr in ItemDataTable.Rows) { //lngProductID = decimal.Parse(dr["RewardPoints"].ToString()); //decRewardPoints += clsProduct.Details1(mclsTerminalDetails.BranchID, lngProductID).RewardPoints; decRewardPoints += decimal.Parse(dr["RewardPoints"].ToString()); } } catch { } mclsSalesTransactionDetails.RewardEarnedPoints = decRewardPoints; mclsSalesTransactionDetails.RewardCurrentPoints = mclsSalesTransactionDetails.RewardPreviousPoints + mclsSalesTransactionDetails.RewardEarnedPoints; Data.ContactReward clsContactReward = new Data.ContactReward(mConnection, mTransaction); mConnection = clsContactReward.Connection; mTransaction = clsContactReward.Transaction; clsContactReward.AddPoints(mclsSalesTransactionDetails.RewardsCustomerID, mclsSalesTransactionDetails.RewardEarnedPoints); clsContactReward.AddPurchase(mclsSalesTransactionDetails.RewardsCustomerID, mclsSalesTransactionDetails.AmountDue); string strReason = "Purchase " + mclsSalesTransactionDetails.AmountDue.ToString("#,##0.#0") + " using Reward Card #: " + mclsSalesTransactionDetails.RewardCardNo; clsContactReward.AddMovement(mclsSalesTransactionDetails.RewardsCustomerID, mclsSalesTransactionDetails.TransactionDate, mclsSalesTransactionDetails.RewardPreviousPoints, mclsSalesTransactionDetails.RewardEarnedPoints, mclsSalesTransactionDetails.RewardCurrentPoints, mclsSalesTransactionDetails.RewardCardExpiry, strReason, mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.CashierName, mclsSalesTransactionDetails.TransactionNo); } #endregion #region 3Nov2014 : autoamtically deposit the change if credit payment //#region Auto deposit for creditpayment //if (clsTransactionStatus == TransactionStatus.CreditPayment && mclsSysConfigDetails.WillDepositChangeOfCreditPayment) //{ // InsertAuditLog(AccessTypes.Deposit, "Auto depositing change of trx #: " + mclsSalesTransactionDetails.TransactionNo + "."); // clsEvent.AddEventLn("Auto depositing change of trx #: " + mclsSalesTransactionDetails.TransactionNo + ".", true); // Data.Deposits clsDeposit = new Data.Deposits(mConnection, mTransaction); // mConnection = clsDeposit.Connection; mTransaction = clsDeposit.Transaction; // Data.DepositDetails clsDepositDetails = new Data.DepositDetails() // { // BranchDetails = mclsTerminalDetails.BranchDetails, // TerminalNo = mclsTerminalDetails.TerminalNo, // Amount = mclsSalesTransactionDetails.ChangeAmount, // PaymentType = mclsSalesTransactionDetails.PaymentType, // DateCreated = DateTime.Now, // CashierID = mclsSalesTransactionDetails.CashierID, // CashierName = mclsSalesTransactionDetails.CashierName, // ContactID = mclsSalesTransactionDetails.CustomerDetails.ContactID, // ContactName = mclsSalesTransactionDetails.CustomerDetails.ContactName, // Remarks = "Auto deposit from trx #: " + mclsSalesTransactionDetails.TransactionNo + ".", // CreatedOn = DateTime.Now, // LastModified = DateTime.Now // }; // clsDeposit.Insert(clsDepositDetails); // clsContact = new Data.Contacts(mConnection, mTransaction); // mConnection = clsContact.Connection; mTransaction = clsContact.Transaction; // clsContact.AddDebit(clsDepositDetails.ContactID, clsDepositDetails.Amount); // clsDeposit.CommitAndDispose(); // InsertAuditLog(AccessTypes.Deposit, "Deposit: type='" + clsDepositDetails.PaymentType.ToString("G") + "' amount='" + clsDepositDetails.Amount.ToString(",##0.#0") + "'" + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode); // clsEvent.AddEventLn("Done! type=" + clsDepositDetails.PaymentType.ToString("G") + " amount=" + clsDepositDetails.Amount.ToString("#,###.#0"), true); //} //#endregion #endregion // 22Nov2014 : remove the merge tables when closed or void if (mclsTerminalDetails.WithRestaurantFeatures) RemoveFromMergeTable(mclsSalesTransactionDetails.CustomerDetails.ContactCode); // commit the transactions here. // in case error s encoutered n printing. transaction is already committed. clsEvent.AddEventLn(" commiting transaction to database...", true, mclsSysConfigDetails.WillWriteSystemLog); clsSalesTransactions.CommitAndDispose(); /*** * print the transaction ***/ #region printing if (mclsTerminalDetails.AutoPrint != PrintingPreference.AskFirst) { try { if (mclsSalesTransactionDetails.isConsignment) { // 18Feb2015 : Print DR only if the transaction is consignment clsEvent.AddEventLn(" printing delivery receipt as consginment...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintDeliveryReceipt(); } else if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.OutOfStockCustomerCode && (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoice || mclsTerminalDetails.ReceiptType == TerminalReceiptType.DeliveryReceipt || mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceAndDR)) { clsEvent.AddEventLn(" printing out of stock orders...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintOSReceipt(); } else if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.WalkInCustomerCode && (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoice || mclsTerminalDetails.ReceiptType == TerminalReceiptType.DeliveryReceipt || mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceAndDR)) { clsEvent.AddEventLn(" printing walk-in customer quote form...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintWalkInReceipt(); } else if (mclsSalesTransactionDetails.TransactionStatus == TransactionStatus.CreditPayment && mclsSysConfigDetails.CreditPaymentType == CreditPaymentType.Houseware) { // do another report for credit payment if HP PrintCreditPayment(); // do this twice as per request of CN trader's and CS PrintCreditPayment(); } else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoice) { clsEvent.AddEventLn(" printing sales invoice...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintSalesInvoice(); } else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.DeliveryReceipt) { clsEvent.AddEventLn(" printing delivery receipt...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintDeliveryReceipt(); } else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceAndDR) { clsEvent.AddEventLn(" printing sales invoice & delivery receipt...", true, mclsSysConfigDetails.WillWriteSystemLog); if (mclsSalesTransactionDetails.TransactionStatus != TransactionStatus.Void) { clsEvent.AddEventLn(" will not print sales invoice. trx is void...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintSalesInvoice(); } PrintDeliveryReceipt(); } // 10Feb2010 : print sales invoice to LX as required by Wireless Link else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceForLX300Printer) { clsEvent.AddEventLn(" printing sales invoice for LX300...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintSalesInvoiceToLX(TerminalReceiptType.SalesInvoiceForLX300Printer); } //Added May 11, 2010 else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceOrDR) { clsEvent.AddEventLn(" printing sales invoice or OR...", true, mclsSysConfigDetails.WillWriteSystemLog); if (mclsSalesTransactionDetails.CashPayment != 0 || mclsSalesTransactionDetails.CreditCardPayment != 0) PrintSalesInvoice(); if (mclsSalesTransactionDetails.ChequePayment != 0 || mclsSalesTransactionDetails.CreditPayment != 0) PrintDeliveryReceipt(); } //Added January 17, 2011 else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceForLX300PlusPrinter) { clsEvent.AddEventLn(" printing sales invoice for LX300 Plus...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintSalesInvoiceToLX(TerminalReceiptType.SalesInvoiceForLX300PlusPrinter); } //Added February 22, 2011 else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceForLX300PlusAmazon) { clsEvent.AddEventLn(" printing sales invoice for LX300 Plus Amazon...", true, mclsSysConfigDetails.WillWriteSystemLog); PrintSalesInvoiceToLX(TerminalReceiptType.SalesInvoiceForLX300PlusAmazon); } else if (!mboIsRefund) // do not print if refund coz its already printed above { // Sep 14, 2014 Control printing in mclsFilePrinter.Write //if (mclsTerminalDetails.AutoPrint == PrintingPreference.Normal) //print items if not yet printed //{ clsEvent.AddEventLn(" printing items to POS printer...", true, mclsSysConfigDetails.WillWriteSystemLog); foreach (System.Data.DataRow dr in ItemDataTable.Rows) { string stItemNo = "" + dr["ItemNo"].ToString(); string stProductUnitCode = "" + dr["ProductUnitCode"].ToString(); decimal decPrice = Convert.ToDecimal(dr["Price"]); decimal decDiscount = Convert.ToDecimal(dr["Discount"]); decimal decAmount = Convert.ToDecimal(dr["Amount"]); decimal decVAT = Convert.ToDecimal(dr["VAT"]); decimal decEVAT = Convert.ToDecimal(dr["EVAT"]); decimal decPromoApplied = Convert.ToDecimal(dr["PromoApplied"]); string stProductCode = "" + dr["ProductCode"].ToString(); if (dr["MatrixDescription"].ToString() != string.Empty && dr["MatrixDescription"].ToString() != null) stProductCode += "-" + dr["MatrixDescription"].ToString(); decimal decQuantity = 0; string stDiscountCode = "" + dr["DiscountCode"].ToString(); DiscountTypes ItemDiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), dr["ItemDiscountType"].ToString()); if (dr["Quantity"].ToString().IndexOf("RETURN") != -1) { stProductCode = "" + dr["ProductCode"].ToString() + "-RET"; decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - RETURN", "").Trim()); decAmount = -decAmount; } else if (dr["Quantity"].ToString().IndexOf("DEMO") != -1) { stProductCode = "" + dr["ProductCode"].ToString() + "-DEMO"; decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - DEMO", "").Trim()); decAmount = 0; } else if (dr["Quantity"].ToString() != "VOID") { decQuantity = Convert.ToDecimal(dr["Quantity"]); } if (dr["Quantity"].ToString().IndexOf("VOID") != -1) { if (mclsTerminalDetails.WillPrintVoidItem) if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default) PrintItem(stItemNo, stProductCode, stProductUnitCode, decQuantity, decPrice, decDiscount, decPromoApplied, decAmount, decVAT, decEVAT, stDiscountCode, ItemDiscountType); } else { if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default) PrintItem(stItemNo, stProductCode, stProductUnitCode, decQuantity, decPrice, decDiscount, decPromoApplied, decAmount, decVAT, decEVAT, stDiscountCode, ItemDiscountType); } } if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default) { PrintReportFooterSection(true, clsTransactionStatus, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.AmountPaid, CashPayment, ChequePayment, CreditCardPayment, CreditPayment, DebitPayment, RewardPointsPayment, RewardConvertedPayment, ChangeAmount, arrChequePaymentDetails, arrCreditCardPaymentDetails, arrCreditPaymentDetails, arrDebitPaymentDetails); // print the charge slip if not refund and will print if (mclsTerminalDetails.WillPrintChargeSlip && !mboIsRefund) { clsEvent.AddEventLn(" printing charge slip...", true, mclsSysConfigDetails.WillWriteSystemLog); // Nov 05, 2011 : Print Charge Slip PrintChargeSlip(ChargeSlipType.Customer); PrintChargeSlip(ChargeSlipType.Original); if (mclsTerminalDetails.IncludeCreditChargeAgreement && mclsSalesTransactionDetails.CustomerDetails.CreditDetails.CardTypeDetails.WithGuarantor) //if (!mclsTerminalDetails.IncludeCreditChargeAgreement) //do not print the guarantor if there is no agreement printed { PrintChargeSlip(ChargeSlipType.Guarantor); } } } //} // Sep 14, 2014 Control printing in mclsFilePrinter.Write } } catch (Exception ex) { clsEvent.AddErrorEventLn(ex); clsEvent.AddEventLn("Error printing transaction no: " + mclsSalesTransactionDetails.TransactionNo + ". Already commited in the database.", true); } } #endregion // print all the coupon's #region Printing of coupons // print coupon's only for customer's with reward cards as per request of Sir Guy, // sa susunod ilalagay na sya sa selection if (mclsContactDetails.ContactID != Constants.C_RETAILPLUS_CUSTOMERID && mclsContactDetails.RewardDetails.ContactID != 0) { Data.PromoBySupplier clsPromoBySupplier = new Data.PromoBySupplier(mConnection, mTransaction); mConnection = clsPromoBySupplier.Connection; mTransaction = clsPromoBySupplier.Transaction; try { clsEvent.AddEventLn("Printing coupon if necessary...", true); Data.PromoBySupplierDetails clsPromoBySupplierDetails = clsPromoBySupplier.getPromoBySupplierID(); if (clsPromoBySupplierDetails.PromoBySupplierID != 0) { Data.PromoBySupplierItems clsPromoBySupplierItems = new Data.PromoBySupplierItems(mConnection, mTransaction); mConnection = clsPromoBySupplierItems.Connection; mTransaction = clsPromoBySupplierItems.Transaction; Data.ProductGroup clsProductGroup = new Data.ProductGroup(mConnection, mTransaction); mConnection = clsProductGroup.Connection; mTransaction = clsProductGroup.Transaction; Data.ProductSubGroup clsProductSubGroup = new Data.ProductSubGroup(mConnection, mTransaction); mConnection = clsProductSubGroup.Connection; mTransaction = clsProductSubGroup.Transaction; decimal decPromoBySupplierValue = -1; decimal decItemAmount = 0; string strCouponRemarks = ""; var lstItems = mclsSalesTransactionDetails.TransactionItemsList; Int64 ProductGroupID = 0, ProductSubGroupID = 0; switch (clsPromoBySupplierDetails.PromoLevel) { case PromoLevel.All: lstItems = mclsSalesTransactionDetails.TransactionItemsList; decPromoBySupplierValue = -1; decItemAmount = mclsSalesTransactionDetails.TransactionItemsList.Sum(x => x.Amount); if (clsPromoBySupplierItems.ApplyPromoBySupplierValue(clsPromoBySupplierDetails, 0, 0, 0, 0, 0, out decPromoBySupplierValue, out strCouponRemarks, mclsSalesTransactionDetails.BranchID)) { if (decPromoBySupplierValue == 0 || decPromoBySupplierValue <= decItemAmount) { //print it PrintCoupon(lstItems[0], strCouponRemarks); } } break; case PromoLevel.Contact: lstItems = mclsSalesTransactionDetails.TransactionItemsList .GroupBy(x => new { x.SupplierID, x.SupplierName }) .Select(data => new Data.SalesTransactionItemDetails() { SupplierID = data.Key.SupplierID, SupplierName = data.Key.SupplierName, ProductGroup = "All", ProductSubGroup = "All", Amount = data.Sum(x => x.Amount) }).ToList(); foreach (Data.SalesTransactionItemDetails item in lstItems) { decPromoBySupplierValue = -1; decItemAmount = item.Amount; if (clsPromoBySupplierItems.ApplyPromoBySupplierValue(clsPromoBySupplierDetails, item.SupplierID, 0, 0, 0, 0, out decPromoBySupplierValue, out strCouponRemarks, mclsSalesTransactionDetails.BranchID)) { if (decPromoBySupplierValue == 0 || decPromoBySupplierValue <= decItemAmount) { //print it PrintCoupon(item, strCouponRemarks); } } } break; case PromoLevel.ProductGroup: lstItems = mclsSalesTransactionDetails.TransactionItemsList .GroupBy(x => new { x.SupplierID, x.SupplierName, x.ProductGroup }) .Select(data => new Data.SalesTransactionItemDetails() { SupplierID = data.Key.SupplierID, SupplierName = data.Key.SupplierName, ProductGroup = data.Key.ProductGroup, ProductSubGroup = "All", Amount = data.Sum(x => x.Amount) }).ToList(); foreach (Data.SalesTransactionItemDetails item in lstItems) { decPromoBySupplierValue = -1; decItemAmount = item.Amount; ProductGroupID = clsProductGroup.DetailsByName(item.ProductGroup).ProductGroupID; if (clsPromoBySupplierItems.ApplyPromoBySupplierValue(clsPromoBySupplierDetails, item.SupplierID, ProductGroupID, 0, 0, 0, out decPromoBySupplierValue, out strCouponRemarks, mclsSalesTransactionDetails.BranchID)) { if (decPromoBySupplierValue == 0 || decPromoBySupplierValue <= decItemAmount) { //print it PrintCoupon(item, strCouponRemarks); } } } break; case PromoLevel.ProductSubGroup: lstItems = mclsSalesTransactionDetails.TransactionItemsList .GroupBy(x => new { x.SupplierID, x.SupplierName, x.ProductGroup, x.ProductSubGroup }) .Select(data => new Data.SalesTransactionItemDetails() { SupplierID = data.Key.SupplierID, SupplierName = data.Key.SupplierName, ProductGroup = data.Key.ProductGroup, ProductSubGroup = data.Key.ProductSubGroup, Amount = data.Sum(x => x.Amount) }).ToList(); foreach (Data.SalesTransactionItemDetails item in lstItems) { decPromoBySupplierValue = -1; decItemAmount = item.Amount; ProductGroupID = clsProductGroup.DetailsByName(item.ProductGroup).ProductGroupID; ProductSubGroupID = clsProductSubGroup.DetailsByName(item.ProductSubGroup).ProductSubGroupID; if (clsPromoBySupplierItems.ApplyPromoBySupplierValue(clsPromoBySupplierDetails, item.SupplierID, ProductGroupID, ProductSubGroupID, 0, 0, out decPromoBySupplierValue, out strCouponRemarks, mclsSalesTransactionDetails.BranchID)) { if (decPromoBySupplierValue == 0 || decPromoBySupplierValue <= decItemAmount) { //print it PrintCoupon(item, strCouponRemarks); } } } break; case PromoLevel.Product: lstItems = mclsSalesTransactionDetails.TransactionItemsList .GroupBy(x => new { x.SupplierID, x.SupplierName, x.ProductGroup, x.ProductSubGroup, x.ProductID }) .Select(data => new Data.SalesTransactionItemDetails() { SupplierID = data.Key.SupplierID, SupplierName = data.Key.SupplierName, ProductGroup = data.Key.ProductGroup, ProductSubGroup = data.Key.ProductSubGroup, ProductID = data.Key.ProductID, Amount = data.Sum(x => x.Amount) }).ToList(); foreach (Data.SalesTransactionItemDetails item in lstItems) { decPromoBySupplierValue = -1; decItemAmount = item.Amount; ProductGroupID = clsProductGroup.DetailsByName(item.ProductGroup).ProductGroupID; ProductSubGroupID = clsProductSubGroup.DetailsByName(item.ProductSubGroup).ProductSubGroupID; if (clsPromoBySupplierItems.ApplyPromoBySupplierValue(clsPromoBySupplierDetails, item.SupplierID, ProductGroupID, ProductSubGroupID, item.ProductID, 0, out decPromoBySupplierValue, out strCouponRemarks, mclsSalesTransactionDetails.BranchID)) { if (decPromoBySupplierValue == 0 || decPromoBySupplierValue <= decItemAmount) { //print it PrintCoupon(item, strCouponRemarks); } } } break; case PromoLevel.Variation: lstItems = mclsSalesTransactionDetails.TransactionItemsList .GroupBy(x => new { x.SupplierID, x.SupplierName, x.ProductGroup, x.ProductSubGroup, x.ProductID, x.VariationsMatrixID }) .Select(data => new Data.SalesTransactionItemDetails() { SupplierID = data.Key.SupplierID, SupplierName = data.Key.SupplierName, ProductGroup = data.Key.ProductGroup, ProductSubGroup = data.Key.ProductSubGroup, ProductID = data.Key.ProductID, VariationsMatrixID = data.Key.VariationsMatrixID, Amount = data.Sum(x => x.Amount) }).ToList(); foreach (Data.SalesTransactionItemDetails item in lstItems) { decPromoBySupplierValue = -1; decItemAmount = item.Amount; ProductGroupID = clsProductGroup.DetailsByName(item.ProductGroup).ProductGroupID; ProductSubGroupID = clsProductSubGroup.DetailsByName(item.ProductSubGroup).ProductSubGroupID; if (clsPromoBySupplierItems.ApplyPromoBySupplierValue(clsPromoBySupplierDetails, item.SupplierID, ProductGroupID, ProductSubGroupID, item.ProductID, item.VariationsMatrixID, out decPromoBySupplierValue, out strCouponRemarks, mclsSalesTransactionDetails.BranchID)) { if (decPromoBySupplierValue == 0 || decPromoBySupplierValue <= decItemAmount) { //print it PrintCoupon(item, strCouponRemarks); } } } break; } } clsEvent.AddEventLn("done...", true); } catch (Exception ex) { clsEvent.AddEventLn("Error printing coupon", true); clsEvent.AddErrorEventLn(ex); } finally { clsPromoBySupplier.CommitAndDispose(); } } #endregion InsertAuditLog(AccessTypes.CloseTransaction, "Close transaction #: " + mclsSalesTransactionDetails.TransactionNo + "... Subtotal: " + mclsSalesTransactionDetails.SubTotal.ToString("#,###.#0") + " Discount: " + mclsSalesTransactionDetails.Discount.ToString("#,###.#0") + " AmountPaid: " + mclsSalesTransactionDetails.AmountPaid.ToString("#,###.#0") + " CashPayment: " + CashPayment.ToString("#,###.#0") + " ChequePayment: " + ChequePayment.ToString("#,###.#0") + " CreditCardPayment: " + CreditCardPayment + " CreditPayment: " + CreditPayment.ToString("#,###.#0") + " DebitPayment: " + DebitPayment.ToString("#,###.#0") + " ChangeAmount: " + ChangeAmount.ToString("#,###.#0") + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode); clsEvent.AddEventLn("Done! Transaction no. " + mclsSalesTransactionDetails.TransactionNo + " has been closed. Subtotal: " + mclsSalesTransactionDetails.SubTotal.ToString("#,###.#0") + " Discount: " + mclsSalesTransactionDetails.Discount.ToString("#,###.#0") + " AmountPaid: " + mclsSalesTransactionDetails.AmountPaid.ToString("#,###.#0") + " CashPayment: " + CashPayment.ToString("#,###.#0") + " ChequePayment: " + ChequePayment.ToString("#,###.#0") + " CreditCardPayment: " + CreditCardPayment + " CreditPayment: " + CreditPayment.ToString("#,###.#0") + " DebitPayment: " + DebitPayment.ToString("#,###.#0") + " ChangeAmount: " + ChangeAmount.ToString("#,###.#0"), true); }
private void PriceInquiryWnd_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { switch (e.KeyData) { case Keys.Escape: dialog = DialogResult.Cancel; this.Hide(); break; case Keys.Enter: if (txtBarCode.Text.Trim() != string.Empty) { ClearProduct(); Data.Products clsProduct = new Data.Products(); Data.ProductDetails clsProductDetails = clsProduct.Details(TerminalDetails.BranchID, txtBarCode.Text.Trim()); if (clsProductDetails.ProductID == 0) { string strContactCardNo = txtBarCode.Text.Trim(); Data.Contacts clsContact = new Data.Contacts(clsProduct.Connection, clsProduct.Transaction); Data.ContactDetails clsContactDetails = clsContact.DetailsByRewardCardNo(strContactCardNo); if (clsContactDetails.ContactID == 0) { clsContactDetails = clsContact.DetailsByCreditCardNo(strContactCardNo); if (clsContactDetails.ContactID == 0) { strContactCardNo = strContactCardNo.Remove(strContactCardNo.Length - 1); clsContactDetails = clsContact.DetailsByRewardCardNo(strContactCardNo); if (clsContactDetails.ContactID == 0) { clsContactDetails = clsContact.DetailsByCreditCardNo(strContactCardNo); if (clsContactDetails.ContactID == 0) { ClearProduct(); } else { decimal decAvailableCreditLimit = clsContactDetails.CreditLimit - clsContactDetails.Credit; lblProductDescription.Text = clsContactDetails.ContactName + " - " + clsContactDetails.CreditDetails.CreditCardNo; lblPrice.Text = decAvailableCreditLimit.ToString("#,##0.#0"); lblPriceLabel.Text = "AVAILABLE CREDITS:"; if (clsContactDetails.CreditDetails.CreditCardStatus == CreditCardStatus.Expired || clsContactDetails.CreditDetails.CreditCardStatus == CreditCardStatus.Lost) lblProductDescription.Text += "(" + clsContactDetails.CreditDetails.CreditCardStatus.ToString("G").ToLower() + ")"; else lblProductDescription.Text += "(active)"; } } else { lblProductDescription.Text = clsContactDetails.ContactName + " - " + clsContactDetails.RewardDetails.RewardCardNo; lblPrice.Text = clsContactDetails.RewardDetails.RewardPoints.ToString("#,##0.#0"); lblPriceLabel.Text = "AVAILABLE POINTS:"; if (clsContactDetails.RewardDetails.RewardCardStatus == RewardCardStatus.Expired || clsContactDetails.RewardDetails.RewardCardStatus == RewardCardStatus.Lost) lblProductDescription.Text += "(" + clsContactDetails.RewardDetails.RewardCardStatus.ToString("G").ToLower() + ")"; else lblProductDescription.Text += "(active)"; } } else { decimal decAvailableCreditLimit = clsContactDetails.CreditLimit - clsContactDetails.Credit; lblProductDescription.Text = clsContactDetails.ContactName + " - " + clsContactDetails.CreditDetails.CreditCardNo; lblPrice.Text = decAvailableCreditLimit.ToString("#,##0.#0"); lblPriceLabel.Text = "AVAILABLE CREDITS:"; if (clsContactDetails.CreditDetails.CreditCardStatus == CreditCardStatus.Expired || clsContactDetails.CreditDetails.CreditCardStatus == CreditCardStatus.Lost) lblProductDescription.Text += "(" + clsContactDetails.CreditDetails.CreditCardStatus.ToString("G").ToLower() + ")"; else lblProductDescription.Text += "(active)"; } } else { lblProductDescription.Text = clsContactDetails.ContactName + " - " + clsContactDetails.RewardDetails.RewardCardNo; lblPrice.Text = clsContactDetails.RewardDetails.RewardPoints.ToString("#,##0.#0"); lblPriceLabel.Text = "AVAILABLE POINTS:"; if (clsContactDetails.RewardDetails.RewardCardStatus == RewardCardStatus.Expired || clsContactDetails.RewardDetails.RewardCardStatus == RewardCardStatus.Lost) lblProductDescription.Text += "(" + clsContactDetails.RewardDetails.RewardCardStatus.ToString("G").ToLower() + ")"; else lblProductDescription.Text += "(active)"; } } else { lblProductDescription.Text = clsProductDetails.ProductDesc; lblPrice.Text = clsProductDetails.Price.ToString("#,##0.#0"); lblPriceLabel.Text = "PRICE:"; } clsProduct.CommitAndDispose(); txtBarCode.Text = ""; } txtBarCode.Focus(); txtBarCode.SelectAll(); break; } }
private void LoadOptions() { Int64 UID = Convert.ToInt64(Session["UID"]); Security.AccessRights clsAccessRights = new Security.AccessRights(); cboReportType.Items.Clear(); cboReportType.Items.Add(new ListItem(ReportTypes.REPORT_SELECTION, ReportTypes.REPORT_SELECTION)); cboReportType.Items.Add(new ListItem(ReportTypes.REPORT_SELECTION_SEPARATOR, ReportTypes.REPORT_SELECTION_SEPARATOR)); cboReportType.Items.Add(new ListItem(ReportTypes.ProductHistoryMovement, ReportTypes.ProductHistoryMovement)); if (clsAccessRights.Details(UID, (int)AccessTypes.PricesReport).Read) cboReportType.Items.Add(new ListItem(ReportTypes.ProductHistoryPrice, ReportTypes.ProductHistoryPrice)); cboReportType.Items.Add(new ListItem(ReportTypes.REPORT_SELECTION_SEPARATOR, ReportTypes.REPORT_SELECTION_SEPARATOR)); if (clsAccessRights.Details(UID, (int)AccessTypes.MostSalableItemsReport).Read) cboReportType.Items.Add(new ListItem(ReportTypes.ProductHistoryMostSaleable, ReportTypes.ProductHistoryMostSaleable)); if (clsAccessRights.Details(UID, (int)AccessTypes.LeastSalableItemsReport).Read) cboReportType.Items.Add(new ListItem(ReportTypes.ProductHistoryLeastSaleable, ReportTypes.ProductHistoryLeastSaleable)); clsAccessRights.CommitAndDispose(); cboReportType.SelectedIndex = 0; try { if (Common.Decrypt(Request.QueryString["task"].ToString().ToLower(), Session.SessionID) == "producthistory") { cboReportType.SelectedIndex = cboReportType.Items.IndexOf(cboReportType.Items.FindByValue(ReportTypes.ProductHistoryMovement)); cboReportType_SelectedIndexChanged(null, null); } } catch {} try { if (Common.Decrypt(Request.QueryString["task"].ToString().ToLower(), Session.SessionID) == "pricehistory") { cboReportType.SelectedIndex = cboReportType.Items.IndexOf(cboReportType.Items.FindByValue(ReportTypes.ProductHistoryPrice)); cboReportType_SelectedIndexChanged(null, null); } } catch { } txtStartDate.Text = DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd"); txtEndDate.Text = DateTime.Now.ToString("yyyy-MM-dd"); string strProductCode = string.Empty; try { try { if (Request.QueryString["sender"].ToString().ToLower() == "direct" && Request.QueryString["productcode"].ToString() != null) strProductCode = Server.UrlDecode(Request.QueryString["productcode"].ToString()); } catch { strProductCode = Server.UrlDecode(Common.Decrypt(Request.QueryString["productcode"].ToString(), Session.SessionID)); } lblReferrer.ToolTip = strProductCode; } catch { strProductCode = lblReferrer.ToolTip; } txtProductCode.Text = strProductCode; Data.Products clsProduct = new Data.Products(); cboProductCode.DataTextField = "ProductCode"; cboProductCode.DataValueField = "ProductID"; cboProductCode.DataSource = clsProduct.ProductIDandCodeDataTable(SearchKey: txtProductCode.Text, limit: 100); cboProductCode.DataBind(); Branch clsBranch = new Branch(clsProduct.Connection, clsProduct.Transaction); cboBranch.DataTextField = "BranchCode"; cboBranch.DataValueField = "BranchID"; cboBranch.DataSource = clsBranch.ListAsDataTable().DefaultView; cboBranch.DataBind(); cboBranch.Items.Insert(0, new ListItem(Constants.ALL, Constants.ZERO_STRING)); cboBranch.SelectedIndex = 0; clsProduct.CommitAndDispose(); if (cboProductCode.Items.Count == 0) cboProductCode.Items.Add(new ListItem("No product", "0")); cboProductCode.SelectedIndex = 0; cboProductCode_SelectedIndexChanged(null, null); try { if (strProductCode != string.Empty && cboProductCode.SelectedItem.Value != "0") { if (!string.IsNullOrEmpty(Request.QueryString["reptype"])) GeneratePDF(); else GenerateHTML(); } } catch { } }
protected void cmdProductCode_Click(object sender, System.Web.UI.ImageClickEventArgs e) { DataClass clsDataClass = new DataClass(); Data.Products clsProduct = new Data.Products(); cboProductCode.DataTextField = "ProductCode"; cboProductCode.DataValueField = "ProductID"; cboProductCode.DataSource = clsProduct.ProductIDandCodeDataTable(SearchKey: txtProductCode.Text, limit: 100); cboProductCode.DataBind(); clsProduct.CommitAndDispose(); if (cboProductCode.Items.Count == 0) cboProductCode.Items.Add(new ListItem("No product", "0")); cboProductCode.SelectedIndex = 0; cboProductCode_SelectedIndexChanged(null, null); }
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); }
//public bool ApplyPromoValue(ContactDetails clsContactDetails, Int64 ProductID, Int64 VariationMatrixID, out PromoTypes PromoType, out decimal PromoQuantity, out decimal PromoValue, out bool InPercent, int BranchID = 0) //{ // Int64 ContactID = clsContactDetails.ContactID; // string ContactIDs = ""; // if (clsContactDetails.ContactID != Constants.ZERO) // { // if (!string.IsNullOrEmpty(ContactIDs)) // ContactIDs = "," + clsContactDetails.ContactID.ToString(); // else // ContactIDs = clsContactDetails.ContactID.ToString(); // } // // rewardcardmember // if (clsContactDetails.RewardDetails.RewardCardStatus == RewardCardStatus.ManualActivated) // { // if (!string.IsNullOrEmpty(ContactIDs)) // ContactIDs = "," + Constants.PLUSCARDMEMBERSID_STRING; // else // ContactIDs = Constants.PLUSCARDMEMBERSID_STRING; // } // // icc card members // if (clsContactDetails.CreditDetails.GuarantorID == Constants.ZERO && // clsContactDetails.CreditDetails.CreditCardStatus == CreditCardStatus.ManualActivated) // { // if (!string.IsNullOrEmpty(ContactIDs)) // ContactIDs = "," + Constants.PLUSCARDMEMBERSID_STRING; // else // ContactIDs = Constants.PLUSCARDMEMBERSID_STRING; // } // PromoType = PromoTypes.NotApplicable; // PromoQuantity = 0; // PromoValue = 0; // InPercent = false; // bool boHasPromo = false; // try // { // Data.Products clsProduct = new Data.Products(base.Connection, base.Transaction); // Data.ProductDetails clsProductDetails = clsProduct.Details1(BranchID, ProductID); // Int64 ProductSubGroupID = clsProductDetails.ProductSubGroupID; // Int64 ProductGroupID = clsProductDetails.ProductGroupID; // MySqlCommand cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // string SQL = "SELECT " + // "PromoID " + // "FROM tblPromo " + // "WHERE 1=1 " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd.CommandText = SQL; // string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // boHasPromo = true; // break; // } // if (boHasPromo == false) //return agad if no Promo is affected by date // return boHasPromo; // /*******************************Up to Contact, Group, Sub, Prod and VarM ID only*****************************/ // SQL = "SELECT " + // "PromoItemsID, " + // "a.PromoID, " + // "PromoTypeID, " + // "ProductGroupID, " + // "ProductSubGroupID, " + // "ProductID, " + // "VariationMatrixID, " + // "Quantity, " + // "PromoValue, " + // "InPercent " + // "FROM tblPromoItems a " + // "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + // "WHERE ContactID = @ContactID " + // "AND ProductGroupID = @ProductGroupID " + // "AND ProductSubGroupID = @ProductSubGroupID " + // "AND ProductID = @ProductID " + // "AND VariationMatrixID = @VariationMatrixID " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // cmd.Parameters.AddWithValue("@ContactID", ContactID); // cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID); // cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); // cmd.Parameters.AddWithValue("@ProductID", ProductID); // cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); // cmd.CommandText = SQL; // dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); // PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); // PromoValue = decimal.Parse(dr["PromoValue"].ToString()); // InPercent = bool.Parse(dr["InPercent"].ToString()); // return boHasPromo; // } // /*******************************Up to Contact, Sub, Prod and VariationsMatrix ID only*****************************/ // SQL = "SELECT " + // "PromoItemsID, " + // "a.PromoID, " + // "PromoTypeID, " + // "ProductGroupID, " + // "ProductSubGroupID, " + // "ProductID, " + // "VariationMatrixID, " + // "Quantity, " + // "PromoValue, " + // "InPercent " + // "FROM tblPromoItems a " + // "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + // "WHERE ContactID = @ContactID " + // "AND ProductGroupID = 0 " + // "AND ProductSubGroupID = @ProductSubGroupID " + // "AND ProductID = @ProductID " + // "AND VariationMatrixID = @VariationMatrixID " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // cmd.Parameters.AddWithValue("@ContactID", ContactID); // cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); // cmd.Parameters.AddWithValue("@ProductID", ProductID); // cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); // cmd.CommandText = SQL; // dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); // PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); // PromoValue = decimal.Parse(dr["PromoValue"].ToString()); // InPercent = bool.Parse(dr["InPercent"].ToString()); // return boHasPromo; // } // /*******************************Up to Contact, Prod and VariationsMatrix ID only*****************************/ // SQL = "SELECT " + // "PromoItemsID, " + // "a.PromoID, " + // "PromoTypeID, " + // "ProductGroupID, " + // "ProductSubGroupID, " + // "ProductID, " + // "VariationMatrixID, " + // "Quantity, " + // "PromoValue, " + // "InPercent " + // "FROM tblPromoItems a " + // "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + // "WHERE ContactID = @ContactID " + // "AND ProductGroupID = 0 " + // "AND ProductSubGroupID = 0 " + // "AND ProductID = @ProductID " + // "AND VariationMatrixID = @VariationMatrixID " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // cmd.Parameters.AddWithValue("@ContactID", ContactID); // cmd.Parameters.AddWithValue("@ProductID", ProductID); // cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); // cmd.CommandText = SQL; // dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); // PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); // PromoValue = decimal.Parse(dr["PromoValue"].ToString()); // InPercent = bool.Parse(dr["InPercent"].ToString()); // return boHasPromo; // } // /*******************************Up to Contact, VariationsMatrix ID only*****************************/ // SQL = "SELECT " + // "PromoItemsID, " + // "a.PromoID, " + // "PromoTypeID, " + // "ProductGroupID, " + // "ProductSubGroupID, " + // "ProductID, " + // "VariationMatrixID, " + // "Quantity, " + // "PromoValue, " + // "InPercent " + // "FROM tblPromoItems a " + // "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + // "WHERE ContactID = @ContactID " + // "AND ProductGroupID = 0 " + // "AND ProductSubGroupID = 0 " + // "AND ProductID = 0 " + // "AND VariationMatrixID = @VariationMatrixID " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // cmd.Parameters.AddWithValue("@ContactID", ContactID); // cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); // cmd.CommandText = SQL; // dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); // PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); // PromoValue = decimal.Parse(dr["PromoValue"].ToString()); // InPercent = bool.Parse(dr["InPercent"].ToString()); // return boHasPromo; // } // /*******************************Up to Contact, Group, Sub, Prod ID only*****************************/ // SQL = "SELECT " + // "PromoItemsID, " + // "a.PromoID, " + // "PromoTypeID, " + // "ProductGroupID, " + // "ProductSubGroupID, " + // "ProductID, " + // "VariationMatrixID, " + // "Quantity, " + // "PromoValue, " + // "InPercent " + // "FROM tblPromoItems a " + // "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + // "WHERE ContactID = @ContactID " + // "AND ProductGroupID = @ProductGroupID " + // "AND ProductSubGroupID = @ProductSubGroupID " + // "AND ProductID = @ProductID " + // "AND VariationMatrixID = 0 " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // cmd.Parameters.AddWithValue("@ContactID", ContactID); // cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID); // cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); // cmd.Parameters.AddWithValue("@ProductID", ProductID); // cmd.CommandText = SQL; // dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); // PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); // PromoValue = decimal.Parse(dr["PromoValue"].ToString()); // InPercent = bool.Parse(dr["InPercent"].ToString()); // return boHasPromo; // } // /*******************************Up to Contact, Sub, Prod ID only*****************************/ // SQL = "SELECT " + // "PromoItemsID, " + // "a.PromoID, " + // "PromoTypeID, " + // "ProductGroupID, " + // "ProductSubGroupID, " + // "ProductID, " + // "VariationMatrixID, " + // "Quantity, " + // "PromoValue, " + // "InPercent " + // "FROM tblPromoItems a " + // "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + // "WHERE ContactID = @ContactID " + // "AND ProductGroupID = 0 " + // "AND ProductSubGroupID = @ProductSubGroupID " + // "AND ProductID = @ProductID " + // "AND VariationMatrixID = 0 " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // cmd.Parameters.AddWithValue("@ContactID", ContactID); // cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); // cmd.Parameters.AddWithValue("@ProductID", ProductID); // cmd.CommandText = SQL; // dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); // PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); // PromoValue = decimal.Parse(dr["PromoValue"].ToString()); // InPercent = bool.Parse(dr["InPercent"].ToString()); // return boHasPromo; // } // /*******************************Up to Contact, Prod ID only*****************************/ // SQL = "SELECT " + // "PromoItemsID, " + // "a.PromoID, " + // "PromoTypeID, " + // "ProductGroupID, " + // "ProductSubGroupID, " + // "ProductID, " + // "VariationMatrixID, " + // "Quantity, " + // "PromoValue, " + // "InPercent " + // "FROM tblPromoItems a " + // "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + // "WHERE ContactID = @ContactID " + // "AND ProductGroupID = 0 " + // "AND ProductSubGroupID = 0 " + // "AND ProductID = @ProductID " + // "AND VariationMatrixID = 0 " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // cmd.Parameters.AddWithValue("@ContactID", ContactID); // cmd.Parameters.AddWithValue("@ProductID", ProductID); // cmd.CommandText = SQL; // dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); // PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); // PromoValue = decimal.Parse(dr["PromoValue"].ToString()); // InPercent = bool.Parse(dr["InPercent"].ToString()); // return boHasPromo; // } // /*******************************Up to Contact, Group, Sub only*****************************/ // SQL = "SELECT " + // "PromoItemsID, " + // "a.PromoID, " + // "PromoTypeID, " + // "ProductGroupID, " + // "ProductSubGroupID, " + // "ProductID, " + // "VariationMatrixID, " + // "Quantity, " + // "PromoValue, " + // "InPercent " + // "FROM tblPromoItems a " + // "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + // "WHERE ContactID = @ContactID " + // "AND ProductGroupID = @ProductGroupID " + // "AND ProductSubGroupID = @ProductSubGroupID " + // "AND ProductID = 0 " + // "AND VariationMatrixID = 0 " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // cmd.Parameters.AddWithValue("@ContactID", ContactID); // cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID); // cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); // cmd.CommandText = SQL; // dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); // PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); // PromoValue = decimal.Parse(dr["PromoValue"].ToString()); // InPercent = bool.Parse(dr["InPercent"].ToString()); // return boHasPromo; // } // /*******************************Up to Contact, Sub only*****************************/ // SQL = "SELECT " + // "PromoItemsID, " + // "a.PromoID, " + // "PromoTypeID, " + // "ProductGroupID, " + // "ProductSubGroupID, " + // "ProductID, " + // "VariationMatrixID, " + // "Quantity, " + // "PromoValue, " + // "InPercent " + // "FROM tblPromoItems a " + // "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + // "WHERE ContactID = @ContactID " + // "AND ProductGroupID = 0 " + // "AND ProductSubGroupID = @ProductSubGroupID " + // "AND ProductID = 0 " + // "AND VariationMatrixID = 0 " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // cmd.Parameters.AddWithValue("@ContactID", ContactID); // cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); // cmd.CommandText = SQL; // dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); // PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); // PromoValue = decimal.Parse(dr["PromoValue"].ToString()); // InPercent = bool.Parse(dr["InPercent"].ToString()); // return boHasPromo; // } // /*******************************Up to Contact only*****************************/ // SQL = "SELECT " + // "PromoItemsID, " + // "a.PromoID, " + // "PromoTypeID, " + // "ProductGroupID, " + // "ProductSubGroupID, " + // "ProductID, " + // "VariationMatrixID, " + // "Quantity, " + // "PromoValue, " + // "InPercent " + // "FROM tblPromoItems a " + // "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + // "WHERE ContactID = @ContactID " + // "AND ProductGroupID = 0 " + // "AND ProductSubGroupID = 0 " + // "AND ProductID = 0 " + // "AND VariationMatrixID = 0 " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // cmd.Parameters.AddWithValue("@ContactID", ContactID); // cmd.CommandText = SQL; // dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); // PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); // PromoValue = decimal.Parse(dr["PromoValue"].ToString()); // InPercent = bool.Parse(dr["InPercent"].ToString()); // return boHasPromo; // } // /*******************************Up to Group, Sub, Prod and VarM ID only*****************************/ // SQL = "SELECT " + // "PromoItemsID, " + // "a.PromoID, " + // "PromoTypeID, " + // "ProductGroupID, " + // "ProductSubGroupID, " + // "ProductID, " + // "VariationMatrixID, " + // "Quantity, " + // "PromoValue, " + // "InPercent " + // "FROM tblPromoItems a " + // "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + // "WHERE ContactID = 0 " + // "AND ProductGroupID = @ProductGroupID " + // "AND ProductSubGroupID = @ProductSubGroupID " + // "AND ProductID = @ProductID " + // "AND VariationMatrixID = @VariationMatrixID " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID); // cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); // cmd.Parameters.AddWithValue("@ProductID", ProductID); // cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); // cmd.CommandText = SQL; // dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); // PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); // PromoValue = decimal.Parse(dr["PromoValue"].ToString()); // InPercent = bool.Parse(dr["InPercent"].ToString()); // return boHasPromo; // } // /*******************************Up to Sub, Prod and VariationMatrix ID only*****************************/ // SQL = "SELECT " + // "PromoItemsID, " + // "a.PromoID, " + // "PromoTypeID, " + // "ProductGroupID, " + // "ProductSubGroupID, " + // "ProductID, " + // "VariationMatrixID, " + // "Quantity, " + // "PromoValue, " + // "InPercent " + // "FROM tblPromoItems a " + // "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + // "WHERE ContactID = 0 " + // "AND ProductGroupID =0 " + // "AND ProductSubGroupID = @ProductSubGroupID " + // "AND ProductID = @ProductID " + // "AND VariationMatrixID = @VariationMatrixID " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); // cmd.Parameters.AddWithValue("@ProductID", ProductID); // cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); // cmd.CommandText = SQL; // dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); // PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); // PromoValue = decimal.Parse(dr["PromoValue"].ToString()); // InPercent = bool.Parse(dr["InPercent"].ToString()); // return boHasPromo; // } // /*******************************Up to Prod and VariationMatrix ID only*****************************/ // SQL = "SELECT " + // "PromoItemsID, " + // "a.PromoID, " + // "PromoTypeID, " + // "ProductGroupID, " + // "ProductSubGroupID, " + // "ProductID, " + // "VariationMatrixID, " + // "Quantity, " + // "PromoValue, " + // "InPercent " + // "FROM tblPromoItems a " + // "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + // "WHERE ContactID = 0 " + // "AND ProductGroupID = 0 " + // "AND ProductSubGroupID = 0 " + // "AND ProductID = @ProductID " + // "AND VariationMatrixID = @VariationMatrixID " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // cmd.Parameters.AddWithValue("@ProductID", ProductID); // cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); // cmd.CommandText = SQL; // dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); // PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); // PromoValue = decimal.Parse(dr["PromoValue"].ToString()); // InPercent = bool.Parse(dr["InPercent"].ToString()); // return boHasPromo; // } // /*******************************Up to VariationsMatrix ID only*****************************/ // SQL = "SELECT " + // "PromoItemsID, " + // "a.PromoID, " + // "PromoTypeID, " + // "ProductGroupID, " + // "ProductSubGroupID, " + // "ProductID, " + // "VariationMatrixID, " + // "Quantity, " + // "PromoValue, " + // "InPercent " + // "FROM tblPromoItems a " + // "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + // "WHERE ContactID = 0 " + // "AND ProductGroupID = 0 " + // "AND ProductSubGroupID = 0 " + // "AND ProductID = 0 " + // "AND VariationMatrixID = @VariationMatrixID " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); // cmd.CommandText = SQL; // dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); // PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); // PromoValue = decimal.Parse(dr["PromoValue"].ToString()); // InPercent = bool.Parse(dr["InPercent"].ToString()); // return boHasPromo; // } // /*******************************Up to group, Sub, Prod ID only*****************************/ // SQL = "SELECT " + // "PromoItemsID, " + // "a.PromoID, " + // "PromoTypeID, " + // "ProductGroupID, " + // "ProductSubGroupID, " + // "ProductID, " + // "VariationMatrixID, " + // "Quantity, " + // "PromoValue, " + // "InPercent " + // "FROM tblPromoItems a " + // "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + // "WHERE ContactID = 0 " + // "AND ProductGroupID = @ProductGroupID " + // "AND ProductSubGroupID = @ProductSubGroupID " + // "AND ProductID = @ProductID " + // "AND VariationMatrixID = 0 " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID); // cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); // cmd.Parameters.AddWithValue("@ProductID", ProductID); // cmd.CommandText = SQL; // dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); // PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); // PromoValue = decimal.Parse(dr["PromoValue"].ToString()); // InPercent = bool.Parse(dr["InPercent"].ToString()); // return boHasPromo; // } // /*******************************Up to Sub, Prod ID only*****************************/ // SQL = "SELECT " + // "PromoItemsID, " + // "a.PromoID, " + // "PromoTypeID, " + // "ProductGroupID, " + // "ProductSubGroupID, " + // "ProductID, " + // "VariationMatrixID, " + // "Quantity, " + // "PromoValue, " + // "InPercent " + // "FROM tblPromoItems a " + // "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + // "WHERE ContactID = 0 " + // "AND ProductGroupID = 0 " + // "AND ProductSubGroupID = @ProductSubGroupID " + // "AND ProductID = @ProductID " + // "AND VariationMatrixID = 0 " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); // cmd.Parameters.AddWithValue("@ProductID", ProductID); // cmd.CommandText = SQL; // dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); // PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); // PromoValue = decimal.Parse(dr["PromoValue"].ToString()); // InPercent = bool.Parse(dr["InPercent"].ToString()); // return boHasPromo; // } // /*******************************Up to group, Sub, Prod and VariationMatrix ID only*****************************/ // SQL = "SELECT " + // "PromoItemsID, " + // "a.PromoID, " + // "PromoTypeID, " + // "ProductGroupID, " + // "ProductSubGroupID, " + // "ProductID, " + // "VariationMatrixID, " + // "Quantity, " + // "PromoValue, " + // "InPercent " + // "FROM tblPromoItems a " + // "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + // "WHERE ContactID = 0 " + // "AND ProductGroupID = 0 " + // "AND ProductSubGroupID = 0 " + // "AND ProductID = @ProductID " + // "AND VariationMatrixID = 0 " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // cmd.Parameters.AddWithValue("@ProductID", ProductID); // cmd.CommandText = SQL; // dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); // PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); // PromoValue = decimal.Parse(dr["PromoValue"].ToString()); // InPercent = bool.Parse(dr["InPercent"].ToString()); // return boHasPromo; // } // /*******************************Up to group, Sub ID only*****************************/ // SQL = "SELECT " + // "PromoItemsID, " + // "a.PromoID, " + // "PromoTypeID, " + // "ProductGroupID, " + // "ProductSubGroupID, " + // "ProductID, " + // "VariationMatrixID, " + // "Quantity, " + // "PromoValue, " + // "InPercent " + // "FROM tblPromoItems a " + // "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + // "WHERE ContactID = 0 " + // "AND ProductGroupID = @ProductGroupID " + // "AND ProductSubGroupID = @ProductSubGroupID " + // "AND ProductID = 0 " + // "AND VariationMatrixID = 0 " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID); // cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); // cmd.CommandText = SQL; // dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); // PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); // PromoValue = decimal.Parse(dr["PromoValue"].ToString()); // InPercent = bool.Parse(dr["InPercent"].ToString()); // return boHasPromo; // } // /*******************************Up to Sub ID only*****************************/ // SQL = "SELECT " + // "PromoItemsID, " + // "a.PromoID, " + // "PromoTypeID, " + // "ProductGroupID, " + // "ProductSubGroupID, " + // "ProductID, " + // "VariationMatrixID, " + // "Quantity, " + // "PromoValue, " + // "InPercent " + // "FROM tblPromoItems a " + // "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + // "WHERE ContactID = 0 " + // "AND ProductGroupID = 0 " + // "AND ProductSubGroupID = @ProductSubGroupID " + // "AND ProductID = 0 " + // "AND VariationMatrixID = 0 " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); // cmd.CommandText = SQL; // dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); // PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); // PromoValue = decimal.Parse(dr["PromoValue"].ToString()); // InPercent = bool.Parse(dr["InPercent"].ToString()); // return boHasPromo; // } // /*******************************Up to group ID only*****************************/ // SQL = "SELECT " + // "PromoItemsID, " + // "a.PromoID, " + // "PromoTypeID, " + // "ProductGroupID, " + // "ProductSubGroupID, " + // "ProductID, " + // "VariationMatrixID, " + // "Quantity, " + // "PromoValue, " + // "InPercent " + // "FROM tblPromoItems a " + // "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + // "WHERE ContactID = 0 " + // "AND ProductGroupID = @ProductGroupID " + // "AND ProductSubGroupID = 0 " + // "AND ProductID = 0 " + // "AND VariationMatrixID = 0 " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID); // cmd.CommandText = SQL; // dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); // PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); // PromoValue = decimal.Parse(dr["PromoValue"].ToString()); // InPercent = bool.Parse(dr["InPercent"].ToString()); // return boHasPromo; // } // /*******************************Up to all only*****************************/ // SQL = "SELECT " + // "PromoItemsID, " + // "a.PromoID, " + // "PromoTypeID, " + // "ProductGroupID, " + // "ProductSubGroupID, " + // "ProductID, " + // "VariationMatrixID, " + // "Quantity, " + // "PromoValue, " + // "InPercent " + // "FROM tblPromoItems a " + // "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + // "WHERE ContactID = 0 " + // "AND ProductGroupID = 0 " + // "AND ProductSubGroupID = 0 " + // "AND ProductID = 0 " + // "AND VariationMatrixID = 0 " + // "AND Status = 1 " + // "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + // "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; // cmd = new MySqlCommand(); // cmd.CommandType = System.Data.CommandType.Text; // cmd.CommandText = SQL; // dt = new System.Data.DataTable(strDataTableName); // base.MySqlDataAdapterFill(cmd, dt); // foreach (System.Data.DataRow dr in dt.Rows) // { // PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); // PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); // PromoValue = decimal.Parse(dr["PromoValue"].ToString()); // InPercent = bool.Parse(dr["InPercent"].ToString()); // return boHasPromo; // } // } // catch (Exception ex) // { // base.ThrowException(ex); // } // return false; //} public bool ApplyPromoValue(ContactDetails clsContactDetails, Int64 ProductID, Int64 VariationMatrixID, out PromoTypes PromoType, out decimal PromoQuantity, out decimal PromoValue, out bool InPercent, int BranchID = 0) { Int64 ContactID = clsContactDetails.ContactID; string strSpecialContactIDs = ""; // rewardcardmember // make sure that it is not the default if (clsContactDetails.ContactID != Constants.C_RETAILPLUS_CUSTOMERID && clsContactDetails.RewardDetails.RewardActive) { if (!string.IsNullOrEmpty(strSpecialContactIDs)) strSpecialContactIDs += "," + Constants.PLUSCARDMEMBERSID_STRING; else strSpecialContactIDs = Constants.PLUSCARDMEMBERSID_STRING; } // icc card members // make sure that it is not the default if (clsContactDetails.ContactID != Constants.C_RETAILPLUS_CUSTOMERID && clsContactDetails.CreditDetails.GuarantorID == Constants.ZERO && clsContactDetails.CreditDetails.CreditActive) { if (!string.IsNullOrEmpty(strSpecialContactIDs)) strSpecialContactIDs += "," + Constants.ICCARDMEMBERSID_STRING; else strSpecialContactIDs = Constants.ICCARDMEMBERSID_STRING; } // gcc card members // make sure that it is not the default if (clsContactDetails.ContactID != Constants.C_RETAILPLUS_CUSTOMERID && clsContactDetails.CreditDetails.GuarantorID != Constants.ZERO && clsContactDetails.CreditDetails.CreditActive) { if (!string.IsNullOrEmpty(strSpecialContactIDs)) strSpecialContactIDs += "," + Constants.GCCARDMEMBERSID_STRING; else strSpecialContactIDs = Constants.GCCARDMEMBERSID_STRING; } PromoType = PromoTypes.NotApplicable; PromoQuantity = 0; PromoValue = 0; InPercent = false; bool boHasPromo = false; try { Data.Products clsProduct = new Data.Products(base.Connection, base.Transaction); Data.ProductDetails clsProductDetails = clsProduct.Details1(BranchID, ProductID); Int64 ProductSubGroupID = clsProductDetails.ProductSubGroupID; Int64 ProductGroupID = clsProductDetails.ProductGroupID; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; string SQL = "SELECT " + "PromoID " + "FROM tblPromo " + "WHERE 1=1 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i');"; cmd.CommandText = SQL; string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { boHasPromo = true; break; } if (boHasPromo == false) //return agad if no Promo is affected by date return boHasPromo; /*******************************Up to Contact, Group, Sub, Prod and VarM ID only*****************************/ SQL = "SELECT " + "PromoItemsID, " + "a.PromoID, " + "PromoTypeID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "Quantity, " + "PromoValue, " + "InPercent " + "FROM tblPromoItems a " + "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + "WHERE " + (string.IsNullOrEmpty(strSpecialContactIDs) ? "ContactID = @ContactID " : "ContactID IN (@ContactID, " + strSpecialContactIDs + ") ") + "AND ProductGroupID = @ProductGroupID " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = @ProductID " + "AND VariationMatrixID = @VariationMatrixID " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@ContactID", ContactID); cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID); cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); PromoValue = decimal.Parse(dr["PromoValue"].ToString()); InPercent = bool.Parse(dr["InPercent"].ToString()); return boHasPromo; } /*******************************Up to Contact, Sub, Prod and VariationsMatrix ID only*****************************/ SQL = "SELECT " + "PromoItemsID, " + "a.PromoID, " + "PromoTypeID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "Quantity, " + "PromoValue, " + "InPercent " + "FROM tblPromoItems a " + "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + "WHERE " + (string.IsNullOrEmpty(strSpecialContactIDs) ? "ContactID = @ContactID " : "ContactID IN (@ContactID, " + strSpecialContactIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = @ProductID " + "AND VariationMatrixID = @VariationMatrixID " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@ContactID", ContactID); cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); PromoValue = decimal.Parse(dr["PromoValue"].ToString()); InPercent = bool.Parse(dr["InPercent"].ToString()); return boHasPromo; } /*******************************Up to Contact, Prod and VariationsMatrix ID only*****************************/ SQL = "SELECT " + "PromoItemsID, " + "a.PromoID, " + "PromoTypeID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "Quantity, " + "PromoValue, " + "InPercent " + "FROM tblPromoItems a " + "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + "WHERE " + (string.IsNullOrEmpty(strSpecialContactIDs) ? "ContactID = @ContactID " : "ContactID IN (@ContactID, " + strSpecialContactIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = 0 " + "AND ProductID = @ProductID " + "AND VariationMatrixID = @VariationMatrixID " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@ContactID", ContactID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); PromoValue = decimal.Parse(dr["PromoValue"].ToString()); InPercent = bool.Parse(dr["InPercent"].ToString()); return boHasPromo; } /*******************************Up to Contact, VariationsMatrix ID only*****************************/ SQL = "SELECT " + "PromoItemsID, " + "a.PromoID, " + "PromoTypeID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "Quantity, " + "PromoValue, " + "InPercent " + "FROM tblPromoItems a " + "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + "WHERE " + (string.IsNullOrEmpty(strSpecialContactIDs) ? "ContactID = @ContactID " : "ContactID IN (@ContactID, " + strSpecialContactIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = 0 " + "AND ProductID = 0 " + "AND VariationMatrixID = @VariationMatrixID " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@ContactID", ContactID); cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); PromoValue = decimal.Parse(dr["PromoValue"].ToString()); InPercent = bool.Parse(dr["InPercent"].ToString()); return boHasPromo; } /*******************************Up to Contact, Group, Sub, Prod ID only*****************************/ SQL = "SELECT " + "PromoItemsID, " + "a.PromoID, " + "PromoTypeID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "Quantity, " + "PromoValue, " + "InPercent " + "FROM tblPromoItems a " + "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + "WHERE " + (string.IsNullOrEmpty(strSpecialContactIDs) ? "ContactID = @ContactID " : "ContactID IN (@ContactID, " + strSpecialContactIDs + ") ") + "AND ProductGroupID = @ProductGroupID " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = @ProductID " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@ContactID", ContactID); cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID); cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); PromoValue = decimal.Parse(dr["PromoValue"].ToString()); InPercent = bool.Parse(dr["InPercent"].ToString()); return boHasPromo; } /*******************************Up to Contact, Sub, Prod ID only*****************************/ SQL = "SELECT " + "PromoItemsID, " + "a.PromoID, " + "PromoTypeID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "Quantity, " + "PromoValue, " + "InPercent " + "FROM tblPromoItems a " + "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + "WHERE " + (string.IsNullOrEmpty(strSpecialContactIDs) ? "ContactID = @ContactID " : "ContactID IN (@ContactID, " + strSpecialContactIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = @ProductID " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@ContactID", ContactID); cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); PromoValue = decimal.Parse(dr["PromoValue"].ToString()); InPercent = bool.Parse(dr["InPercent"].ToString()); return boHasPromo; } /*******************************Up to Contact, Prod ID only*****************************/ SQL = "SELECT " + "PromoItemsID, " + "a.PromoID, " + "PromoTypeID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "Quantity, " + "PromoValue, " + "InPercent " + "FROM tblPromoItems a " + "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + "WHERE " + (string.IsNullOrEmpty(strSpecialContactIDs) ? "ContactID = @ContactID " : "ContactID IN (@ContactID, " + strSpecialContactIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = 0 " + "AND ProductID = @ProductID " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@ContactID", ContactID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); PromoValue = decimal.Parse(dr["PromoValue"].ToString()); InPercent = bool.Parse(dr["InPercent"].ToString()); return boHasPromo; } /*******************************Up to Contact, Group, Sub only*****************************/ SQL = "SELECT " + "PromoItemsID, " + "a.PromoID, " + "PromoTypeID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "Quantity, " + "PromoValue, " + "InPercent " + "FROM tblPromoItems a " + "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + "WHERE " + (string.IsNullOrEmpty(strSpecialContactIDs) ? "ContactID = @ContactID " : "ContactID IN (@ContactID, " + strSpecialContactIDs + ") ") + "AND ProductGroupID = @ProductGroupID " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = 0 " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@ContactID", ContactID); cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID); cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); PromoValue = decimal.Parse(dr["PromoValue"].ToString()); InPercent = bool.Parse(dr["InPercent"].ToString()); return boHasPromo; } /*******************************Up to Contact, Sub only*****************************/ SQL = "SELECT " + "PromoItemsID, " + "a.PromoID, " + "PromoTypeID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "Quantity, " + "PromoValue, " + "InPercent " + "FROM tblPromoItems a " + "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + "WHERE " + (string.IsNullOrEmpty(strSpecialContactIDs) ? "ContactID = @ContactID " : "ContactID IN (@ContactID, " + strSpecialContactIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = 0 " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@ContactID", ContactID); cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); PromoValue = decimal.Parse(dr["PromoValue"].ToString()); InPercent = bool.Parse(dr["InPercent"].ToString()); return boHasPromo; } /*******************************Up to Contact only*****************************/ SQL = "SELECT " + "PromoItemsID, " + "a.PromoID, " + "PromoTypeID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "Quantity, " + "PromoValue, " + "InPercent " + "FROM tblPromoItems a " + "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + "WHERE " + (string.IsNullOrEmpty(strSpecialContactIDs) ? "ContactID = @ContactID " : "ContactID IN (@ContactID, " + strSpecialContactIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = 0 " + "AND ProductID = 0 " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@ContactID", ContactID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); PromoValue = decimal.Parse(dr["PromoValue"].ToString()); InPercent = bool.Parse(dr["InPercent"].ToString()); return boHasPromo; } /*******************************Up to Group, Sub, Prod and VarM ID only*****************************/ SQL = "SELECT " + "PromoItemsID, " + "a.PromoID, " + "PromoTypeID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "Quantity, " + "PromoValue, " + "InPercent " + "FROM tblPromoItems a " + "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + "WHERE " + (string.IsNullOrEmpty(strSpecialContactIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialContactIDs + ") ") + "AND ProductGroupID = @ProductGroupID " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = @ProductID " + "AND VariationMatrixID = @VariationMatrixID " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID); cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); PromoValue = decimal.Parse(dr["PromoValue"].ToString()); InPercent = bool.Parse(dr["InPercent"].ToString()); return boHasPromo; } /*******************************Up to Sub, Prod and VariationMatrix ID only*****************************/ SQL = "SELECT " + "PromoItemsID, " + "a.PromoID, " + "PromoTypeID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "Quantity, " + "PromoValue, " + "InPercent " + "FROM tblPromoItems a " + "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + "WHERE " + (string.IsNullOrEmpty(strSpecialContactIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialContactIDs + ") ") + "AND ProductGroupID =0 " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = @ProductID " + "AND VariationMatrixID = @VariationMatrixID " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); PromoValue = decimal.Parse(dr["PromoValue"].ToString()); InPercent = bool.Parse(dr["InPercent"].ToString()); return boHasPromo; } /*******************************Up to Prod and VariationMatrix ID only*****************************/ SQL = "SELECT " + "PromoItemsID, " + "a.PromoID, " + "PromoTypeID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "Quantity, " + "PromoValue, " + "InPercent " + "FROM tblPromoItems a " + "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + "WHERE " + (string.IsNullOrEmpty(strSpecialContactIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialContactIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = 0 " + "AND ProductID = @ProductID " + "AND VariationMatrixID = @VariationMatrixID " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); PromoValue = decimal.Parse(dr["PromoValue"].ToString()); InPercent = bool.Parse(dr["InPercent"].ToString()); return boHasPromo; } /*******************************Up to VariationsMatrix ID only*****************************/ SQL = "SELECT " + "PromoItemsID, " + "a.PromoID, " + "PromoTypeID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "Quantity, " + "PromoValue, " + "InPercent " + "FROM tblPromoItems a " + "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + "WHERE " + (string.IsNullOrEmpty(strSpecialContactIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialContactIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = 0 " + "AND ProductID = 0 " + "AND VariationMatrixID = @VariationMatrixID " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); PromoValue = decimal.Parse(dr["PromoValue"].ToString()); InPercent = bool.Parse(dr["InPercent"].ToString()); return boHasPromo; } /*******************************Up to group, Sub, Prod ID only*****************************/ SQL = "SELECT " + "PromoItemsID, " + "a.PromoID, " + "PromoTypeID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "Quantity, " + "PromoValue, " + "InPercent " + "FROM tblPromoItems a " + "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + "WHERE " + (string.IsNullOrEmpty(strSpecialContactIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialContactIDs + ") ") + "AND ProductGroupID = @ProductGroupID " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = @ProductID " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID); cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); PromoValue = decimal.Parse(dr["PromoValue"].ToString()); InPercent = bool.Parse(dr["InPercent"].ToString()); return boHasPromo; } /*******************************Up to Sub, Prod ID only*****************************/ SQL = "SELECT " + "PromoItemsID, " + "a.PromoID, " + "PromoTypeID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "Quantity, " + "PromoValue, " + "InPercent " + "FROM tblPromoItems a " + "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + "WHERE " + (string.IsNullOrEmpty(strSpecialContactIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialContactIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = @ProductID " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); PromoValue = decimal.Parse(dr["PromoValue"].ToString()); InPercent = bool.Parse(dr["InPercent"].ToString()); return boHasPromo; } /*******************************Up to group, Sub, Prod and VariationMatrix ID only*****************************/ SQL = "SELECT " + "PromoItemsID, " + "a.PromoID, " + "PromoTypeID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "Quantity, " + "PromoValue, " + "InPercent " + "FROM tblPromoItems a " + "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + "WHERE " + (string.IsNullOrEmpty(strSpecialContactIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialContactIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = 0 " + "AND ProductID = @ProductID " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); PromoValue = decimal.Parse(dr["PromoValue"].ToString()); InPercent = bool.Parse(dr["InPercent"].ToString()); return boHasPromo; } /*******************************Up to group, Sub ID only*****************************/ SQL = "SELECT " + "PromoItemsID, " + "a.PromoID, " + "PromoTypeID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "Quantity, " + "PromoValue, " + "InPercent " + "FROM tblPromoItems a " + "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + "WHERE " + (string.IsNullOrEmpty(strSpecialContactIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialContactIDs + ") ") + "AND ProductGroupID = @ProductGroupID " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = 0 " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID); cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); PromoValue = decimal.Parse(dr["PromoValue"].ToString()); InPercent = bool.Parse(dr["InPercent"].ToString()); return boHasPromo; } /*******************************Up to Sub ID only*****************************/ SQL = "SELECT " + "PromoItemsID, " + "a.PromoID, " + "PromoTypeID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "Quantity, " + "PromoValue, " + "InPercent " + "FROM tblPromoItems a " + "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + "WHERE " + (string.IsNullOrEmpty(strSpecialContactIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialContactIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = 0 " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); PromoValue = decimal.Parse(dr["PromoValue"].ToString()); InPercent = bool.Parse(dr["InPercent"].ToString()); return boHasPromo; } /*******************************Up to group ID only*****************************/ SQL = "SELECT " + "PromoItemsID, " + "a.PromoID, " + "PromoTypeID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "Quantity, " + "PromoValue, " + "InPercent " + "FROM tblPromoItems a " + "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + "WHERE " + (string.IsNullOrEmpty(strSpecialContactIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialContactIDs + ") ") + "AND ProductGroupID = @ProductGroupID " + "AND ProductSubGroupID = 0 " + "AND ProductID = 0 " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); PromoValue = decimal.Parse(dr["PromoValue"].ToString()); InPercent = bool.Parse(dr["InPercent"].ToString()); return boHasPromo; } /*******************************Up to all only*****************************/ SQL = "SELECT " + "PromoItemsID, " + "a.PromoID, " + "PromoTypeID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "Quantity, " + "PromoValue, " + "InPercent " + "FROM tblPromoItems a " + "INNER JOIN tblPromo b ON a.PromoID = b.PromoID " + "WHERE " + (string.IsNullOrEmpty(strSpecialContactIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialContactIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = 0 " + "AND ProductID = 0 " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoTypeID"].ToString()); PromoQuantity = decimal.Parse(dr["Quantity"].ToString()); PromoValue = decimal.Parse(dr["PromoValue"].ToString()); InPercent = bool.Parse(dr["InPercent"].ToString()); return boHasPromo; } } catch (Exception ex) { base.ThrowException(ex); } return false; }
private void RenewRewardCard() { if (mboIsInTransaction) { MessageBox.Show("Sorry you cannot renew a Reward Card while there is an ongoing transaction. Please finish the transaction first.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.RewardCardChange); if (loginresult == DialogResult.OK) { try { DialogResult result; Data.ContactDetails clsContactDetails; ContactSelectWnd clsContactWnd = new ContactSelectWnd(); clsContactWnd.EnableContactAddUpdate = GetWriteAccess(mclsSalesTransactionDetails.CashierID, AccessTypes.Contacts) == System.Windows.Forms.DialogResult.OK; clsContactWnd.SysConfigDetails = mclsSysConfigDetails; clsContactWnd.TerminalDetails = mclsTerminalDetails; clsContactWnd.ContactGroupCategory = AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER; clsContactWnd.Header = "Please select customer for reward card renewal."; clsContactWnd.ShowDialog(this); clsContactDetails = clsContactWnd.Details; result = clsContactWnd.Result; clsContactWnd.Close(); clsContactWnd.Dispose(); if (result != DialogResult.OK) { return; } if (clsContactDetails.ContactID == Constants.ZERO || clsContactDetails.ContactID == Constants.C_RETAILPLUS_CUSTOMERID) { return; } clsEvent.AddEvent("[" + lblCashier.Text + "] Renewing reward card."); Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction); mConnection = clsContact.Connection; mTransaction = clsContact.Transaction; clsContactDetails = clsContact.Details(clsContactDetails.ContactID); clsContact.CommitAndDispose(); if (clsContactDetails.RewardDetails.RewardCardNo == string.Empty || clsContactDetails.RewardDetails.RewardCardNo == null) { clsEvent.AddEventLn("Cancelled!"); clsEvent.AddEventLn(clsContactDetails.ContactName + " has no valid Reward Card yet. "); MessageBox.Show(clsContactDetails.ContactName + " has no valid Reward Card yet. Please select another customer.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } clsEvent.AddEvent("[" + lblCashier.Text + "] Renewing reward card #: " + clsContactDetails.RewardDetails.RewardCardNo + " of " + clsContactDetails.ContactName + "."); ContactRewardWnd clsContactRewardWnd = new ContactRewardWnd(); clsContactRewardWnd.TerminalDetails = mclsTerminalDetails; clsContactRewardWnd.Caption = "Reward Card Renewal"; clsContactRewardWnd.ContactDetails = clsContactDetails; clsContactRewardWnd.RewardCardStatus = RewardCardStatus.ReNew; clsContactRewardWnd.ShowDialog(this); result = clsContactRewardWnd.Result; clsContactDetails = clsContactRewardWnd.ContactDetails; clsContactRewardWnd.Close(); clsContactRewardWnd.Dispose(); if (result == DialogResult.OK) { Data.Products clsProducts = new Data.Products(mConnection, mTransaction); mConnection = clsProducts.Connection; mTransaction = clsProducts.Transaction; if (clsProducts.Details(Data.Products.DEFAULT_ADVANTAGE_CARD_RENEWAL_FEE_BARCODE).ProductID == 0) { clsProducts.CREATE_ADVANTAGE_CARD_RENEWAL_FEE_BARCODE_PRODUCT(); Methods.InsertAuditLog(mclsTerminalDetails, "System Administrator", AccessTypes.RewardCardChange, "ADVANTAGE_CARD_RENEWAL_FEE_BARCODE product has been created coz it's not configured"); } clsProducts.CommitAndDispose(); MessageBox.Show("Reward Card No: " + clsContactDetails.RewardDetails.RewardCardNo + " has been renewed with new expiry date " + clsContactDetails.RewardDetails.ExpiryDate.ToString("yyyy-MM-dd") + ".", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); clsEvent.AddEventLn("Done!", true); clsEvent.AddEventLn("Reward Card No: " + clsContactDetails.RewardDetails.RewardCardNo + " has been renewed with new expiry date " + clsContactDetails.RewardDetails.ExpiryDate.ToString("yyyy-MM-dd") + ".", true); LocalDB clsLocalDB = new LocalDB(mConnection, mTransaction); mConnection = clsLocalDB.Connection; mTransaction = clsLocalDB.Transaction; clsEvent.AddEvent("[" + lblCashier.Text + "] Creating " + Data.Products.DEFAULT_ADVANTAGE_CARD_RENEWAL_FEE_BARCODE + "transaction for customer: "); LoadContact(AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER, clsContactDetails); if (!this.CreateTransaction()) return; txtBarCode.Text = Data.Products.DEFAULT_ADVANTAGE_CARD_RENEWAL_FEE_BARCODE; ReadBarCode(); int iRow = dgItems.CurrentRowIndex; txtBarCode.Text = ""; CloseTransaction(); clsLocalDB.CommitAndDispose(); } else { clsEvent.AddEventLn("Cancelled!"); } } catch (Exception ex) { InsertErrorLogToFile(ex, "ERROR!!! Renewing reward card."); } Cursor.Current = Cursors.Default; } }
private void IssueCreditCard() { if (mboIsInTransaction) { MessageBox.Show("Sorry you cannot issue a Credit Card while there is an ongoing transaction. Please finish the transaction first.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.CreditCardIssuance); if (loginresult == DialogResult.OK) { try { DialogResult result; Data.CardTypeDetails clsCardTypeDetails = new Data.CardTypeDetails(); Data.ContactDetails clsGuarantorDetails = new AceSoft.RetailPlus.Data.ContactDetails(); ContactCreditTypeSelectWnd clsContactCreditTypeSelectWnd = new ContactCreditTypeSelectWnd(); clsContactCreditTypeSelectWnd.TerminalDetails = mclsTerminalDetails; clsContactCreditTypeSelectWnd.ShowDialog(this); clsCardTypeDetails = clsContactCreditTypeSelectWnd.CardTypeDetails; result = clsContactCreditTypeSelectWnd.Result; clsContactCreditTypeSelectWnd.Close(); clsContactCreditTypeSelectWnd.Dispose(); if (result != DialogResult.OK) { return; } Data.ContactDetails clsContactDetails; ContactSelectWnd clsContactWnd = new ContactSelectWnd(); clsContactWnd.EnableContactAddUpdate = GetWriteAccess(mclsSalesTransactionDetails.CashierID, AccessTypes.Contacts) == System.Windows.Forms.DialogResult.OK; clsContactWnd.SysConfigDetails = mclsSysConfigDetails; clsContactWnd.TerminalDetails = mclsTerminalDetails; if (clsCardTypeDetails.WithGuarantor) { MessageBox.Show("Please select a GUARANTOR to issue Credit Card.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information); clsContactWnd.ContactGroupCategory = AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER; clsContactWnd.Header = "Select GUARANTOR to issue Credit Card."; clsContactWnd.ShowDialog(this); clsGuarantorDetails = clsContactWnd.Details; result = clsContactWnd.Result; clsContactWnd.Close(); clsContactWnd.Dispose(); if (result != DialogResult.OK) { return; } MessageBox.Show(clsGuarantorDetails.ContactName + " has been selected as guarantor." + Environment.NewLine + "Please select the CUSTOMER to issue Credit Card.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information); } clsContactWnd = new ContactSelectWnd(); clsContactWnd.EnableContactAddUpdate = GetWriteAccess(mclsSalesTransactionDetails.CashierID, AccessTypes.Contacts) == System.Windows.Forms.DialogResult.OK; clsContactWnd.SysConfigDetails = mclsSysConfigDetails; clsContactWnd.TerminalDetails = mclsTerminalDetails; clsContactWnd.ContactGroupCategory = AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER; clsContactWnd.Header = "Select CUSTOMER to issue Credit Card."; clsContactWnd.ShowDialog(this); clsContactDetails = clsContactWnd.Details; result = clsContactWnd.Result; clsContactWnd.Close(); clsContactWnd.Dispose(); if (result != DialogResult.OK) { return; } if (clsContactDetails.ContactID == Constants.ZERO || clsContactDetails.ContactID == Constants.C_RETAILPLUS_CUSTOMERID) { return; } // if no guarantor if (!clsCardTypeDetails.WithGuarantor) clsGuarantorDetails = new Data.ContactDetails(); clsEvent.AddEvent("[" + lblCashier.Text + "] Issuing credit card no to " + clsContactDetails.ContactName); Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction); mConnection = clsContact.Connection; mTransaction = clsContact.Transaction; clsContactDetails = clsContact.Details(clsContactDetails.ContactID); clsContact.CommitAndDispose(); if (clsContactDetails.CreditDetails.CreditCardNo != string.Empty && clsContactDetails.CreditDetails.CreditCardNo != null) { clsEvent.AddEventLn("Cancelled!"); clsEvent.AddEventLn("Credit Card No: " + clsContactDetails.CreditDetails.CreditCardNo + " was already issued to " + clsContactDetails.ContactName + " on " + clsContactDetails.CreditDetails.CreditAwardDate.ToString("MMM dd, yyyy hh:mm tt")); MessageBox.Show("Credit Card No: " + clsContactDetails.CreditDetails.CreditCardNo + " was already issued to " + clsContactDetails.ContactName + " on " + clsContactDetails.CreditDetails.CreditAwardDate.ToString("MMM dd, yyyy hh:mm tt") + "." + Environment.NewLine + " Please select another customer to issue Credit Card.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } clsEvent.AddEvent("[" + lblCashier.Text + "] Issuing credit card no to " + clsContactDetails.ContactName); ContactCreditWnd clsContactCreditWnd = new ContactCreditWnd(); clsContactCreditWnd.Header = "Credit Card Issuance"; clsContactCreditWnd.CardTypeDetails = clsCardTypeDetails; clsContactCreditWnd.Guarantor = clsGuarantorDetails; clsContactCreditWnd.ContactDetails = clsContactDetails; clsContactCreditWnd.CreditCardStatus = CreditCardStatus.New; clsContactCreditWnd.TerminalDetails = mclsTerminalDetails; clsContactCreditWnd.ShowDialog(this); result = clsContactCreditWnd.Result; clsContactDetails = clsContactCreditWnd.ContactDetails; clsContactCreditWnd.Close(); clsContactCreditWnd.Dispose(); if (result == DialogResult.OK) { Data.Products clsProducts = new Data.Products(mConnection, mTransaction); mConnection = clsProducts.Connection; mTransaction = clsProducts.Transaction; string strProductBarcode = Data.Products.DEFAULT_CREDIT_CARD_MEMBERSHIP_FEE_BARCODE; //override if with Guarantor if (clsCardTypeDetails.WithGuarantor) strProductBarcode = Data.Products.DEFAULT_SUPER_CARD_MEMBERSHIP_FEE_BARCODE; if (clsProducts.Details(strProductBarcode).ProductID == 0) { if (!clsCardTypeDetails.WithGuarantor) clsProducts.CREATE_CREDIT_CARD_MEMBERSHIP_FEE_BARCODE_PRODUCT(); else clsProducts.CREATE_SUPER_CARD_MEMBERSHIP_FEE_BARCODE_PRODUCT(); Methods.InsertAuditLog(mclsTerminalDetails, "System Administrator", AccessTypes.RewardCardChange, strProductBarcode + " product has been created coz it's not configured"); } clsProducts.CommitAndDispose(); MessageBox.Show("Credit Card No: " + clsContactDetails.CreditDetails.CreditCardNo + " was issued to " + clsContactDetails.ContactName + "." + Environment.NewLine + "Please collect the payment then close the transaction.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information); clsEvent.AddEventLn("Done!", true); clsEvent.AddEventLn("Credit Card No: " + clsContactDetails.CreditDetails.CreditCardNo + " was issued to " + clsContactDetails.ContactName + ".", true); LocalDB clsLocalDB = new LocalDB(mConnection, mTransaction); mConnection = clsLocalDB.Connection; mTransaction = clsLocalDB.Transaction; clsEvent.AddEvent("[" + lblCashier.Text + "] Creating " + strProductBarcode + "transaction for customer: "); LoadContact(AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER, clsContactDetails); if (!this.CreateTransaction()) return; txtBarCode.Text = strProductBarcode; ReadBarCode(); int iRow = dgItems.CurrentRowIndex; txtBarCode.Text = ""; CloseTransaction(); clsLocalDB.CommitAndDispose(); } else { clsEvent.AddEventLn("Cancelled!"); } } catch (Exception ex) { InsertErrorLogToFile(ex, "ERROR!!! Issuing internal credit-card."); } Cursor.Current = Cursors.Default; } }
protected void cmdProductCode_Click(object sender, System.Web.UI.ImageClickEventArgs e) { DataClass clsDataClass = new DataClass(); Data.Products clsProduct = new Data.Products(); cboProductCode.DataTextField = "ProductCode"; cboProductCode.DataValueField = "ProductID"; string stSearchKey = txtProductCode.Text; cboProductCode.DataSource = clsProduct.ProductIDandCodeDataTable(SearchKey: stSearchKey, limit: 100); cboProductCode.DataBind(); clsProduct.CommitAndDispose(); bool bolShowCommandButtons = false; if (cboProductCode.Items.Count == 0) { cboProductCode.Items.Add(new ListItem("No product", "0")); bolShowCommandButtons = false; } else { bolShowCommandButtons = true; } ShowCommandButtons(bolShowCommandButtons); cboProductCode.SelectedIndex = 0; cboProductCode_SelectedIndexChanged(null, null); }
private void LoadOptionsProductHistory() { txtStartDate.Text = DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd"); txtEndDate.Text = DateTime.Now.ToString("yyyy-MM-dd"); try { if (Request.QueryString["productcode"].ToString() != null) { txtProductCodeSearch.Text = Common.Decrypt(Request.QueryString["productcode"].ToString(), Session.SessionID); } } catch { } string stSearchKey = txtProductCodeSearch.Text; Data.Products clsProduct = new Data.Products(); cboProductCode.DataTextField = "ProductCode"; cboProductCode.DataValueField = "ProductID"; cboProductCode.DataSource = clsProduct.ProductIDandCodeDataTable(SearchKey: stSearchKey, limit: 100); cboProductCode.DataBind(); clsProduct.CommitAndDispose(); if (cboProductCode.Items.Count == 0) cboProductCode.Items.Add(new ListItem("No product", "0")); cboProductCode.SelectedIndex = 0; cboProductCode_SelectedIndexChanged(null, null); try { if (Request.QueryString["productcode"].ToString() != null && cboProductCode.SelectedItem.Value != "0") GenerateHTML(); } catch { } }
private void ReadBarCode() { try { if (string.IsNullOrEmpty(txtBarCode.Text)) { return; } Data.Products clsProducts = new Data.Products(); Data.ProductDetails clsProductDetails = clsProducts.Details(txtBarCode.Text); clsProducts.CommitAndDispose(); if (clsProductDetails.ProductID == 0) { lblProductDesc.Text = "Item not found in db"; lblProductDesc.Tag = "Item not found in db"; txtUnitCode.Text = "PCS"; } else { if (clsProductDetails.ProductCode != clsProductDetails.ProductDesc) lblProductDesc.Text = clsProductDetails.ProductCode + ": " + clsProductDetails.ProductDesc; else lblProductDesc.Text = clsProductDetails.ProductDesc; lblProductDesc.Tag = clsProductDetails.ProductCode; txtUnitCode.Text = clsProductDetails.BaseUnitCode; } } catch { } }
private void ChangeProductCode() { int iOldRow = dgItems.CurrentRowIndex; int iRow = dgItems.CurrentRowIndex; if (iRow >= 0) { if (dgItems[iRow, 8].ToString() != "VOID") { if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto) { MessageBox.Show("Sorry you cannot change quantity if Auto-print is ON.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.ChangeQuantity); if (loginresult == DialogResult.OK) { Data.SalesTransactionItemDetails Details = getCurrentRowItemDetails(); string oldproductCode = Details.ProductCode; ChangeProductCodeWnd ProdCodeWnd = new ChangeProductCodeWnd(); ProdCodeWnd.Details = Details; ProdCodeWnd.TerminalDetails = mclsTerminalDetails; ProdCodeWnd.ShowDialog(this); DialogResult result = ProdCodeWnd.Result; Details = ProdCodeWnd.Details; ProdCodeWnd.Close(); ProdCodeWnd.Dispose(); if (result == DialogResult.OK && oldproductCode != Details.ProductCode) { Data.Products clsProduct = new Data.Products(mConnection, mTransaction); mConnection = clsProduct.Connection; mTransaction = clsProduct.Transaction; mbodgItemRowClick = true; clsEvent.AddEventLn("Updating item #".PadRight(15) + ":" + Details.ItemNo + "".PadRight(15) + " productcode from:" + oldproductCode + " to " + Details.ProductCode, true); System.Data.DataRow dr = (System.Data.DataRow)ItemDataTable.Rows[iRow]; dr = setCurrentRowItemDetails(dr, Details); ComputeSubTotal(); setTotalDetails(); Details.TransactionID = Convert.ToInt64(lblTransNo.Tag); Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction); mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction; clsSalesTransactions.UpdateItem(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.GrossSales, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.NetSales, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.SNRDiscount, mclsSalesTransactionDetails.PWDDiscount, mclsSalesTransactionDetails.OtherDiscount, mclsSalesTransactionDetails.TransDiscount, mclsSalesTransactionDetails.TransDiscountType, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, mclsSalesTransactionDetails.DiscountCode, mclsSalesTransactionDetails.DiscountRemarks, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.ChargeAmount, mclsSalesTransactionDetails.ChargeCode, mclsSalesTransactionDetails.ChargeRemarks, mclsSalesTransactionDetails.ChargeType, Details); clsSalesTransactions.CommitAndDispose(); // 10Jul2015 : Update the item list mclsSalesTransactionDetails.TransactionItemsList[mclsSalesTransactionDetails.TransactionItemsList.FindIndex(x => x.ItemNo == Details.ItemNo)] = Details; clsEvent.AddEventLn("Updating item #".PadRight(15) + ":" + Details.ItemNo + " : done", true); clsProduct.CommitAndDispose(); mbodgItemRowClick = false; DisplayItemToTurretDelegate DisplayItemToTurretDel = new DisplayItemToTurretDelegate(DisplayItemToTurret); DisplayItemToTurretDel.BeginInvoke(Details.Description, Details.ProductUnitCode, Details.Quantity, Details.Price, Details.Discount, Details.PromoApplied, Details.Amount, Details.VAT, Details.EVAT, null, null); } } } } }
private void LoadProduct() { string strSearchKey = txtProductCode.Text.Trim(); Data.ProductDetails clsSearchKeys = new Data.ProductDetails(); clsSearchKeys.BarCode = strSearchKey; clsSearchKeys.BarCode2 = strSearchKey; clsSearchKeys.BarCode3 = strSearchKey; clsSearchKeys.ProductCode = strSearchKey; clsSearchKeys.ProductSubGroupID = long.Parse(cboProductSubGroup.SelectedItem.Value); clsSearchKeys.ProductGroupID = long.Parse(cboProductGroup.SelectedItem.Value); Data.Products clsProduct = new Data.Products(); cboProductCode.DataTextField = "ProductCode"; cboProductCode.DataValueField = "ProductID"; cboProductCode.DataSource = clsProduct.ListAsDataTable(clsSearchKeys: clsSearchKeys, limit: 100).DefaultView; cboProductCode.DataBind(); clsProduct.CommitAndDispose(); if (cboProductCode.Items.Count == 0) cboProductCode.Items.Insert(0, new ListItem(Constants.ALL, Constants.ZERO_STRING)); cboProductCode.SelectedIndex = 0; cboProductCode_SelectedIndexChanged(null, null); }
static void Main(string[] args) { try { WriteProcessToMonitor("Starting RetailPlus monitoring tool..."); // check if it's already running if (System.Diagnostics.Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)).Count() > 1) { WriteProcessToMonitor(" already running. not ok"); return; } WriteProcessToMonitor(" ok"); Data.Database clsDatabase = new Data.Database(); back: WriteProcessToMonitor("Checking connections to server."); if (IPAddress.IsOpen(AceSoft.RetailPlus.DBConnection.ServerIP(), DBConnection.DBPort()) == false) { WriteProcessToMonitor(" cannot connect to server please check."); goto exit; } WriteProcessToMonitor(" ok"); WriteProcessToMonitor("Checking connections to database."); clsDatabase.GetConnection(username: "******", password: "******"); try { bool boIsDBAlive = clsDatabase.IsAlive(); WriteProcessToMonitor(" connected to '" + clsDatabase.Connection.ConnectionString.Split(';')[0].ToString().Replace("Data Source=", "") + "'"); } catch (Exception ex) { WriteProcessToMonitor(" ERROR connecting to database. Exception: " + ex.ToString()); } #region Timed-Out Process WriteProcessToMonitor("Checking timed-out process."); System.Data.DataTable dtProcessList = clsDatabase.getProcessList(); foreach (DataRow dr in dtProcessList.Rows) { int iID = int.Parse(dr["ID"].ToString()); string strHost = dr["Host"].ToString(); string strDB = dr["db"].ToString(); int iTime = int.Parse(dr["Time"].ToString()); string strInfo = dr["Info"].ToString(); if (strInfo.ToUpper() != "SHOW PROCESSLIST" || strDB == "pos") { WriteProcessToMonitor(" id:" + iID.ToString() + " host:" + strHost + " Time:" + iTime.ToString() + " Info:" + strInfo); if (iTime > Constants.C_DEFAULT_MYSQL_PROCESS_TIMEOUT && strDB == "pos") { WriteProcessToMonitor(" status not ok... killing process id: " + iID.ToString()); clsDatabase.killProcess(iID); WriteProcessToMonitor(" done."); } else if (iTime > 16 && string.IsNullOrEmpty(strInfo)) { WriteProcessToMonitor(" status idle... killing process id: " + iID.ToString()); clsDatabase.killProcess(iID); WriteProcessToMonitor(" done."); } else if (strInfo.Contains("INSERT INTO tblTransactions") && iTime >= 8) { WriteProcessToMonitor(" status not ok... flushing table tblTransactions...process id: " + iID.ToString()); clsDatabase.FlushTable("tblTransactions"); WriteProcessToMonitor(" done."); } else if (strInfo.Contains("UPDATE tblTerminalReport") && iTime >= 8) { WriteProcessToMonitor(" status not ok... flushing table tblTerminalReport...process id: " + iID.ToString()); clsDatabase.FlushTable("tblTerminalReport"); WriteProcessToMonitor(" done."); } else { WriteProcessToMonitor(" status ok"); } } } clsDatabase.CommitAndDispose(); // audit //clsDatabase = new Data.Database(clsDatabase.Connection, clsDatabase.Transaction); clsDatabase.GetConnection(username: "******", password: "******"); try { bool boIsDBAlive = clsDatabase.IsAlive(); WriteProcessToMonitor(" connected to '" + clsDatabase.Connection.ConnectionString.Split(';')[0].ToString().Replace("Data Source=", "") + "'"); } catch (Exception ex) { WriteProcessToMonitor(" ERROR connecting to database. Exception: " + ex.ToString()); } WriteProcessToMonitor("Checking Audit timed-out process."); dtProcessList = clsDatabase.getProcessList(); foreach (DataRow dr in dtProcessList.Rows) { int iID = int.Parse(dr["ID"].ToString()); string strHost = dr["Host"].ToString(); string strDB = dr["db"].ToString(); int iTime = int.Parse(dr["Time"].ToString()); string strInfo = dr["Info"].ToString(); if (strInfo.ToUpper() != "SHOW PROCESSLIST" || strDB == "pos") { WriteProcessToMonitor(" audit id:" + iID.ToString() + " host:" + strHost + " Time:" + iTime.ToString() + " Info:" + strInfo); if (iTime > Constants.C_DEFAULT_MYSQL_PROCESS_TIMEOUT && strDB == "pos") { WriteProcessToMonitor(" status not ok... killing process id: " + iID.ToString()); clsDatabase.killProcess(iID); WriteProcessToMonitor(" done."); } else { WriteProcessToMonitor(" status ok"); } } } clsDatabase.CommitAndDispose(); WriteProcessToMonitor(" done checking..."); #endregion string strSyncFunction = ""; try { strSyncFunction = System.Configuration.ConfigurationManager.AppSettings["SyncFunction"].ToString(); } catch { } if (strSyncFunction.ToLower().Trim() == "export") { #region Export Products //clsDatabase = new Data.Database(clsDatabase.Connection, clsDatabase.Transaction); clsDatabase.GetConnection(username: "******", password: "******"); Data.SysConfig clsSysConfig = new Data.SysConfig(clsDatabase.Connection, clsDatabase.Transaction); DateTime dteLastSyncDateTime = clsSysConfig.get_ProdLastSyncDateTime(); DateTime dteLastSyncDateTimeTo = dteLastSyncDateTime.AddMinutes(clsSysConfig.get_ProdSyncInterval()); if (dteLastSyncDateTimeTo <= DateTime.Now) { Data.DBSync clsDBSync = new Data.DBSync(clsDatabase.Connection, clsDatabase.Transaction); System.Data.DataTable stSyncItems = clsDBSync.ListAsDataTable("tblProducts", dteLastSyncDateTime, dteLastSyncDateTimeTo); if (stSyncItems.Rows.Count > 0) { string xmlFileName = @"C:\RetailPlus\RetailPlus\RetailPlus\temp\uploaded\prodsync\prod_" + dteLastSyncDateTime.ToString("yyyyMMddHHmmss") + ".xml"; if (!System.IO.File.Exists(xmlFileName)) { XmlTextWriter writer = new XmlTextWriter(xmlFileName, System.Text.Encoding.UTF8); writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); writer.WriteComment("This file represents the updated products."); writer.WriteStartElement("Header"); writer.WriteAttributeString("TableName", stSyncItems.TableName); writer.WriteAttributeString("LastSyncDateTime", dteLastSyncDateTime.ToString("yyyy-MM-dd HH:mm:ss")); writer.WriteAttributeString("LastSyncDateTimeTo", dteLastSyncDateTimeTo.ToString("yyyy-MM-dd HH:mm:ss")); foreach (DataRow dr in stSyncItems.Rows) { writer.WriteStartElement("Details"); foreach (DataColumn dc in dr.Table.Columns) { if (dc.DataType == System.Type.GetType("System.DateTime")) writer.WriteAttributeString(dc.ColumnName, DateTime.Parse(dr[dc.ColumnName].ToString()).ToString("yyyy-MM-dd HH:mm:ss")); else writer.WriteAttributeString(dc.ColumnName, dr[dc.ColumnName].ToString()); } writer.WriteEndElement(); } writer.WriteEndElement(); //Write the XML to file and close the writer writer.Flush(); writer.Close(); } } clsSysConfig = new Data.SysConfig(clsDatabase.Connection, clsDatabase.Transaction); clsSysConfig.Save(new Data.SysConfigDetails() { ConfigName = "ProdLastSyncDateTime", ConfigValue = dteLastSyncDateTimeTo.ToString("yyyy-MM-dd HH:mm:ss"), Category = "Sync" }); } clsDatabase.CommitAndDispose(); #endregion } else if (strSyncFunction.ToLower().Trim() == "import") { #region Import Products XmlTextReader xmlReader = new XmlTextReader(@"C:\RetailPlus\RetailPlus\RetailPlus\temp\uploaded\prodsync\prod_20150629183000.xml"); xmlReader.WhitespaceHandling = WhitespaceHandling.None; ////clsDatabase = new Data.Database(clsDatabase.Connection, clsDatabase.Transaction); clsDatabase.GetConnection(DBName: "poseamirror", username: "******", password: "******"); clsDatabase.SetForeignKey(false); Data.SysConfig clsSysConfig = new Data.SysConfig(clsDatabase.Connection, clsDatabase.Transaction); DateTime dteLastSyncDateTime = clsSysConfig.get_ProdLastSyncDateTime(); DateTime dteLastSyncDateTimeTo = dteLastSyncDateTime.AddMinutes(clsSysConfig.get_ProdSyncInterval()); Data.Products clsProducts = new Data.Products(clsDatabase.Connection, clsDatabase.Transaction); Data.ProductDetails clsProductDetails = new Data.ProductDetails(); string strTableName = ""; DateTime dteXmlLastSyncDateTime = Constants.C_DATE_MIN_VALUE; DateTime dteXmlLastSyncDateTimeTo = Constants.C_DATE_MIN_VALUE; while (xmlReader.Read()) { switch (xmlReader.NodeType) { case XmlNodeType.Element: if (xmlReader.Name == "Header") { strTableName = xmlReader.GetAttribute("TableName").ToString(); dteXmlLastSyncDateTime = DateTime.TryParse(xmlReader.GetAttribute("LastSyncDateTime").ToString(), out dteXmlLastSyncDateTime) ? dteXmlLastSyncDateTime : Constants.C_DATE_MIN_VALUE; dteXmlLastSyncDateTimeTo = DateTime.TryParse(xmlReader.GetAttribute("LastSyncDateTimeTo").ToString(), out dteXmlLastSyncDateTimeTo) ? dteXmlLastSyncDateTimeTo : Constants.C_DATE_MIN_VALUE; if (dteLastSyncDateTime >= dteXmlLastSyncDateTime) break; } else if (strTableName == "tblProducts" && xmlReader.Name == "Details") { clsProductDetails = Data.DBSync.setSyncProductDetails(xmlReader); clsProducts.Save(clsProductDetails); } break; } } if (dteLastSyncDateTime < dteXmlLastSyncDateTime) { clsSysConfig = new Data.SysConfig(clsDatabase.Connection, clsDatabase.Transaction); clsSysConfig.Save(new Data.SysConfigDetails() { ConfigName = "ProdLastSyncDateTime", ConfigValue = dteXmlLastSyncDateTimeTo.ToString("yyyy-MM-dd HH:mm:ss"), Category = "Sync" }); } clsDatabase.SetForeignKey(true); clsDatabase.CommitAndDispose(); #endregion } WriteProcessToMonitor("Waiting for next process..."); System.Threading.Thread.Sleep(20000); goto back; exit: WriteProcessToMonitor("Sytem terminated."); } catch (Exception ex) { WriteProcessToMonitor("PLEASE CALL RETAILPLUS IMMEDIATELY... error:" + ex.ToString()); } }
public void ReservedAndCommitItem(Data.SalesTransactionItemDetails Details, TransactionItemStatus _previousTransactionItemStatus) { // Sep 24, 2011 Lemuel E. Aceron // Added order slip wherein all punch items will not change sales and inventory // a customer named ORDER SLIP should be defined in contacts if (mclsSalesTransactionDetails.CustomerName.ToUpper() != Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER && mclsSalesTransactionDetails.CustomerDetails.ContactCode != mclsSysConfigDetails.OutOfStockCustomerCode && Details.TransactionItemStatus != TransactionItemStatus.Return) { // Added May 7, 2011 to Cater Reserved and Commit functionality //if (mclsTerminalDetails.ReservedAndCommit) //{ Data.Products clsProduct = new Data.Products(mConnection, mTransaction); mConnection = clsProduct.Connection; mTransaction = clsProduct.Transaction; Data.ProductUnit clsProductUnit = new Data.ProductUnit(mConnection, mTransaction); mConnection = clsProductUnit.Connection; mTransaction = clsProductUnit.Transaction; Data.ProductVariationsMatrix clsProductVariationsMatrix = new Data.ProductVariationsMatrix(mConnection, mTransaction); decimal decNewQuantity = 0; // both refund and normal transaction // Sep 14, 2013: remove the reserved and commit for refund. // refund quantity should only reflect for refund after closing of transaction. // // return is also not applicable for reserved an commit. // return quantity should only reflect for refund after closing of transaction. if (!mboIsRefund) { // SOLD items that are VOID if (Details.TransactionItemStatus == TransactionItemStatus.Void && _previousTransactionItemStatus != TransactionItemStatus.Return) { decNewQuantity = clsProductUnit.GetBaseUnitValue(Details.ProductID, Details.ProductUnitID, Details.Quantity * Details.PackageQuantity); clsProduct.SubtractReservedQuantity(Constants.TerminalBranchID, Details.ProductID, Details.VariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.DEDUCT_QTY_RESERVE_AND_COMMIT_VOID_ITEM), DateTime.Now, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); // Sep 14, 2013: remove // clsProduct.AddQuantity(Constants.TerminalBranchID, Details.ProductID, Details.VariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.ADD_RESERVE_AND_COMMIT_VOID_ITEM), DateTime.Now, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); // remove the ff codes for a change in Jul 26, 2011 // clsProduct.AddQuantity(Details.ProductID, decNewQuantity); // // if (Details.VariationsMatrixID != 0) // clsProductVariationsMatrix.AddQuantity(Details.VariationsMatrixID, decNewQuantity); } // SOLD items else if (Details.TransactionItemStatus != TransactionItemStatus.Void) { decNewQuantity = clsProductUnit.GetBaseUnitValue(Details.ProductID, Details.ProductUnitID, Details.Quantity * Details.PackageQuantity); if (mclsTerminalDetails.IsParkingTerminal) clsProduct.AddReservedQuantity(Constants.TerminalBranchID, Details.ProductID, Details.VariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.PARKING_IN) + " @ " + (Details.Amount / decNewQuantity).ToString("#,##0.#0") + " Buying: " + Details.PurchasePrice.ToString("#,##0.#0") + " Orig Selling: " + Details.Price.ToString("#,##0.#0") + " Discount: " + (Details.Price - (Details.Amount / decNewQuantity)).ToString("#,##0.#0") + " to " + mclsSalesTransactionDetails.CustomerName, DateTime.Now, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); else clsProduct.AddReservedQuantity(Constants.TerminalBranchID, Details.ProductID, Details.VariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.DEDUCT_SOLD_RETAIL) + " @ " + (Details.Amount / decNewQuantity).ToString("#,##0.#0") + " Buying: " + Details.PurchasePrice.ToString("#,##0.#0") + " Orig Selling: " + Details.Price.ToString("#,##0.#0") + " Discount: " + (Details.Price - (Details.Amount / decNewQuantity)).ToString("#,##0.#0") + " to " + mclsSalesTransactionDetails.CustomerName, DateTime.Now, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName); // remove the ff codes for a change in Jul 26, 2011 // clsProduct.SubtractQuantity(Details.ProductID, decNewQuantity); // // if (Details.VariationsMatrixID != 0) // clsProductVariationsMatrix.SubtractQuantity(Details.VariationsMatrixID, decNewQuantity); } } //} } }
public bool ApplyPromoBySupplierValue(PromoBySupplierDetails clsPromoBySupplierDetails, Int64 ContactID, Int64 ProductGroupID, Int64 ProductSubGroupID, Int64 ProductID, Int64 VariationMatrixID, out decimal PromoBySupplierValue, out string CouponRemarks, int BranchID = 0) { string strSpecialSupplierIDs = ""; PromoBySupplierValue = 0; CouponRemarks = ""; bool boHasPromoBySupplier = true; try { if (ProductID != 0) { Data.Products clsProduct = new Data.Products(base.Connection, base.Transaction); Data.ProductDetails clsProductDetails = clsProduct.Details1(BranchID, ProductID); ProductSubGroupID = clsProductDetails.ProductSubGroupID; ProductGroupID = clsProductDetails.ProductGroupID; } MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; string SQL = ""; string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName); /*******************************Up to Contact, Group, Sub, Prod and VarM ID *****************************/ SQL = "SELECT " + "PromoBySupplierItemsID, " + "a.PromoBySupplierID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "PromoBySupplierValue, " + "CouponRemarks " + "FROM tblPromoBySupplierItems a " + "INNER JOIN tblPromoBySupplier b ON a.PromoBySupplierID = b.PromoBySupplierID AND a.PromoBySupplierID = @PromoBySupplierID " + "WHERE " + (string.IsNullOrEmpty(strSpecialSupplierIDs) ? "ContactID = @ContactID " : "ContactID IN (@ContactID, " + strSpecialSupplierIDs + ") ") + "AND ProductGroupID = @ProductGroupID " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = @ProductID " + "AND VariationMatrixID = @VariationMatrixID " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoBySupplierValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@PromoBySupplierID", clsPromoBySupplierDetails.PromoBySupplierID); cmd.Parameters.AddWithValue("@ContactID", ContactID); cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID); cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoBySupplierValue = decimal.Parse(dr["PromoBySupplierValue"].ToString()); CouponRemarks = dr["CouponRemarks"].ToString(); return boHasPromoBySupplier; } /*******************************Up to Contact, Sub, Prod and VariationsMatrix ID *****************************/ SQL = "SELECT " + "PromoBySupplierItemsID, " + "a.PromoBySupplierID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "PromoBySupplierValue, " + "CouponRemarks " + "FROM tblPromoBySupplierItems a " + "INNER JOIN tblPromoBySupplier b ON a.PromoBySupplierID = b.PromoBySupplierID AND a.PromoBySupplierID = @PromoBySupplierID " + "WHERE " + (string.IsNullOrEmpty(strSpecialSupplierIDs) ? "ContactID = @ContactID " : "ContactID IN (@ContactID, " + strSpecialSupplierIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = @ProductID " + "AND VariationMatrixID = @VariationMatrixID " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoBySupplierValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@PromoBySupplierID", clsPromoBySupplierDetails.PromoBySupplierID); cmd.Parameters.AddWithValue("@ContactID", ContactID); cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoBySupplierValue = decimal.Parse(dr["PromoBySupplierValue"].ToString()); CouponRemarks = dr["CouponRemarks"].ToString(); return boHasPromoBySupplier; } /*******************************Up to Contact, Prod and VariationsMatrix ID *****************************/ SQL = "SELECT " + "PromoBySupplierItemsID, " + "a.PromoBySupplierID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "PromoBySupplierValue, " + "CouponRemarks " + "FROM tblPromoBySupplierItems a " + "INNER JOIN tblPromoBySupplier b ON a.PromoBySupplierID = b.PromoBySupplierID AND a.PromoBySupplierID = @PromoBySupplierID " + "WHERE " + (string.IsNullOrEmpty(strSpecialSupplierIDs) ? "ContactID = @ContactID " : "ContactID IN (@ContactID, " + strSpecialSupplierIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = 0 " + "AND ProductID = @ProductID " + "AND VariationMatrixID = @VariationMatrixID " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoBySupplierValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@PromoBySupplierID", clsPromoBySupplierDetails.PromoBySupplierID); cmd.Parameters.AddWithValue("@ContactID", ContactID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoBySupplierValue = decimal.Parse(dr["PromoBySupplierValue"].ToString()); CouponRemarks = dr["CouponRemarks"].ToString(); return boHasPromoBySupplier; } /*******************************Up to Contact, VariationsMatrix ID *****************************/ SQL = "SELECT " + "PromoBySupplierItemsID, " + "a.PromoBySupplierID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "PromoBySupplierValue, " + "CouponRemarks " + "FROM tblPromoBySupplierItems a " + "INNER JOIN tblPromoBySupplier b ON a.PromoBySupplierID = b.PromoBySupplierID AND a.PromoBySupplierID = @PromoBySupplierID " + "WHERE " + (string.IsNullOrEmpty(strSpecialSupplierIDs) ? "ContactID = @ContactID " : "ContactID IN (@ContactID, " + strSpecialSupplierIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = 0 " + "AND ProductID = 0 " + "AND VariationMatrixID = @VariationMatrixID " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoBySupplierValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@PromoBySupplierID", clsPromoBySupplierDetails.PromoBySupplierID); cmd.Parameters.AddWithValue("@ContactID", ContactID); cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoBySupplierValue = decimal.Parse(dr["PromoBySupplierValue"].ToString()); CouponRemarks = dr["CouponRemarks"].ToString(); return boHasPromoBySupplier; } /*******************************Up to Contact, Group, Sub, Prod ID *****************************/ SQL = "SELECT " + "PromoBySupplierItemsID, " + "a.PromoBySupplierID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "PromoBySupplierValue, " + "CouponRemarks " + "FROM tblPromoBySupplierItems a " + "INNER JOIN tblPromoBySupplier b ON a.PromoBySupplierID = b.PromoBySupplierID AND a.PromoBySupplierID = @PromoBySupplierID " + "WHERE " + (string.IsNullOrEmpty(strSpecialSupplierIDs) ? "ContactID = @ContactID " : "ContactID IN (@ContactID, " + strSpecialSupplierIDs + ") ") + "AND ProductGroupID = @ProductGroupID " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = @ProductID " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoBySupplierValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@PromoBySupplierID", clsPromoBySupplierDetails.PromoBySupplierID); cmd.Parameters.AddWithValue("@ContactID", ContactID); cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID); cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoBySupplierValue = decimal.Parse(dr["PromoBySupplierValue"].ToString()); CouponRemarks = dr["CouponRemarks"].ToString(); return boHasPromoBySupplier; } /*******************************Up to Contact, Sub, Prod ID *****************************/ SQL = "SELECT " + "PromoBySupplierItemsID, " + "a.PromoBySupplierID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "PromoBySupplierValue, " + "CouponRemarks " + "FROM tblPromoBySupplierItems a " + "INNER JOIN tblPromoBySupplier b ON a.PromoBySupplierID = b.PromoBySupplierID AND a.PromoBySupplierID = @PromoBySupplierID " + "WHERE " + (string.IsNullOrEmpty(strSpecialSupplierIDs) ? "ContactID = @ContactID " : "ContactID IN (@ContactID, " + strSpecialSupplierIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = @ProductID " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoBySupplierValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@PromoBySupplierID", clsPromoBySupplierDetails.PromoBySupplierID); cmd.Parameters.AddWithValue("@ContactID", ContactID); cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoBySupplierValue = decimal.Parse(dr["PromoBySupplierValue"].ToString()); CouponRemarks = dr["CouponRemarks"].ToString(); return boHasPromoBySupplier; } /*******************************Up to Contact, Prod ID *****************************/ SQL = "SELECT " + "PromoBySupplierItemsID, " + "a.PromoBySupplierID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "PromoBySupplierValue, " + "CouponRemarks " + "FROM tblPromoBySupplierItems a " + "INNER JOIN tblPromoBySupplier b ON a.PromoBySupplierID = b.PromoBySupplierID AND a.PromoBySupplierID = @PromoBySupplierID " + "WHERE " + (string.IsNullOrEmpty(strSpecialSupplierIDs) ? "ContactID = @ContactID " : "ContactID IN (@ContactID, " + strSpecialSupplierIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = 0 " + "AND ProductID = @ProductID " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoBySupplierValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@PromoBySupplierID", clsPromoBySupplierDetails.PromoBySupplierID); cmd.Parameters.AddWithValue("@ContactID", ContactID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoBySupplierValue = decimal.Parse(dr["PromoBySupplierValue"].ToString()); CouponRemarks = dr["CouponRemarks"].ToString(); return boHasPromoBySupplier; } /*******************************Up to Contact, Group, Sub *****************************/ SQL = "SELECT " + "PromoBySupplierItemsID, " + "a.PromoBySupplierID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "PromoBySupplierValue, " + "CouponRemarks " + "FROM tblPromoBySupplierItems a " + "INNER JOIN tblPromoBySupplier b ON a.PromoBySupplierID = b.PromoBySupplierID AND a.PromoBySupplierID = @PromoBySupplierID " + "WHERE " + (string.IsNullOrEmpty(strSpecialSupplierIDs) ? "ContactID = @ContactID " : "ContactID IN (@ContactID, " + strSpecialSupplierIDs + ") ") + "AND ProductGroupID = @ProductGroupID " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = 0 " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoBySupplierValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@PromoBySupplierID", clsPromoBySupplierDetails.PromoBySupplierID); cmd.Parameters.AddWithValue("@ContactID", ContactID); cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID); cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoBySupplierValue = decimal.Parse(dr["PromoBySupplierValue"].ToString()); CouponRemarks = dr["CouponRemarks"].ToString(); return boHasPromoBySupplier; } /*******************************Up to Contact, Sub *****************************/ SQL = "SELECT " + "PromoBySupplierItemsID, " + "a.PromoBySupplierID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "PromoBySupplierValue, " + "CouponRemarks " + "FROM tblPromoBySupplierItems a " + "INNER JOIN tblPromoBySupplier b ON a.PromoBySupplierID = b.PromoBySupplierID AND a.PromoBySupplierID = @PromoBySupplierID " + "WHERE " + (string.IsNullOrEmpty(strSpecialSupplierIDs) ? "ContactID = @ContactID " : "ContactID IN (@ContactID, " + strSpecialSupplierIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = 0 " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoBySupplierValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@PromoBySupplierID", clsPromoBySupplierDetails.PromoBySupplierID); cmd.Parameters.AddWithValue("@ContactID", ContactID); cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoBySupplierValue = decimal.Parse(dr["PromoBySupplierValue"].ToString()); CouponRemarks = dr["CouponRemarks"].ToString(); return boHasPromoBySupplier; } /*******************************Up to Contact *****************************/ SQL = "SELECT " + "PromoBySupplierItemsID, " + "a.PromoBySupplierID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "PromoBySupplierValue, " + "CouponRemarks " + "FROM tblPromoBySupplierItems a " + "INNER JOIN tblPromoBySupplier b ON a.PromoBySupplierID = b.PromoBySupplierID AND a.PromoBySupplierID = @PromoBySupplierID " + "WHERE " + (string.IsNullOrEmpty(strSpecialSupplierIDs) ? "ContactID = @ContactID " : "ContactID IN (@ContactID, " + strSpecialSupplierIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = 0 " + "AND ProductID = 0 " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoBySupplierValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@PromoBySupplierID", clsPromoBySupplierDetails.PromoBySupplierID); cmd.Parameters.AddWithValue("@ContactID", ContactID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoBySupplierValue = decimal.Parse(dr["PromoBySupplierValue"].ToString()); CouponRemarks = dr["CouponRemarks"].ToString(); return boHasPromoBySupplier; } /*******************************Up to Group, Sub, Prod and VarM ID *****************************/ SQL = "SELECT " + "PromoBySupplierItemsID, " + "a.PromoBySupplierID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "PromoBySupplierValue, " + "CouponRemarks " + "FROM tblPromoBySupplierItems a " + "INNER JOIN tblPromoBySupplier b ON a.PromoBySupplierID = b.PromoBySupplierID AND a.PromoBySupplierID = @PromoBySupplierID " + "WHERE " + (string.IsNullOrEmpty(strSpecialSupplierIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialSupplierIDs + ") ") + "AND ProductGroupID = @ProductGroupID " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = @ProductID " + "AND VariationMatrixID = @VariationMatrixID " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoBySupplierValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@PromoBySupplierID", clsPromoBySupplierDetails.PromoBySupplierID); cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID); cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoBySupplierValue = decimal.Parse(dr["PromoBySupplierValue"].ToString()); CouponRemarks = dr["CouponRemarks"].ToString(); return boHasPromoBySupplier; } /*******************************Up to Sub, Prod and VariationMatrix ID *****************************/ SQL = "SELECT " + "PromoBySupplierItemsID, " + "a.PromoBySupplierID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "PromoBySupplierValue, " + "CouponRemarks " + "FROM tblPromoBySupplierItems a " + "INNER JOIN tblPromoBySupplier b ON a.PromoBySupplierID = b.PromoBySupplierID AND a.PromoBySupplierID = @PromoBySupplierID " + "WHERE " + (string.IsNullOrEmpty(strSpecialSupplierIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialSupplierIDs + ") ") + "AND ProductGroupID =0 " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = @ProductID " + "AND VariationMatrixID = @VariationMatrixID " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoBySupplierValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@PromoBySupplierID", clsPromoBySupplierDetails.PromoBySupplierID); cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoBySupplierValue = decimal.Parse(dr["PromoBySupplierValue"].ToString()); CouponRemarks = dr["CouponRemarks"].ToString(); return boHasPromoBySupplier; } /*******************************Up to Prod and VariationMatrix ID *****************************/ SQL = "SELECT " + "PromoBySupplierItemsID, " + "a.PromoBySupplierID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "PromoBySupplierValue, " + "CouponRemarks " + "FROM tblPromoBySupplierItems a " + "INNER JOIN tblPromoBySupplier b ON a.PromoBySupplierID = b.PromoBySupplierID AND a.PromoBySupplierID = @PromoBySupplierID " + "WHERE " + (string.IsNullOrEmpty(strSpecialSupplierIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialSupplierIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = 0 " + "AND ProductID = @ProductID " + "AND VariationMatrixID = @VariationMatrixID " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoBySupplierValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@PromoBySupplierID", clsPromoBySupplierDetails.PromoBySupplierID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoBySupplierValue = decimal.Parse(dr["PromoBySupplierValue"].ToString()); CouponRemarks = dr["CouponRemarks"].ToString(); return boHasPromoBySupplier; } /*******************************Up to VariationsMatrix ID *****************************/ SQL = "SELECT " + "PromoBySupplierItemsID, " + "a.PromoBySupplierID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "PromoBySupplierValue, " + "CouponRemarks " + "FROM tblPromoBySupplierItems a " + "INNER JOIN tblPromoBySupplier b ON a.PromoBySupplierID = b.PromoBySupplierID AND a.PromoBySupplierID = @PromoBySupplierID " + "WHERE " + (string.IsNullOrEmpty(strSpecialSupplierIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialSupplierIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = 0 " + "AND ProductID = 0 " + "AND VariationMatrixID = @VariationMatrixID " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoBySupplierValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@PromoBySupplierID", clsPromoBySupplierDetails.PromoBySupplierID); cmd.Parameters.AddWithValue("@VariationMatrixID", VariationMatrixID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoBySupplierValue = decimal.Parse(dr["PromoBySupplierValue"].ToString()); CouponRemarks = dr["CouponRemarks"].ToString(); return boHasPromoBySupplier; } /*******************************Up to group, Sub, Prod ID *****************************/ SQL = "SELECT " + "PromoBySupplierItemsID, " + "a.PromoBySupplierID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "PromoBySupplierValue, " + "CouponRemarks " + "FROM tblPromoBySupplierItems a " + "INNER JOIN tblPromoBySupplier b ON a.PromoBySupplierID = b.PromoBySupplierID AND a.PromoBySupplierID = @PromoBySupplierID " + "WHERE " + (string.IsNullOrEmpty(strSpecialSupplierIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialSupplierIDs + ") ") + "AND ProductGroupID = @ProductGroupID " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = @ProductID " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoBySupplierValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@PromoBySupplierID", clsPromoBySupplierDetails.PromoBySupplierID); cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID); cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoBySupplierValue = decimal.Parse(dr["PromoBySupplierValue"].ToString()); CouponRemarks = dr["CouponRemarks"].ToString(); return boHasPromoBySupplier; } /*******************************Up to Sub, Prod ID *****************************/ SQL = "SELECT " + "PromoBySupplierItemsID, " + "a.PromoBySupplierID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "PromoBySupplierValue, " + "CouponRemarks " + "FROM tblPromoBySupplierItems a " + "INNER JOIN tblPromoBySupplier b ON a.PromoBySupplierID = b.PromoBySupplierID AND a.PromoBySupplierID = @PromoBySupplierID " + "WHERE " + (string.IsNullOrEmpty(strSpecialSupplierIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialSupplierIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = @ProductID " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoBySupplierValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@PromoBySupplierID", clsPromoBySupplierDetails.PromoBySupplierID); cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoBySupplierValue = decimal.Parse(dr["PromoBySupplierValue"].ToString()); CouponRemarks = dr["CouponRemarks"].ToString(); return boHasPromoBySupplier; } /*******************************Up to group, Sub, Prod and VariationMatrix ID *****************************/ SQL = "SELECT " + "PromoBySupplierItemsID, " + "a.PromoBySupplierID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "PromoBySupplierValue, " + "CouponRemarks " + "FROM tblPromoBySupplierItems a " + "INNER JOIN tblPromoBySupplier b ON a.PromoBySupplierID = b.PromoBySupplierID AND a.PromoBySupplierID = @PromoBySupplierID " + "WHERE " + (string.IsNullOrEmpty(strSpecialSupplierIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialSupplierIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = 0 " + "AND ProductID = @ProductID " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoBySupplierValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@PromoBySupplierID", clsPromoBySupplierDetails.PromoBySupplierID); cmd.Parameters.AddWithValue("@ProductID", ProductID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoBySupplierValue = decimal.Parse(dr["PromoBySupplierValue"].ToString()); CouponRemarks = dr["CouponRemarks"].ToString(); return boHasPromoBySupplier; } /*******************************Up to group, Sub ID *****************************/ SQL = "SELECT " + "PromoBySupplierItemsID, " + "a.PromoBySupplierID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "PromoBySupplierValue, " + "CouponRemarks " + "FROM tblPromoBySupplierItems a " + "INNER JOIN tblPromoBySupplier b ON a.PromoBySupplierID = b.PromoBySupplierID AND a.PromoBySupplierID = @PromoBySupplierID " + "WHERE " + (string.IsNullOrEmpty(strSpecialSupplierIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialSupplierIDs + ") ") + "AND ProductGroupID = @ProductGroupID " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = 0 " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoBySupplierValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@PromoBySupplierID", clsPromoBySupplierDetails.PromoBySupplierID); cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID); cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoBySupplierValue = decimal.Parse(dr["PromoBySupplierValue"].ToString()); CouponRemarks = dr["CouponRemarks"].ToString(); return boHasPromoBySupplier; } /*******************************Up to Sub ID *****************************/ SQL = "SELECT " + "PromoBySupplierItemsID, " + "a.PromoBySupplierID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "PromoBySupplierValue, " + "CouponRemarks " + "FROM tblPromoBySupplierItems a " + "INNER JOIN tblPromoBySupplier b ON a.PromoBySupplierID = b.PromoBySupplierID AND a.PromoBySupplierID = @PromoBySupplierID " + "WHERE " + (string.IsNullOrEmpty(strSpecialSupplierIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialSupplierIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = @ProductSubGroupID " + "AND ProductID = 0 " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoBySupplierValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@PromoBySupplierID", clsPromoBySupplierDetails.PromoBySupplierID); cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoBySupplierValue = decimal.Parse(dr["PromoBySupplierValue"].ToString()); CouponRemarks = dr["CouponRemarks"].ToString(); return boHasPromoBySupplier; } /*******************************Up to group ID *****************************/ SQL = "SELECT " + "PromoBySupplierItemsID, " + "a.PromoBySupplierID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "PromoBySupplierValue, " + "CouponRemarks " + "FROM tblPromoBySupplierItems a " + "INNER JOIN tblPromoBySupplier b ON a.PromoBySupplierID = b.PromoBySupplierID AND a.PromoBySupplierID = @PromoBySupplierID " + "WHERE " + (string.IsNullOrEmpty(strSpecialSupplierIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialSupplierIDs + ") ") + "AND ProductGroupID = @ProductGroupID " + "AND ProductSubGroupID = 0 " + "AND ProductID = 0 " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoBySupplierValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@PromoBySupplierID", clsPromoBySupplierDetails.PromoBySupplierID); cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoBySupplierValue = decimal.Parse(dr["PromoBySupplierValue"].ToString()); CouponRemarks = dr["CouponRemarks"].ToString(); return boHasPromoBySupplier; } /*******************************Up to all *****************************/ SQL = "SELECT " + "PromoBySupplierItemsID, " + "a.PromoBySupplierID, " + "ProductGroupID, " + "ProductSubGroupID, " + "ProductID, " + "VariationMatrixID, " + "PromoBySupplierValue, " + "CouponRemarks " + "FROM tblPromoBySupplierItems a " + "INNER JOIN tblPromoBySupplier b ON a.PromoBySupplierID = b.PromoBySupplierID AND a.PromoBySupplierID = @PromoBySupplierID " + "WHERE " + (string.IsNullOrEmpty(strSpecialSupplierIDs) ? "ContactID = 0 " : "ContactID IN (0, " + strSpecialSupplierIDs + ") ") + "AND ProductGroupID = 0 " + "AND ProductSubGroupID = 0 " + "AND ProductID = 0 " + "AND VariationMatrixID = 0 " + "AND Status = 1 " + "AND DATE_FORMAT(StartDate, '%Y-%m-%d %H:%i') <= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') " + "AND DATE_FORMAT(EndDate, '%Y-%m-%d %H:%i') >= DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i') ORDER BY PromoBySupplierValue ASC LIMIT 1;"; cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@PromoBySupplierID", clsPromoBySupplierDetails.PromoBySupplierID); cmd.CommandText = SQL; dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); foreach (System.Data.DataRow dr in dt.Rows) { PromoBySupplierValue = decimal.Parse(dr["PromoBySupplierValue"].ToString()); CouponRemarks = dr["CouponRemarks"].ToString(); return boHasPromoBySupplier; } } catch (Exception ex) { base.ThrowException(ex); } return false; }
public bool PrintOrderSlip(bool WillReprintAll, bool isFromSuspendTransaction = false) { bool boRetValue = true; if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto) { MessageBox.Show("Sorry this option is not applicable for Auto-Print receipt.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); return false; } if (!mboIsInTransaction) { MessageBox.Show("No active transaction is found! Please transact first.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); return false; } DialogResult loginresult = GetWriteAccess(mclsSalesTransactionDetails.CashierID, AccessTypes.SuspendTransaction); if (loginresult == DialogResult.None) { LogInWnd login = new LogInWnd(); login.AccessType = AccessTypes.SuspendTransaction; login.Header = "Print Order Slip Validation"; login.TerminalDetails = mclsTerminalDetails; login.ShowDialog(this); loginresult = login.Result; login.Close(); login.Dispose(); } if (loginresult != DialogResult.OK) { boRetValue = false; } else { if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoice) { PrintSalesInvoice(); } else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.DeliveryReceipt) { PrintDeliveryReceipt(); } else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceAndDR) { PrintSalesInvoice(); PrintDeliveryReceipt(); } else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceForLX300Printer) { PrintSalesInvoiceToLX(TerminalReceiptType.SalesInvoiceForLX300Printer); } //Added May 11, 2010 else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceOrDR) { PrintDeliveryReceipt(); } //Added January 17, 2011 else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceForLX300PlusPrinter) { PrintSalesInvoiceToLX(TerminalReceiptType.SalesInvoiceForLX300PlusPrinter); } //Added February 22, 2011 else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceForLX300PlusAmazon) { PrintSalesInvoiceToLX(TerminalReceiptType.SalesInvoiceForLX300PlusAmazon); //8.5inc x 7inch } else { Cursor.Show(); Cursor.Current = Cursors.WaitCursor; /************************* * Check if will reprint all items for ALT + S * December 18, 2008 * **********************/ bool bolRetailPlusOSPrinter1HeaderPrinted = false; bool bolRetailPlusOSPrinter2HeaderPrinted = false; bool bolRetailPlusOSPrinter3HeaderPrinted = false; bool bolRetailPlusOSPrinter4HeaderPrinted = false; bool bolRetailPlusOSPrinter5HeaderPrinted = false; Data.ProductComposition clsProductComposition = new Data.ProductComposition(mConnection, mTransaction); mConnection = clsProductComposition.Connection; mTransaction = clsProductComposition.Transaction; Data.Products clsProduct = new Data.Products(mConnection, mTransaction); mConnection = clsProduct.Connection; mTransaction = clsProduct.Transaction; // print order slip items in each printer foreach (System.Data.DataRow dr in ItemDataTable.Rows) { bool OrderSlipPrinted = Convert.ToBoolean(dr["OrderSlipPrinted"]); /**** * 05Dec2014 remove the WillReprintAll * it's only tagged as printed if success print * ***/ if (!OrderSlipPrinted || WillReprintAll) //if (!OrderSlipPrinted) { /**************************************** * Update items that are already printed * December 18, 2008 * * 05Dec2014 Remove this, should only set to true if success printing ****************************************/ //Int64 iTransactionItemsID = Convert.ToInt64(dr["TransactionItemsID"]); //clsSalesTransactionItems.UpdateOrderSlipPrinted(true, iTransactionItemsID, mclsSalesTransactionDetails.TransactionDate); if (dr["Quantity"].ToString() != "VOID" && dr["Quantity"].ToString().IndexOf("RETURN") == -1) { //string stItemNo = "" + dr["ItemNo"].ToString(); long lProductID = Convert.ToInt64(dr["ProductID"]); bool bolWillPrintProductComposition = clsProduct.WillPrintProductComposition(lProductID); string stProductCode = "" + dr["ProductCode"].ToString(); string stProductUnitCode = "" + dr["ProductUnitCode"].ToString(); decimal decQuantity = Convert.ToDecimal(dr["Quantity"]); string strItemRemarks = "" + dr["ItemRemarks"].ToString(); bool orderSlipPrinter1 = bool.Parse(dr["OrderSlipPrinter1"].ToString()); bool orderSlipPrinter2 = bool.Parse(dr["OrderSlipPrinter2"].ToString()); bool orderSlipPrinter3 = bool.Parse(dr["OrderSlipPrinter3"].ToString()); bool orderSlipPrinter4 = bool.Parse(dr["OrderSlipPrinter4"].ToString()); bool orderSlipPrinter5 = bool.Parse(dr["OrderSlipPrinter5"].ToString()); // print the headers if (orderSlipPrinter1 && !bolRetailPlusOSPrinter1HeaderPrinted) { bolRetailPlusOSPrinter1HeaderPrinted = true; PrintOrderSlipHeader(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter1, WillReprintAll); } if (orderSlipPrinter2 && !bolRetailPlusOSPrinter2HeaderPrinted) { bolRetailPlusOSPrinter2HeaderPrinted = true; PrintOrderSlipHeader(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter2, WillReprintAll); } if (orderSlipPrinter3 && !bolRetailPlusOSPrinter3HeaderPrinted) { bolRetailPlusOSPrinter3HeaderPrinted = true; PrintOrderSlipHeader(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter3, WillReprintAll); } if (orderSlipPrinter4 && !bolRetailPlusOSPrinter4HeaderPrinted) { bolRetailPlusOSPrinter4HeaderPrinted = true; PrintOrderSlipHeader(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter4, WillReprintAll); } if (orderSlipPrinter5 && !bolRetailPlusOSPrinter5HeaderPrinted) { bolRetailPlusOSPrinter5HeaderPrinted = true; PrintOrderSlipHeader(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter5, WillReprintAll); } // print product composition first: // if there are product compositions no need to print product if (bolWillPrintProductComposition) { if (!PrintOrderSlipComposition(lProductID, stProductCode, stProductUnitCode, decQuantity, bolWillPrintProductComposition)) { // if there are no product composition // print the product only if (orderSlipPrinter1) { PrintItemToOSPrinter(stProductCode, stProductUnitCode, decQuantity, OrderSlipPrinter.RetailPlusOSPrinter1, true, strItemRemarks); } if (orderSlipPrinter2) { PrintItemToOSPrinter(stProductCode, stProductUnitCode, decQuantity, OrderSlipPrinter.RetailPlusOSPrinter2, true, strItemRemarks); } if (orderSlipPrinter3) { PrintItemToOSPrinter(stProductCode, stProductUnitCode, decQuantity, OrderSlipPrinter.RetailPlusOSPrinter3, true, strItemRemarks); } if (orderSlipPrinter4) { PrintItemToOSPrinter(stProductCode, stProductUnitCode, decQuantity, OrderSlipPrinter.RetailPlusOSPrinter4, true, strItemRemarks); } if (orderSlipPrinter5) { PrintItemToOSPrinter(stProductCode, stProductUnitCode, decQuantity, OrderSlipPrinter.RetailPlusOSPrinter5, true, strItemRemarks); } } } else { // if there are no product composition // print the product only if (orderSlipPrinter1) { PrintItemToOSPrinter(stProductCode, stProductUnitCode, decQuantity, OrderSlipPrinter.RetailPlusOSPrinter1, true, strItemRemarks); } if (orderSlipPrinter2) { PrintItemToOSPrinter(stProductCode, stProductUnitCode, decQuantity, OrderSlipPrinter.RetailPlusOSPrinter2, true, strItemRemarks); } if (orderSlipPrinter3) { PrintItemToOSPrinter(stProductCode, stProductUnitCode, decQuantity, OrderSlipPrinter.RetailPlusOSPrinter3, true, strItemRemarks); } if (orderSlipPrinter4) { PrintItemToOSPrinter(stProductCode, stProductUnitCode, decQuantity, OrderSlipPrinter.RetailPlusOSPrinter4, true, strItemRemarks); } if (orderSlipPrinter5) { PrintItemToOSPrinter(stProductCode, stProductUnitCode, decQuantity, OrderSlipPrinter.RetailPlusOSPrinter5, true, strItemRemarks); } } } /**************************************** * Update items that are already printed * December 18, 2008 * * 05Dec2014 Remove this, should only set to true if success printing ****************************************/ // dr["OrderSlipPrinted"] = true.ToString(); } } clsProductComposition.CommitAndDispose(); // print order slip footer in each printer if (bolRetailPlusOSPrinter1HeaderPrinted) { if (isPrinterOnline(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter1.ToString("G"))) { if (!PrintOrderSlipFooter(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter1)) { ShowOrderSlipPrinterError(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter1, isFromSuspendTransaction); boRetValue = false; } else UpdateOrderSlipAsPrinted(OrderSlipPrinter.RetailPlusOSPrinter1); //boRetValue = boRetValue; } else { ShowOrderSlipPrinterError(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter1, isFromSuspendTransaction, true); boRetValue = false; } } if (bolRetailPlusOSPrinter2HeaderPrinted) { if (isPrinterOnline(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter2.ToString("G"))) { if (!PrintOrderSlipFooter(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter2)) { ShowOrderSlipPrinterError(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter2, isFromSuspendTransaction); boRetValue = false; } else UpdateOrderSlipAsPrinted(OrderSlipPrinter.RetailPlusOSPrinter2); //boRetValue = boRetValue; } else { ShowOrderSlipPrinterError(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter2, isFromSuspendTransaction, true); boRetValue = false; } } if (bolRetailPlusOSPrinter3HeaderPrinted) { if (isPrinterOnline(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter3.ToString("G"))) { if (!PrintOrderSlipFooter(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter3)) { ShowOrderSlipPrinterError(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter3, isFromSuspendTransaction); boRetValue = false; } else UpdateOrderSlipAsPrinted(OrderSlipPrinter.RetailPlusOSPrinter3); //boRetValue = boRetValue } else { ShowOrderSlipPrinterError(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter3, isFromSuspendTransaction, true); boRetValue = false; } } if (bolRetailPlusOSPrinter4HeaderPrinted) { if (isPrinterOnline(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter4.ToString("G"))) { if (!PrintOrderSlipFooter(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter4)) { ShowOrderSlipPrinterError(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter4, isFromSuspendTransaction); boRetValue = false; } else UpdateOrderSlipAsPrinted(OrderSlipPrinter.RetailPlusOSPrinter4); //boRetValue = boRetValue; } else { ShowOrderSlipPrinterError(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter4, isFromSuspendTransaction, true); boRetValue = false; } } if (bolRetailPlusOSPrinter5HeaderPrinted) { if (isPrinterOnline(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter5.ToString("G"))) { if (!PrintOrderSlipFooter(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter5)) { ShowOrderSlipPrinterError(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter5, isFromSuspendTransaction); boRetValue = false; } else UpdateOrderSlipAsPrinted(OrderSlipPrinter.RetailPlusOSPrinter5); } else { ShowOrderSlipPrinterError(AceSoft.RetailPlus.OrderSlipPrinter.RetailPlusOSPrinter5, isFromSuspendTransaction, true); boRetValue = false; } } Cursor.Current = Cursors.Default; Cursor.Hide(); // show message only if boRetValue=true // no need to message if boRetValue=false, coz it has already shown error message if (boRetValue && !isFromSuspendTransaction) { if (WillReprintAll) MessageBox.Show("Order's has been re-send to Kitchen/Bar printer's.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); else MessageBox.Show("Order's has been sent to Kitchen/Bar printer's.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } } } return boRetValue; }
private void CreditsItemizeWnd_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyData) { case Keys.Escape: if (grpSearch.Visible) { grpSearch.Visible = false; dgvItems.Focus(); cmdEnter.Text = "Enter"; } else { this.Hide(); } break; case Keys.Enter: if (grpSearch.Visible) { LoadData(); } else if (Convert.ToDecimal(lblBalanceSelected.Text) > 0) { Data.Products clsProducts = new Data.Products(); if (clsProducts.Details(Data.Products.DEFAULT_CREDIT_PAYMENT_BARCODE).ProductID == 0) { clsProducts.CREATE_CREDITPAYMENT_PRODUCT(); Methods.InsertAuditLog(TerminalDetails, "System Administrator", AccessTypes.EnterCreditPayment, "CREDIT PAYMENT product has been created coz it's not configured"); } clsProducts.CommitAndDispose(); dialog = ShowPayment(); if (dialog == DialogResult.OK) { mKeyData = Keys.Enter; this.Hide(); } } else this.Hide(); break; case Keys.F3: CreditSalesWnd clsCreditSalesWnd = new CreditSalesWnd(); clsCreditSalesWnd.TerminalDetails = TerminalDetails; clsCreditSalesWnd.SysConfigDetails = mclsSysConfigDetails; clsCreditSalesWnd.CustomerDetails = mclsCustomerDetails; clsCreditSalesWnd.ShowDialog(this); clsCreditSalesWnd.Close(); clsCreditSalesWnd.Dispose(); break; case Keys.F4: CreditPaymentsWnd clsCreditPaymentsWnd = new CreditPaymentsWnd(); clsCreditPaymentsWnd.TerminalDetails = TerminalDetails; clsCreditPaymentsWnd.SysConfigDetails = mclsSysConfigDetails; clsCreditPaymentsWnd.CustomerDetails = mclsCustomerDetails; clsCreditPaymentsWnd.CashierID = CashierID; clsCreditPaymentsWnd.ShowDialog(this); DialogResult result = clsCreditPaymentsWnd.Result; mclsCustomerDetails = clsCreditPaymentsWnd.CustomerDetails; clsCreditPaymentsWnd.Close(); clsCreditPaymentsWnd.Dispose(); if (result == System.Windows.Forms.DialogResult.OK) { LoadData(); } break; case Keys.F5: if (!lblF5.Visible) return; grpSearch.Visible = !grpSearch.Visible; if (grpSearch.Visible) { txtTrxStartDate.Focus(); cmdEnter.Text = "Search"; } else { dgvItems.Focus(); cmdEnter.Text = "Enter"; } break; case Keys.F11: if (!lblF11.Visible) return; if (dgvItems.Rows.Count > 0) { PrintSOA(); } break; case Keys.F12: if (!lblF12.Visible) return; TransactionNoToReprint = ""; TerminalNoToReprint = ""; foreach (DataGridViewRow dr in dgvItems.SelectedRows) { TransactionNoToReprint = dr.Cells["TransactionNo"].Value.ToString(); TerminalNoToReprint = dr.Cells["TerminalNo"].Value.ToString(); dialog = System.Windows.Forms.DialogResult.OK; mKeyData = Keys.F12; this.Hide(); break; } break; } }
private void LoadProduct() { string strSearchKey = txtProductCode.Text.Trim(); Data.ProductDetails clsSearchKeys = new Data.ProductDetails(); clsSearchKeys.BarCode = strSearchKey; clsSearchKeys.BarCode2 = strSearchKey; clsSearchKeys.BarCode3 = strSearchKey; clsSearchKeys.ProductCode = strSearchKey; Data.Products clsProduct = new Data.Products(); cboProductCode.DataTextField = "ProductCode"; cboProductCode.DataValueField = "ProductID"; cboProductCode.DataSource = clsProduct.ListAsDataTable(clsSearchKeys: clsSearchKeys, limit: 100); cboProductCode.DataBind(); clsProduct.CommitAndDispose(); if (cboProductCode.Items.Count == 0) cboProductCode.Items.Insert(0, new ListItem(Constants.PLEASE_SELECT, Constants.ZERO_STRING)); cboProductCode.SelectedIndex = 0; }
private void LoadOptions() { Int64 UID = Convert.ToInt64(Session["UID"]); Security.AccessRights clsAccessRights = new Security.AccessRights(); cboReportType.Items.Clear(); cboReportType.Items.Add(new ListItem(ReportTypes.REPORT_SELECTION, ReportTypes.REPORT_SELECTION)); cboReportType.Items.Add(new ListItem(ReportTypes.REPORT_SELECTION_SEPARATOR, ReportTypes.REPORT_SELECTION_SEPARATOR)); cboReportType.Items.Add(new ListItem(ReportTypes.ProductHistoryMovement, ReportTypes.ProductHistoryMovement)); if (clsAccessRights.Details(UID, (int)AccessTypes.PricesReport).Read) { cboReportType.Items.Add(new ListItem(ReportTypes.ProductHistoryPrice, ReportTypes.ProductHistoryPrice)); } cboReportType.Items.Add(new ListItem(ReportTypes.REPORT_SELECTION_SEPARATOR, ReportTypes.REPORT_SELECTION_SEPARATOR)); if (clsAccessRights.Details(UID, (int)AccessTypes.MostSalableItemsReport).Read) { cboReportType.Items.Add(new ListItem(ReportTypes.ProductHistoryMostSaleable, ReportTypes.ProductHistoryMostSaleable)); } if (clsAccessRights.Details(UID, (int)AccessTypes.LeastSalableItemsReport).Read) { cboReportType.Items.Add(new ListItem(ReportTypes.ProductHistoryLeastSaleable, ReportTypes.ProductHistoryLeastSaleable)); } clsAccessRights.CommitAndDispose(); cboReportType.SelectedIndex = 0; try { if (Common.Decrypt(Request.QueryString["task"].ToString().ToLower(), Session.SessionID) == "producthistory") { cboReportType.SelectedIndex = cboReportType.Items.IndexOf(cboReportType.Items.FindByValue(ReportTypes.ProductHistoryMovement)); cboReportType_SelectedIndexChanged(null, null); } } catch {} try { if (Common.Decrypt(Request.QueryString["task"].ToString().ToLower(), Session.SessionID) == "pricehistory") { cboReportType.SelectedIndex = cboReportType.Items.IndexOf(cboReportType.Items.FindByValue(ReportTypes.ProductHistoryPrice)); cboReportType_SelectedIndexChanged(null, null); } } catch { } txtStartDate.Text = DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd"); txtEndDate.Text = DateTime.Now.ToString("yyyy-MM-dd"); string strProductCode = string.Empty; try { try { if (Request.QueryString["sender"].ToString().ToLower() == "direct" && Request.QueryString["productcode"].ToString() != null) { strProductCode = Server.UrlDecode(Request.QueryString["productcode"].ToString()); } } catch { strProductCode = Server.UrlDecode(Common.Decrypt(Request.QueryString["productcode"].ToString(), Session.SessionID)); } lblReferrer.ToolTip = strProductCode; } catch { strProductCode = lblReferrer.ToolTip; } txtProductCode.Text = strProductCode; Data.Products clsProduct = new Data.Products(); cboProductCode.DataTextField = "ProductCode"; cboProductCode.DataValueField = "ProductID"; cboProductCode.DataSource = clsProduct.ProductIDandCodeDataTable(SearchKey: txtProductCode.Text, limit: 100); cboProductCode.DataBind(); Branch clsBranch = new Branch(clsProduct.Connection, clsProduct.Transaction); cboBranch.DataTextField = "BranchCode"; cboBranch.DataValueField = "BranchID"; cboBranch.DataSource = clsBranch.ListAsDataTable().DefaultView; cboBranch.DataBind(); cboBranch.Items.Insert(0, new ListItem(Constants.ALL, Constants.ZERO_STRING)); cboBranch.SelectedIndex = 0; clsProduct.CommitAndDispose(); if (cboProductCode.Items.Count == 0) { cboProductCode.Items.Add(new ListItem("No product", "0")); } cboProductCode.SelectedIndex = 0; cboProductCode_SelectedIndexChanged(null, null); try { if (strProductCode != string.Empty && cboProductCode.SelectedItem.Value != "0") { if (!string.IsNullOrEmpty(Request.QueryString["reptype"])) { GeneratePDF(); } else { GenerateHTML(); } } } catch { } }
private void PriceInquiryWnd_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { switch (e.KeyData) { case Keys.Escape: dialog = DialogResult.Cancel; this.Hide(); break; case Keys.Enter: if (txtBarCode.Text.Trim() != string.Empty) { ClearProduct(); Data.Products clsProduct = new Data.Products(); Data.ProductDetails clsProductDetails = clsProduct.Details(TerminalDetails.BranchID, txtBarCode.Text.Trim()); if (clsProductDetails.ProductID == 0) { string strContactCardNo = txtBarCode.Text.Trim(); Data.Contacts clsContact = new Data.Contacts(clsProduct.Connection, clsProduct.Transaction); Data.ContactDetails clsContactDetails = clsContact.DetailsByRewardCardNo(strContactCardNo); if (clsContactDetails.ContactID == 0) { clsContactDetails = clsContact.DetailsByCreditCardNo(strContactCardNo); if (clsContactDetails.ContactID == 0) { strContactCardNo = strContactCardNo.Remove(strContactCardNo.Length - 1); clsContactDetails = clsContact.DetailsByRewardCardNo(strContactCardNo); if (clsContactDetails.ContactID == 0) { clsContactDetails = clsContact.DetailsByCreditCardNo(strContactCardNo); if (clsContactDetails.ContactID == 0) { ClearProduct(); } else { decimal decAvailableCreditLimit = clsContactDetails.CreditLimit - clsContactDetails.Credit; lblProductDescription.Text = clsContactDetails.ContactName + " - " + clsContactDetails.CreditDetails.CreditCardNo; lblPrice.Text = decAvailableCreditLimit.ToString("#,##0.#0"); lblPriceLabel.Text = "AVAILABLE CREDITS:"; if (clsContactDetails.CreditDetails.CreditCardStatus == CreditCardStatus.Expired || clsContactDetails.CreditDetails.CreditCardStatus == CreditCardStatus.Lost) { lblProductDescription.Text += "(" + clsContactDetails.CreditDetails.CreditCardStatus.ToString("G").ToLower() + ")"; } else { lblProductDescription.Text += "(active)"; } } } else { lblProductDescription.Text = clsContactDetails.ContactName + " - " + clsContactDetails.RewardDetails.RewardCardNo; lblPrice.Text = clsContactDetails.RewardDetails.RewardPoints.ToString("#,##0.#0"); lblPriceLabel.Text = "AVAILABLE POINTS:"; if (clsContactDetails.RewardDetails.RewardCardStatus == RewardCardStatus.Expired || clsContactDetails.RewardDetails.RewardCardStatus == RewardCardStatus.Lost) { lblProductDescription.Text += "(" + clsContactDetails.RewardDetails.RewardCardStatus.ToString("G").ToLower() + ")"; } else { lblProductDescription.Text += "(active)"; } } } else { decimal decAvailableCreditLimit = clsContactDetails.CreditLimit - clsContactDetails.Credit; lblProductDescription.Text = clsContactDetails.ContactName + " - " + clsContactDetails.CreditDetails.CreditCardNo; lblPrice.Text = decAvailableCreditLimit.ToString("#,##0.#0"); lblPriceLabel.Text = "AVAILABLE CREDITS:"; if (clsContactDetails.CreditDetails.CreditCardStatus == CreditCardStatus.Expired || clsContactDetails.CreditDetails.CreditCardStatus == CreditCardStatus.Lost) { lblProductDescription.Text += "(" + clsContactDetails.CreditDetails.CreditCardStatus.ToString("G").ToLower() + ")"; } else { lblProductDescription.Text += "(active)"; } } } else { lblProductDescription.Text = clsContactDetails.ContactName + " - " + clsContactDetails.RewardDetails.RewardCardNo; lblPrice.Text = clsContactDetails.RewardDetails.RewardPoints.ToString("#,##0.#0"); lblPriceLabel.Text = "AVAILABLE POINTS:"; if (clsContactDetails.RewardDetails.RewardCardStatus == RewardCardStatus.Expired || clsContactDetails.RewardDetails.RewardCardStatus == RewardCardStatus.Lost) { lblProductDescription.Text += "(" + clsContactDetails.RewardDetails.RewardCardStatus.ToString("G").ToLower() + ")"; } else { lblProductDescription.Text += "(active)"; } } } else { lblProductDescription.Text = clsProductDetails.ProductDesc; lblPrice.Text = clsProductDetails.Price.ToString("#,##0.#0"); lblPriceLabel.Text = "PRICE:"; } clsProduct.CommitAndDispose(); txtBarCode.Text = ""; } txtBarCode.Focus(); txtBarCode.SelectAll(); break; } }
static void Main(string[] args) { try { WriteProcessToMonitor("Starting RetailPlus monitoring tool..."); // check if it's already running if (System.Diagnostics.Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)).Count() > 1) { WriteProcessToMonitor(" already running. not ok"); return; } WriteProcessToMonitor(" ok"); Data.Database clsDatabase = new Data.Database(); back: WriteProcessToMonitor("Checking connections to server."); if (IPAddress.IsOpen(AceSoft.RetailPlus.DBConnection.ServerIP(), DBConnection.DBPort()) == false) { WriteProcessToMonitor(" cannot connect to server please check."); goto exit; } WriteProcessToMonitor(" ok"); WriteProcessToMonitor("Checking connections to database."); clsDatabase.GetConnection(username: "******", password: "******"); try { bool boIsDBAlive = clsDatabase.IsAlive(); WriteProcessToMonitor(" connected to '" + clsDatabase.Connection.ConnectionString.Split(';')[0].ToString().Replace("Data Source=", "") + "'"); } catch (Exception ex) { WriteProcessToMonitor(" ERROR connecting to database. Exception: " + ex.ToString()); } #region Timed-Out Process WriteProcessToMonitor("Checking timed-out process."); System.Data.DataTable dtProcessList = clsDatabase.getProcessList(); foreach (DataRow dr in dtProcessList.Rows) { int iID = int.Parse(dr["ID"].ToString()); string strHost = dr["Host"].ToString(); string strDB = dr["db"].ToString(); int iTime = int.Parse(dr["Time"].ToString()); string strInfo = dr["Info"].ToString(); if (strInfo.ToUpper() != "SHOW PROCESSLIST" || strDB == "pos") { WriteProcessToMonitor(" id:" + iID.ToString() + " host:" + strHost + " Time:" + iTime.ToString() + " Info:" + strInfo); if (iTime > Constants.C_DEFAULT_MYSQL_PROCESS_TIMEOUT && strDB == "pos") { WriteProcessToMonitor(" status not ok... killing process id: " + iID.ToString()); clsDatabase.killProcess(iID); WriteProcessToMonitor(" done."); } else if (iTime > 16 && string.IsNullOrEmpty(strInfo)) { WriteProcessToMonitor(" status idle... killing process id: " + iID.ToString()); clsDatabase.killProcess(iID); WriteProcessToMonitor(" done."); } else if (strInfo.Contains("INSERT INTO tblTransactions") && iTime >= 8) { WriteProcessToMonitor(" status not ok... flushing table tblTransactions...process id: " + iID.ToString()); clsDatabase.FlushTable("tblTransactions"); WriteProcessToMonitor(" done."); } else if (strInfo.Contains("UPDATE tblTerminalReport") && iTime >= 8) { WriteProcessToMonitor(" status not ok... flushing table tblTerminalReport...process id: " + iID.ToString()); clsDatabase.FlushTable("tblTerminalReport"); WriteProcessToMonitor(" done."); } else { WriteProcessToMonitor(" status ok"); } } } clsDatabase.CommitAndDispose(); // audit //clsDatabase = new Data.Database(clsDatabase.Connection, clsDatabase.Transaction); clsDatabase.GetConnection(username: "******", password: "******"); try { bool boIsDBAlive = clsDatabase.IsAlive(); WriteProcessToMonitor(" connected to '" + clsDatabase.Connection.ConnectionString.Split(';')[0].ToString().Replace("Data Source=", "") + "'"); } catch (Exception ex) { WriteProcessToMonitor(" ERROR connecting to database. Exception: " + ex.ToString()); } WriteProcessToMonitor("Checking Audit timed-out process."); dtProcessList = clsDatabase.getProcessList(); foreach (DataRow dr in dtProcessList.Rows) { int iID = int.Parse(dr["ID"].ToString()); string strHost = dr["Host"].ToString(); string strDB = dr["db"].ToString(); int iTime = int.Parse(dr["Time"].ToString()); string strInfo = dr["Info"].ToString(); if (strInfo.ToUpper() != "SHOW PROCESSLIST" || strDB == "pos") { WriteProcessToMonitor(" audit id:" + iID.ToString() + " host:" + strHost + " Time:" + iTime.ToString() + " Info:" + strInfo); if (iTime > Constants.C_DEFAULT_MYSQL_PROCESS_TIMEOUT && strDB == "pos") { WriteProcessToMonitor(" status not ok... killing process id: " + iID.ToString()); clsDatabase.killProcess(iID); WriteProcessToMonitor(" done."); } else { WriteProcessToMonitor(" status ok"); } } } clsDatabase.CommitAndDispose(); WriteProcessToMonitor(" done checking..."); #endregion string strSyncFunction = ""; try { strSyncFunction = System.Configuration.ConfigurationManager.AppSettings["SyncFunction"].ToString(); } catch { } if (strSyncFunction.ToLower().Trim() == "export") { #region Export Products //clsDatabase = new Data.Database(clsDatabase.Connection, clsDatabase.Transaction); clsDatabase.GetConnection(username: "******", password: "******"); Data.SysConfig clsSysConfig = new Data.SysConfig(clsDatabase.Connection, clsDatabase.Transaction); DateTime dteLastSyncDateTime = clsSysConfig.get_ProdLastSyncDateTime(); DateTime dteLastSyncDateTimeTo = dteLastSyncDateTime.AddMinutes(clsSysConfig.get_ProdSyncInterval()); if (dteLastSyncDateTimeTo <= DateTime.Now) { Data.DBSync clsDBSync = new Data.DBSync(clsDatabase.Connection, clsDatabase.Transaction); System.Data.DataTable stSyncItems = clsDBSync.ListAsDataTable("tblProducts", dteLastSyncDateTime, dteLastSyncDateTimeTo); if (stSyncItems.Rows.Count > 0) { string xmlFileName = @"C:\RetailPlus\RetailPlus\RetailPlus\temp\uploaded\prodsync\prod_" + dteLastSyncDateTime.ToString("yyyyMMddHHmmss") + ".xml"; if (!System.IO.File.Exists(xmlFileName)) { XmlTextWriter writer = new XmlTextWriter(xmlFileName, System.Text.Encoding.UTF8); writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); writer.WriteComment("This file represents the updated products."); writer.WriteStartElement("Header"); writer.WriteAttributeString("TableName", stSyncItems.TableName); writer.WriteAttributeString("LastSyncDateTime", dteLastSyncDateTime.ToString("yyyy-MM-dd HH:mm:ss")); writer.WriteAttributeString("LastSyncDateTimeTo", dteLastSyncDateTimeTo.ToString("yyyy-MM-dd HH:mm:ss")); foreach (DataRow dr in stSyncItems.Rows) { writer.WriteStartElement("Details"); foreach (DataColumn dc in dr.Table.Columns) { if (dc.DataType == System.Type.GetType("System.DateTime")) { writer.WriteAttributeString(dc.ColumnName, DateTime.Parse(dr[dc.ColumnName].ToString()).ToString("yyyy-MM-dd HH:mm:ss")); } else { writer.WriteAttributeString(dc.ColumnName, dr[dc.ColumnName].ToString()); } } writer.WriteEndElement(); } writer.WriteEndElement(); //Write the XML to file and close the writer writer.Flush(); writer.Close(); } } clsSysConfig = new Data.SysConfig(clsDatabase.Connection, clsDatabase.Transaction); clsSysConfig.Save(new Data.SysConfigDetails() { ConfigName = "ProdLastSyncDateTime", ConfigValue = dteLastSyncDateTimeTo.ToString("yyyy-MM-dd HH:mm:ss"), Category = "Sync" }); } clsDatabase.CommitAndDispose(); #endregion } else if (strSyncFunction.ToLower().Trim() == "import") { #region Import Products XmlTextReader xmlReader = new XmlTextReader(@"C:\RetailPlus\RetailPlus\RetailPlus\temp\uploaded\prodsync\prod_20150629183000.xml"); xmlReader.WhitespaceHandling = WhitespaceHandling.None; ////clsDatabase = new Data.Database(clsDatabase.Connection, clsDatabase.Transaction); clsDatabase.GetConnection(DBName: "poseamirror", username: "******", password: "******"); clsDatabase.SetForeignKey(false); Data.SysConfig clsSysConfig = new Data.SysConfig(clsDatabase.Connection, clsDatabase.Transaction); DateTime dteLastSyncDateTime = clsSysConfig.get_ProdLastSyncDateTime(); DateTime dteLastSyncDateTimeTo = dteLastSyncDateTime.AddMinutes(clsSysConfig.get_ProdSyncInterval()); Data.Products clsProducts = new Data.Products(clsDatabase.Connection, clsDatabase.Transaction); Data.ProductDetails clsProductDetails = new Data.ProductDetails(); string strTableName = ""; DateTime dteXmlLastSyncDateTime = Constants.C_DATE_MIN_VALUE; DateTime dteXmlLastSyncDateTimeTo = Constants.C_DATE_MIN_VALUE; while (xmlReader.Read()) { switch (xmlReader.NodeType) { case XmlNodeType.Element: if (xmlReader.Name == "Header") { strTableName = xmlReader.GetAttribute("TableName").ToString(); dteXmlLastSyncDateTime = DateTime.TryParse(xmlReader.GetAttribute("LastSyncDateTime").ToString(), out dteXmlLastSyncDateTime) ? dteXmlLastSyncDateTime : Constants.C_DATE_MIN_VALUE; dteXmlLastSyncDateTimeTo = DateTime.TryParse(xmlReader.GetAttribute("LastSyncDateTimeTo").ToString(), out dteXmlLastSyncDateTimeTo) ? dteXmlLastSyncDateTimeTo : Constants.C_DATE_MIN_VALUE; if (dteLastSyncDateTime >= dteXmlLastSyncDateTime) { break; } } else if (strTableName == "tblProducts" && xmlReader.Name == "Details") { clsProductDetails = Data.DBSync.setSyncProductDetails(xmlReader); clsProducts.Save(clsProductDetails); } break; } } if (dteLastSyncDateTime < dteXmlLastSyncDateTime) { clsSysConfig = new Data.SysConfig(clsDatabase.Connection, clsDatabase.Transaction); clsSysConfig.Save(new Data.SysConfigDetails() { ConfigName = "ProdLastSyncDateTime", ConfigValue = dteXmlLastSyncDateTimeTo.ToString("yyyy-MM-dd HH:mm:ss"), Category = "Sync" }); } clsDatabase.SetForeignKey(true); clsDatabase.CommitAndDispose(); #endregion } WriteProcessToMonitor("Waiting for next process..."); System.Threading.Thread.Sleep(20000); goto back; exit: WriteProcessToMonitor("Sytem terminated."); } catch (Exception ex) { WriteProcessToMonitor("PLEASE CALL RETAILPLUS IMMEDIATELY... error:" + ex.ToString()); } }