Esempio n. 1
0
        private bool AddItemUsingBarcode(string aBarcode)
        {
            try
            {
                if (!ItemsMgmt.IsItemTouchScreen(aBarcode))
                {
                    DataTable aItemTable = ItemsMgmt.SelectItemByBarCode(aBarcode);
                    if (aItemTable.Rows.Count == 1)
                    {
                        TeldgView.ClearSelection();
                        int RowNum = TeldgView.Rows.Add();
                        TeldgView.Rows[RowNum].Cells["Barcode"].Value      = aItemTable.Rows[0]["Barcode"].ToString();
                        TeldgView.Rows[RowNum].Cells["Description"].Value  = aItemTable.Rows[0]["Description"].ToString();
                        TeldgView.Rows[RowNum].Cells["PricePerUnit"].Value = aItemTable.Rows[0]["SellPrice"].ToString();
                        TeldgView.Rows[RowNum].Cells["AvalQty"].Value      = aItemTable.Rows[0]["Qty"].ToString();
                        TeldgView.Rows[RowNum].Selected = true;
                        BarcodeTxtBox.Text = string.Empty;
                        ItemsMgmt.MakeItemTouchScreen(aBarcode, true);
                        // MessageBox.Show(MsgTxt.UpdateSuccessfully, MsgTxt.UpdateSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return(true);
                    }
                    else
                    {
                        MessageBox.Show(MsgTxt.ItemNotFoundTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        BarcodeTxtBox.Text = string.Empty;
                        return(false);
                    }
                }
                else
                {
                    MessageBox.Show(MsgTxt.AlreadyUsedTxt, MsgTxt.InformationCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [AddItemUsingBarcode] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                return(false);

                throw;
            }
        }
Esempio n. 2
0
        private void WithoutBarcodeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (IsUpdating)
                {
                    return;
                }
                if (WithoutBarcodeComboBox.SelectedValue != null)
                {
                    aItemData = ItemsMgmt.SelectItemByBarCode(WithoutBarcodeComboBox.SelectedValue.ToString());
                }
                else
                {
                    return;
                }
                if (aItemData.Rows.Count > 0)
                {
                    IsUpdating = true;
                    UpdateItemBtn.Show();
                    TypeComboBox.Text     = ItemTypeMgmt.SelectItemTypeByID(int.Parse(aItemData.Rows[0]["Type"].ToString()));
                    CategoryComboBox.Text = ItemCategoryMgmt.SelectItemCategoryByID(int.Parse(aItemData.Rows[0]["Category"].ToString()));
                    VendorComboBox.Text   = VendorsMgmt.SelectVendorByID(int.Parse(aItemData.Rows[0]["Vendor"].ToString()));
                    TaxLevelComboBox.Text = ItemTaxLevelMgmt.SelectItemTaxByID(int.Parse(aItemData.Rows[0]["TaxLevel"].ToString()));

                    BarcodeTxtBox.Text      = aItemData.Rows[0]["Barcode"].ToString();
                    DescriptionTxtBox.Text  = aItemData.Rows[0]["Description"].ToString();
                    QtyTxtBox.Text          = aItemData.Rows[0]["Qty"].ToString();
                    RenderPointTxtBox.Text  = aItemData.Rows[0]["RenderPoint"].ToString();
                    DateAddedTxtBox.Text    = aItemData.Rows[0]["EntryDate"].ToString();
                    SellPriceTxtBox.Text    = aItemData.Rows[0]["SellPrice"].ToString();
                    AvgCostTxtBox.Text      = aItemData.Rows[0]["AvgUnitCost"].ToString();
                    AvailableQtyTxtBox.Text = aItemData.Rows[0]["OnHandQty"].ToString(); /*@SMS V01O changed*/
                    Pricing.Controls.Clear();
                    //ADDING PRICE LEVELS
                    int ItemID = int.Parse(aItemData.Rows[0]["ID"].ToString());
                    aPriceLevelsTable = PriceLevelsMgmt.SelectAll();

                    if (aPriceLevelsTable.Rows.Count > 0)
                    {
                        foreach (DataRow r in aPriceLevelsTable.Rows)
                        {
                            if (r["Name"].ToString() != "Standard")
                            {
                                Label aLabel = new Label();
                                aLabel.Text      = r["Name"].ToString();
                                aLabel.ForeColor = Color.Black;
                                TextBox   aTextBox           = new TextBox();
                                DataTable aSpecialPriceTable = SpecialPricesMgmt.SelectSpecialPricebyItemIDandPriceLevelID(ItemID, int.Parse(r["ID"].ToString()));
                                if (aSpecialPriceTable.Rows.Count > 0)
                                {
                                    aTextBox.Text = aSpecialPriceTable.Rows[0]["Price"].ToString();
                                }
                                else
                                {
                                    aTextBox.Text = SellPriceTxtBox.Text;
                                }

                                aTextBox.Name         = r["Name"].ToString();
                                aTextBox.TextChanged += new EventHandler(Calcium_RMS.Validators.TextBoxDoubleInputChange);
                                Pricing.Controls.Add(aLabel);
                                Pricing.Controls.Add(aTextBox);
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show(MsgTxt.NotUsedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                TaxEnclodedChkBox.Checked = false;
                UpdateMargin();
                IsUpdating = false;
            }
            catch (Exception ex)
            {
                IsUpdating = false;
                MessageBox.Show(MsgTxt.UnexpectedError + "\nException: IN[WithoutBarcodeComboBox_SelectedIndexChanged] \n" + ex.ToString(), MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
Esempio n. 3
0
        private void Add1000Sale_Click(object sender, EventArgs e)
        {
            int      cnt        = 1;
            DateTime date       = DateTime.Now;
            var      randAmount = new Random();

            int userId = int.Parse(UsersMgmt.SelectAllUsers().Rows[0]["ID"].ToString());

            while (cnt++ < NumberOfBills)
            {
                try
                {
                    int numofDetailed = randAmount.Next(1, 20);
                    var aBillGeneral  = new BillGeneral();
                    aBillGeneral.Bill_General_AccountID       = 1;
                    aBillGeneral.Bill_General_CashIn          = 100;
                    aBillGeneral.Bill_General_Currency        = "JOD";
                    aBillGeneral.Bill_General_CurrencyID      = 1;
                    aBillGeneral.Bill_General_CustomerID      = 1;
                    aBillGeneral.Bill_General_Date            = date.Subtract(TimeSpan.FromDays(randAmount.Next(1, 2000))).ToShortDateString();
                    aBillGeneral.Bill_General_DiscountPerc    = 0;
                    aBillGeneral.Bill_General_IsCashCredit    = 0;
                    aBillGeneral.Bill_General_NetAmount       = 100;
                    aBillGeneral.Bill_General_Number          = BillGeneralMgmt.NextBillNumber();
                    aBillGeneral.Bill_General_PaymentMethodID = 1;
                    aBillGeneral.Bill_General_PriceLevel      = 1;
                    aBillGeneral.Bill_General_SalesDiscount   = 0;
                    aBillGeneral.Bill_General_SubTotal        = 100;
                    aBillGeneral.Bill_General_TellerID        = userId;
                    aBillGeneral.Bill_General_Time            =
                        DateTime.Now.ToShortTimeString();
                    aBillGeneral.Bill_General_TotalCost      = randAmount.Next(50, 99);
                    aBillGeneral.Bill_General_TotalDiscount  = 0;
                    aBillGeneral.Bill_General_TotalItems     = numofDetailed;
                    aBillGeneral.Bill_General_TotalPrice     = 100;
                    aBillGeneral.Bill_General_TotalTax       = 16;
                    aBillGeneral.CustomerAccountAmountOld    = 0;
                    aBillGeneral.Bill_General_Comments       = "Test Sale";
                    aBillGeneral.Bill_General_CreditCardInfo = "NotCredit";

                    Random aRandom = new Random();

                    if (BillGeneralMgmt.InsertBill(aBillGeneral))
                    {
                        while (numofDetailed > 0)
                        {
                            BillDetailed aBillDetailed = new BillDetailed();
                            string       aBarcode      = "Test Item " + aRandom.Next(1, (int)NumberOfItems);
                            DataTable    aItemRow      = ItemsMgmt.SelectItemByBarCode(aBarcode);
                            if (aItemRow.Rows.Count != 0)
                            {
                                aBillDetailed.Bill_Detailed_ItemDescription = aItemRow.Rows[0]["Description"].ToString();
                                aBillDetailed.Bill_Detailed_ItemID          = int.Parse(aItemRow.Rows[0]["ID"].ToString());
                                aBillDetailed.Bill_Detailed_Number          = aBillGeneral.Bill_General_Number;
                                aBillDetailed.Bill_Detailed_OldAvaQty       = double.Parse(aItemRow.Rows[0]["Qty"].ToString());
                                aBillDetailed.Bill_Detailed_OldAvgUnitCost  =
                                    double.Parse(aItemRow.Rows[0]["AvgUnitCost"].ToString());
                                aBillDetailed.Bill_Detailed_Qty       = numofDetailed;
                                aBillDetailed.Bill_Detailed_SellPrice = double.Parse(aItemRow.Rows[0]["SellPrice"].ToString());

                                aBillDetailed.Bill_Detailed_TotalPerUnit = aBillDetailed.Bill_Detailed_Qty *
                                                                           aBillDetailed.Bill_Detailed_SellPrice;

                                BillDetailedMgmt.InsertItem(aBillDetailed);
                            }
                            numofDetailed--;
                        }
                    }
                    if (cnt % 100 == 0)
                    {
                        label1.Text = $"Adding Bill {cnt}/{NumberOfBills} ... ({(cnt / NumberOfBills) * 100 })%";
                        Application.DoEvents();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"Error in {cnt} \n {ex}");
                }
            }
        }
Esempio n. 4
0
        private void Add1000PurchaseVoucherBtn_Click(object sender, EventArgs e)
        {
            Random randAmount = new Random();
            int    cnt        = 1;
            var    Vendors    = VendorsMgmt.SelectAllVendors();
            int    userId     = int.Parse(UsersMgmt.SelectAllUsers().Rows[0]["ID"].ToString());

            while (cnt++ < NumberOfPurchases)
            {
                try
                {
                    PurchaseVoucherGeneral aPurchaseGeneral = new PurchaseVoucherGeneral();
                    aPurchaseGeneral.AccountID              = 1;
                    aPurchaseGeneral.Comments               = "";
                    aPurchaseGeneral.CurrencyID             = 1;
                    aPurchaseGeneral.Date                   = DateTime.Now.Subtract(TimeSpan.FromDays(randAmount.Next(1, 2000))).ToShortDateString();
                    aPurchaseGeneral.DiscountPerc           = 0;
                    aPurchaseGeneral.Fees                   = 10;
                    aPurchaseGeneral.IsCashCredit           = 0;
                    aPurchaseGeneral.IsChecked              = 0;
                    aPurchaseGeneral.IsRevised              = 0;
                    aPurchaseGeneral.PaymentMethodID        = 1;
                    aPurchaseGeneral.Subtotal               = 100;
                    aPurchaseGeneral.TellerID               = userId;
                    aPurchaseGeneral.Time                   = DateTime.Now.ToShortTimeString();
                    aPurchaseGeneral.TotalCost              = 90;
                    aPurchaseGeneral.TotalDiscount          = 0;
                    aPurchaseGeneral.TotalFreeItemsQty      = 0;
                    aPurchaseGeneral.TotalItemsDiscount     = 0;
                    aPurchaseGeneral.TotalTax               = 10;
                    aPurchaseGeneral.VendorAccountAmountOld = 0;
                    aPurchaseGeneral.VendorID               =
                        int.Parse(Vendors.Rows[(int)NumberOfPurchases % Vendors.Rows.Count]["ID"].ToString());
                    aPurchaseGeneral.VoucherNumber  = PurchaseVoucherGeneralMgmt.NextVoucherNumber();
                    aPurchaseGeneral.CreditCardInfo = "";


                    int NumofDetailed = randAmount.Next(1, 20);
                    if (PurchaseVoucherGeneralMgmt.AddVoucher(aPurchaseGeneral))
                    {
                        while (NumofDetailed > 0)
                        {
                            PurchaseVoucherDetailed aPurchaseDetailed = new PurchaseVoucherDetailed();
                            string    aBarcode = "Test Item " + randAmount.Next(1, (int)NumberOfItems).ToString();
                            DataTable aItemRow = ItemsMgmt.SelectItemByBarCode(aBarcode);
                            if (aItemRow.Rows.Count != 0)
                            {
                                aPurchaseDetailed.Purchase_Voucher_Detailed_ItemID =
                                    int.Parse(aItemRow.Rows[0]["ID"].ToString());
                                aPurchaseDetailed.Purchase_Voucher_Detailed_VoucherNumber =
                                    aPurchaseGeneral.VoucherNumber;
                                aPurchaseDetailed.Purchase_Voucher_Detailed_IsRevised = 0;
                                aPurchaseDetailed.Purchase_Voucher_Detailed_ItemCost  =
                                    double.Parse(aItemRow.Rows[0]["AvgUnitCost"].ToString());
                                aPurchaseDetailed.Purchase_Voucher_Detailed_OldAvaQty =
                                    double.Parse(aItemRow.Rows[0]["Qty"].ToString());
                                aPurchaseDetailed.Purchase_Voucher_Detailed_Qty      = NumofDetailed;
                                aPurchaseDetailed.Purchase_Voucher_Detailed_Discount = 0;
                                // = double.Parse(aItemRow.Rows[0]["SellPrice"].ToString());
                                aPurchaseDetailed.Purchase_Voucher_Detailed_FreeItemsQty = 0;
                                // aBillDetailed.Bill_Detailed_TotalPerUnit = aBillDetailed.Bill_Detailed_Qty * aBillDetailed.Bill_Detailed_SellPrice;
                                PurchaseVoucherDetailedMgmt.AddItem(aPurchaseDetailed);
                            }
                            NumofDetailed--;
                        }
                    }
                    if (cnt % 100 == 0)
                    {
                        label1.Text = $"Adding Purchase Order {cnt}/{NumberOfPurchases} ... ({(cnt / NumberOfPurchases) * 100 })%";
                        Application.DoEvents();
                    }
                }
                catch (Exception ex) { MessageBox.Show($"Error in {cnt} \n {ex}"); }
            }
        }
Esempio n. 5
0
        //[BARCODE FUNCTIONS]
        /// <summary>
        /// ADD ITEM USING BARCODE
        /// this is one of the major function which is used to add item using its barcode to the
        /// TELDGVIEW with the following columns
        /// [Barcode] [Qty] [Description] [PricePerUnit] [Tax]  [PriceTotal] [AvalQty]
        /// And this function loocks a bool called IsAddingItem
        /// Function Version 1.00
        /// Last Edited By Sari Sultan On October,7,2013
        /// changed sell price to AvgUnitCost TeldgView.Rows[RowNum].Cells["PricePerUnit"].Value = aItemTable.Rows[0]["AvgUnitCost"].ToString();
        /// </summary>
        /// <param name="aBarcode"></param>
        /// <param name="IsFromGun"></param>
        private void AddItemUsingBarcode(string aBarcode, bool IsFromGun = false)
        {
            try
            {
                double    TotwgtPrice = 0;
                bool      dowgt       = false;
                DataTable aItemTable  = null;

                if (aThereIsWeigth && IsFromGun)
                {
                    if (aBarcode.Length > BarcodeLength)
                    {
                        aBarcode = aBarcode.Substring(0, BarcodeLength);
                        if (ItemsMgmt.IsItemWgtExist(aBarcode))
                        {
                            aItemTable = ItemsMgmt.SelectItemByBarCode(aBarcode);
                            string tempcoststr = aBarcode.Substring(BarcodeLength, aBarcode.Length - BarcodeLength);
                            if (double.TryParse(tempcoststr, out TotwgtPrice))
                            {
                                dowgt = true;
                            }
                        }
                        else
                        {
                            aItemTable = ItemsMgmt.SelectItemByBarCode(aBarcode);
                        }
                    }
                    else
                    {
                        aItemTable = ItemsMgmt.SelectItemByBarCode(aBarcode);
                    }
                }
                else
                {
                    aItemTable = ItemsMgmt.SelectItemByBarCode(aBarcode);
                }

                if (aItemTable != null)
                {
                    if (aItemTable.Rows.Count == 1)
                    {
                        double TaxPer = double.Parse(ItemTaxLevelMgmt.SelectItemTaxByID(int.Parse(aItemTable.Rows[0]["TaxLevel"].ToString())));
                        foreach (DataGridViewRow r in TeldgView.Rows)
                        {
                            if (TeldgView.Rows[r.Index].Cells["Barcode"].Value.ToString() == aItemTable.Rows[0]["Barcode"].ToString())
                            {
                                TeldgView.ClearSelection();
                                if (dowgt)
                                {
                                    TeldgView.Rows[r.Index].Cells["Qty"].Value = Convert.ToDouble(TeldgView.Rows[r.Index].Cells["Qty"].Value.ToString()) + Math.Round(TotwgtPrice / DivisionScale / (double.Parse(aItemTable.Rows[0]["SellPrice"].ToString()) * (1 + TaxPer / 100)), 3);
                                }
                                else
                                {
                                    TeldgView.Rows[r.Index].Cells["Qty"].Value = Convert.ToDouble(TeldgView.Rows[r.Index].Cells["Qty"].Value.ToString()) + 1;
                                }
                                TeldgView.Rows[r.Index].Cells["PriceTotal"].Value = Math.Round(Convert.ToDouble(TeldgView.Rows[r.Index].Cells["Qty"].Value.ToString()) * Convert.ToDouble(TeldgView.Rows[r.Index].Cells["PricePerUnit"].Value.ToString()), 3);
                                TeldgView.Rows[r.Index].Selected = true;
                                return;
                            }
                        }
                        IsAddingItem = true;
                        TeldgView.ClearSelection();
                        int RowNum = TeldgView.Rows.Add();
                        TeldgView.Rows[RowNum].Cells["Barcode"].Value      = aItemTable.Rows[0]["Barcode"].ToString();
                        TeldgView.Rows[RowNum].Cells["Description"].Value  = aItemTable.Rows[0]["Description"].ToString();
                        TeldgView.Rows[RowNum].Cells["PricePerUnit"].Value = aItemTable.Rows[0]["AvgUnitCost"].ToString();
                        if (dowgt)
                        {
                            TeldgView.Rows[RowNum].Cells["Qty"].Value = Math.Round((TotwgtPrice / DivisionScale) / (double.Parse(aItemTable.Rows[0]["SellPrice"].ToString()) * (1 + TaxPer / 100)), 3);
                        }
                        else
                        {
                            TeldgView.Rows[RowNum].Cells["Qty"].Value = 1;
                        }
                        TeldgView.Rows[RowNum].Cells["PriceTotal"].Value = Math.Round(double.Parse(TeldgView.Rows[RowNum].Cells["PricePerUnit"].Value.ToString()) * Convert.ToDouble(TeldgView.Rows[RowNum].Cells["Qty"].Value.ToString()), 3);
                        TeldgView.Rows[RowNum].Cells["Tax"].Value        = TaxPer;
                        TeldgView.Rows[RowNum].Cells["AvalQty"].Value    = aItemTable.Rows[0]["Qty"].ToString();
                        TeldgView.Rows[RowNum].Selected = true;
                    }
                    else
                    {
                        MessageBox.Show(MsgTxt.ItemNotFoundTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    IsAddingItem = false;
                }
            }
            catch (Exception ex)
            {
                IsAddingItem = false;
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [AddItemUsingBarcode] \n Exception: \n" + ex.ToString(), MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }