예제 #1
0
 private void AddNewPriceLevelBtn_Click(object sender, EventArgs e)
 {
     try
     {
         AddNewPriceLevel aAddNewPriceLevel = new AddNewPriceLevel();
         aAddNewPriceLevel.ShowDialog();
         aPriceLevelsTable = PriceLevelsMgmt.SelectAll();
         Pricing.Controls.Clear();
         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();
                     TextBox aTextBox = new TextBox();
                     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);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(MsgTxt.UnexpectedError + "\nException: IN[AddNewPriceLevelBtn_Click] \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
         this.Close();
     }
 }
예제 #2
0
파일: EditItems.cs 프로젝트: SariSultan/RMS
        private void AddNewPriceLevelBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (aItemData != null)
                {
                    AddNewPriceLevel aAddNewPriceLevel = new AddNewPriceLevel();
                    aAddNewPriceLevel.ShowDialog();

                    aPriceLevelsTable = PriceLevelsMgmt.SelectAll();
                    Pricing.Controls.Clear();
                    if (aPriceLevelsTable.Rows.Count > 0)
                    {
                        int ItemID = int.Parse(aItemData.Rows[0]["ID"].ToString());
                        foreach (DataRow r in aPriceLevelsTable.Rows)
                        {
                            if (r["Name"].ToString() != "Standard")
                            {
                                Label aLabel = new Label();
                                aLabel.Text = r["Name"].ToString();
                                TextBox   aTextBox           = new TextBox();
                                DataTable aSpecialPriceTable = SpecialPricesMgmt.SelectSpecialPricebyItemIDandPriceLevelID(ItemID, int.Parse(r["ID"].ToString()));
                                if (aSpecialPriceTable == null)
                                {
                                    MessageBox.Show("UNEXPECTED ERROR");
                                    this.Close();
                                }
                                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.PleaseSelectTxt + "\n1)" + MsgTxt.ItemTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\nException: IN[AddNewPriceLevelBtn_Click] \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
파일: EditItems.cs 프로젝트: SariSultan/RMS
        private void UpdateItemBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (Validators.TxtBoxNotEmpty(BarcodeTxtBox.Text) || WithoutBarcodeChkBox.Checked)
                {
                    BarcodeTxtBox.BackColor = BarcodeTxtBoxBGColor;
                    double ParsingOutTester = 0;
                    if (Validators.TxtBoxNotEmpty(QtyTxtBox.Text) && double.TryParse(QtyTxtBox.Text, out ParsingOutTester))
                    {
                        QtyTxtBox.BackColor = QtyTxtBoxBGColor;
                        if (Validators.TxtBoxNotEmpty(RenderPointTxtBox.Text) && double.TryParse(RenderPointTxtBox.Text, out ParsingOutTester))
                        {
                            RenderPointTxtBox.BackColor = RenderTxtBoxBGColor;
                            if (Validators.TxtBoxNotEmpty(DescriptionTxtBox.Text))
                            {
                                DescriptionTxtBox.BackColor = DescriptionBGColor;
                                if (Validators.TxtBoxNotEmpty(SellPriceTxtBox.Text) && double.TryParse(SellPriceTxtBox.Text, out ParsingOutTester))
                                {
                                    SellPriceTxtBox.BackColor = SellPriceBGColor;
                                    if (Validators.TxtBoxNotEmpty(AvgCostTxtBox.Text) && double.TryParse(AvgCostTxtBox.Text, out ParsingOutTester))
                                    {
                                        AvgCostTxtBox.BackColor = AvgUnitCostBGColor;

                                        bool IsPriceLevelsEmpty = false;

                                        foreach (var tb in Pricing.Controls.OfType <TextBox>())
                                        {
                                            if (!Validators.TxtBoxNotEmpty(tb.Text) || !double.TryParse(tb.Text, out ParsingOutTester))
                                            {
                                                IsPriceLevelsEmpty = true;
                                                tb.BackColor       = SharedVariables.TxtBoxRequiredColor;
                                            }
                                            else
                                            {
                                                // tb.BackColor = Color.Black;
                                            }
                                        }
                                        if (IsPriceLevelsEmpty)
                                        {
                                            MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.PriceLevelsTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                            return;
                                        }
                                        else
                                        {
                                            bool IsBarcodeUsed = false;
                                            //CHECK IF NEW BARCODE IS  NOT CHECKED
                                            string OldBarcode;
                                            if (!WithoutBarcodeChkBox.Checked)
                                            {
                                                IsBarcodeUsed = ItemsMgmt.IsItemExist(BarcodeTxtBox.Text);
                                                if (ByBarcDescChkBox.Checked)
                                                {
                                                    OldBarcode = BarcodeToEditTxtBox.Text;
                                                }
                                                else
                                                {
                                                    OldBarcode = ItemDescriptionComboBox.SelectedValue.ToString();
                                                }
                                            }
                                            else
                                            {
                                                OldBarcode = WithoutBarcodeComboBox.SelectedValue.ToString();
                                            }
                                            Items aItem = new Items();
                                            aItem.Item_Type      = (int)TypeComboBox.SelectedValue;
                                            aItem.Item_Category  = (int)CategoryComboBox.SelectedValue;
                                            aItem.Vendor         = (int)VendorComboBox.SelectedValue;
                                            aItem.Item_Tax_Level = (int)TaxLevelComboBox.SelectedValue;
                                            if (WithoutBarcodeChkBox.Checked)
                                            {
                                                aItem.Item_Barcode = WithoutBarcodeComboBox.SelectedValue.ToString();
                                            }
                                            else
                                            {
                                                //aItem.IsWithoutBarcode = 0;
                                                aItem.Item_Barcode = BarcodeTxtBox.Text;
                                            }
                                            aItem.Item_ID = ItemsMgmt.SelectItemIDByBarcode(OldBarcode);
                                            if (!IsBarcodeUsed || WithoutBarcodeChkBox.Checked || OldBarcode == aItem.Item_Barcode)
                                            {
                                                aItem.Item_Description = DescriptionTxtBox.Text;
                                                aItem.Avalable_Qty     = double.Parse(QtyTxtBox.Text);
                                                aItem.Render_Point     = double.Parse(RenderPointTxtBox.Text);
                                                // aItem.Entry_Date = DateTime.Now.ToShortDateString();

                                                double aSellPrice = double.Parse(SellPriceTxtBox.Text);
                                                double aUnitCost  = double.Parse(AvgCostTxtBox.Text);
                                                double aTax       = double.Parse(ItemTaxLevelMgmt.SelectItemTaxByID(aItem.Item_Tax_Level));

                                                if (TaxEnclodedChkBox.Checked)
                                                {
                                                    aItem.Sell_Price    = Math.Round(aSellPrice / ((aTax / 100) + 1), 4);
                                                    aItem.Avg_Unit_Cost = Math.Round(aUnitCost / ((aTax / 100) + 1), 4);
                                                }
                                                else
                                                {
                                                    aItem.Sell_Price    = aSellPrice;
                                                    aItem.Avg_Unit_Cost = aUnitCost;
                                                }
                                                ItemsMgmt.UpdateItemByID(aItem);
                                                int ItemID = aItem.Item_ID;
                                                foreach (var tb in Pricing.Controls.OfType <TextBox>())
                                                {
                                                    Nullable <int> PriceLevelID = PriceLevelsMgmt.SelectPriceLevelIDByName(tb.Name);
                                                    if (PriceLevelID != null)
                                                    {
                                                        double atbSellPrice = double.Parse(tb.Text);

                                                        if (TaxEnclodedChkBox.Checked)
                                                        {
                                                            atbSellPrice = Math.Round(atbSellPrice / ((aTax / 100) + 1), 4);
                                                        }

                                                        Nullable <int> IsAddSpecialPriceOK;
                                                        if (SpecialPricesMgmt.IsSpecialPriceExist(ItemID, (int)PriceLevelID) == true)//exist update
                                                        {
                                                            IsAddSpecialPriceOK = SpecialPricesMgmt.UpdatePriceLevel(ItemID, (int)PriceLevelID, atbSellPrice);
                                                        }
                                                        else if (SpecialPricesMgmt.IsSpecialPriceExist(ItemID, (int)PriceLevelID) == false)//not exist create new
                                                        {
                                                            IsAddSpecialPriceOK = SpecialPricesMgmt.AddSpecialPrice(ItemID, (int)PriceLevelID, atbSellPrice);
                                                        } //null database error
                                                        else
                                                        {
                                                            MessageBox.Show(MsgTxt.UnexpectedError + "DataBase: SpecialPricesMgmt.AddSpecialPrice", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                            return;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        MessageBox.Show("UNEXPECTED ERROR !!ITEM ADDED SUCCESSFULY, NOT PRICE LEVELS ADDED " + "\n" + "PLEASE ADD PRICE LEVELS MANUALLY FROM EDIT ITEM PAGE", "PRICE LEVEL ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                        throw new System.ArgumentException("Parameter cannot be null", "original");
                                                    }
                                                }
                                                MessageBox.Show(MsgTxt.UpdateSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            }
                                            else
                                            {
                                                MessageBox.Show(MsgTxt.BarcodeTxt + " " + MsgTxt.AlreadyUsedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                                BarcodeTxtBox.Text = "";
                                            }
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.UnitCostTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        AvgCostTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                                        AvgCostTxtBox.Focus();
                                    }
                                }
                                else
                                {
                                    MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.SellingPriceTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    SellPriceTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                                    SellPriceTxtBox.Focus();
                                }
                            }
                            else
                            {
                                MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.DescriptionTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                DescriptionTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                                DescriptionTxtBox.Focus();
                            }
                        }
                        else
                        {
                            MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.RenderPointTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            RenderPointTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                            RenderPointTxtBox.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.ValidQtyTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        QtyTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                        QtyTxtBox.Focus();
                    }
                }
                else
                {
                    MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.BarcodeTxt + "\n2)" + MsgTxt.IfNotBarChkWithoutBarcodeTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    BarcodeTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                    BarcodeTxtBox.Focus();
                }
            }
            catch (Exception ex)
            {
                IsUpdating = false;
                MessageBox.Show(MsgTxt.UnexpectedError + "\nException: IN[UpdateItemBtn_Click] \n" + ex.ToString(), MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                throw;
            }
        }
예제 #4
0
파일: EditItems.cs 프로젝트: SariSultan/RMS
        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;
            }
        }
예제 #5
0
        private void ListBillsBtn_Click(object sender, EventArgs e)
        {
            try
            {
                int FilterCustomerID = -1;
                if (CustomerNameChkBox.Checked)
                {
                    FilterCustomerID = CustomerMgmt.SelectCustomerIDByPhone1(CustomerPhoneTxtBox.Text);
                    if (FilterCustomerID == -1)
                    {
                        MessageBox.Show("Customer Not Found");
                    }
                }

                aCustomerTable      = CustomerMgmt.SelectAllCustomers();
                aCurrencyTable      = CurrencyMgmt.SelectAll();
                aUsersTable         = UsersMgmt.SelectAllUsers();
                aAccountsTable      = AccountsMgmt.SelectAll();
                aPriceLevelTable    = PriceLevelsMgmt.SelectAll();
                aPaymentMethodTable = PaymentMethodMgmt.SelectAll();

                ListBillsDGView.Rows.Clear();
                int FilterTellerNameID = 0;
                if (TellerNameChkBox.Checked && TellerNameComboBox.SelectedValue != null)
                {
                    FilterTellerNameID = int.Parse(TellerNameComboBox.SelectedValue.ToString());
                }

                string FilterDateFrom = "";
                string FilterDateTo   = "";
                if (DateCheckBox.Checked)
                {
                    FilterDateFrom = DateFrompicker.Value.ToShortDateString();
                    FilterDateTo   = DateToPicker.Value.ToShortDateString();
                }

                bool FilterCheckedBills = CkeckedBillsChkBox.Checked;
                bool FilterIsRevised    = IsRevisedChkBox.Checked;

                bool FilterUnCheckedBills  = UncheckedBillChkBox.Checked;
                bool FilterUnRevisedBills  = UnRevisedChkBox.Checked;
                bool FilterCashCreditBills = CreditBillsChkBox.Checked;

                aBillTable = BillGeneralMgmt.SelectAllBills(FilterTellerNameID, FilterDateFrom, FilterDateTo, FilterCheckedBills, FilterIsRevised, FilterUnCheckedBills, FilterUnRevisedBills, FilterCustomerID, FilterCashCreditBills);
                if (aBillTable == null)
                {
                    MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListBillsBtn_Click:DB-ERROR  aBillTable=null] \n  \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                TotalITemsTxtBox.Text = aBillTable.Rows.Count.ToString();

                if (aBillTable.Rows.Count > 0)
                {
                    RowNum = 0;
                    if (ListBillsDGView.Rows.Count < ItemsPerPage)
                    {
                        //TestingFor Paging
                        pagesnumber = (int)aBillTable.Rows.Count / ItemsPerPage;
                        if ((double.Parse(aBillTable.Rows.Count.ToString()) / ItemsPerPage - int.Parse(aBillTable.Rows.Count.ToString()) / ItemsPerPage) > 0)
                        {
                            pagesnumber++;
                        }
                        foreach (DataRow r in aBillTable.Rows)
                        {
                            if (ListBillsDGView.Rows.Count < ItemsPerPage)
                            {
                                ListBillsDGView.Rows.Add();
                                ListBillsDGView.Rows[RowNum].Cells["Number"].Value     = aBillTable.Rows[RowNum]["Number"].ToString();
                                ListBillsDGView.Rows[RowNum].Cells["Date"].Value       = aBillTable.Rows[RowNum]["Date"].ToString();
                                ListBillsDGView.Rows[RowNum].Cells["BillTime"].Value   = aBillTable.Rows[RowNum]["BillTime"].ToString();
                                ListBillsDGView.Rows[RowNum].Cells["TotalItems"].Value = aBillTable.Rows[RowNum]["TotalItems"].ToString();
                                ListBillsDGView.Rows[RowNum].Cells["TotalTax"].Value   = aBillTable.Rows[RowNum]["TotalTax"].ToString();
                                ListBillsDGView.Rows[RowNum].Cells["TotalPrice"].Value = aBillTable.Rows[RowNum]["TotalPrice"].ToString();
                                for (int i = 0; i < aUsersTable.Rows.Count; i++)
                                {
                                    if (int.Parse(aUsersTable.Rows[i]["ID"].ToString()) == int.Parse(aBillTable.Rows[RowNum]["TellerID"].ToString()))
                                    {
                                        ListBillsDGView.Rows[RowNum].Cells["TellerID"].Value = aUsersTable.Rows[i]["UserName"].ToString();//aBillTable.Rows[RowNum]["TellerID"].ToString();
                                        break;
                                    }
                                }
                                for (int i = 0; i < aCustomerTable.Rows.Count; i++)
                                {
                                    if (int.Parse(aCustomerTable.Rows[i]["ID"].ToString()) == int.Parse(aBillTable.Rows[RowNum]["CustomerID"].ToString()))
                                    {
                                        ListBillsDGView.Rows[RowNum].Cells["CustomerID"].Value = aCustomerTable.Rows[i]["Name"].ToString();
                                        break;
                                    }
                                }
                                for (int i = 0; i < aPriceLevelTable.Rows.Count; i++)
                                {
                                    if (int.Parse(aPriceLevelTable.Rows[i]["ID"].ToString()) == int.Parse(aBillTable.Rows[RowNum]["PriceLevelID"].ToString()))
                                    {
                                        ListBillsDGView.Rows[RowNum].Cells["PriceLevelID"].Value = aPriceLevelTable.Rows[i]["Name"].ToString();
                                        break;
                                    }
                                }

                                for (int i = 0; i < aPaymentMethodTable.Rows.Count; i++)
                                {
                                    if (int.Parse(aPaymentMethodTable.Rows[i]["ID"].ToString()) == int.Parse(aBillTable.Rows[RowNum]["PaymentMethodID"].ToString()))
                                    {
                                        ListBillsDGView.Rows[RowNum].Cells["PaymentMethodID"].Value = aPaymentMethodTable.Rows[i]["Name"].ToString();
                                        break;
                                    }
                                }
                                ListBillsDGView.Rows[RowNum].Cells["TotalCost"].Value     = aBillTable.Rows[RowNum]["TotalCost"].ToString();
                                ListBillsDGView.Rows[RowNum].Cells["Comments"].Value      = aBillTable.Rows[RowNum]["Comments"].ToString();
                                ListBillsDGView.Rows[RowNum].Cells["SalesDiscount"].Value = aBillTable.Rows[RowNum]["SalesDiscount"].ToString();
                                ListBillsDGView.Rows[RowNum].Cells["DiscountPerc"].Value  = aBillTable.Rows[RowNum]["DiscountPerc"].ToString();
                                ListBillsDGView.Rows[RowNum].Cells["CashIn"].Value        = aBillTable.Rows[RowNum]["CashIn"].ToString();
                                ListBillsDGView.Rows[RowNum].Cells["TotalDiscount"].Value = aBillTable.Rows[RowNum]["TotalDiscount"].ToString();

                                if (aBillTable.Rows[RowNum]["IsChecked"].ToString() == "0")
                                {
                                    ListBillsDGView.Rows[RowNum].Cells["IsChecked"].Value = UiText.NoTxt;
                                }
                                else
                                {
                                    ListBillsDGView.Rows[RowNum].Cells["IsChecked"].Value = UiText.YesTxt;
                                }

                                if (aBillTable.Rows[RowNum]["IsRevised"].ToString() == "0")
                                {
                                    ListBillsDGView.Rows[RowNum].Cells["IsRevised"].Value = UiText.NoTxt;
                                }
                                else
                                {
                                    ListBillsDGView.Rows[RowNum].Cells["IsRevised"].Value = UiText.YesTxt;
                                }
                                ListBillsDGView.Rows[RowNum].Cells["CheckedDate"].Value = aBillTable.Rows[RowNum]["CheckedDate"].ToString();
                                ListBillsDGView.Rows[RowNum].Cells["CheckedBy"].Value   = aBillTable.Rows[RowNum]["CheckedBy"].ToString();
                                ListBillsDGView.Rows[RowNum].Cells["ReviseDate"].Value  = aBillTable.Rows[RowNum]["ReviseDate"].ToString();
                                ListBillsDGView.Rows[RowNum].Cells["RevisedBy"].Value   = aBillTable.Rows[RowNum]["RevisedBy"].ToString();
                                ListBillsDGView.Rows[RowNum].Cells["ReviseLoss"].Value  = aBillTable.Rows[RowNum]["ReviseLoss"].ToString();
                                RowNum++;
                            }
                        }
                        PageOfTotalTxtBox.Text = "1/" + pagesnumber.ToString();
                        currentpage            = 1;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListBillsBtn_Click] \n Exception: \n" + ex.ToString(), MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
예제 #6
0
        public void UpdateVariables(DataRow aGeneralBillDataRow)
        {
            try
            {
                aBillGeneralRow = aGeneralBillDataRow;

                InvoiceNumTxtBox.Text = aGeneralBillDataRow["Number"].ToString();

                DateLbl.Text = DateTime.Parse(aGeneralBillDataRow["Date"].ToString()).ToShortDateString();

                TimeLbl.Text = aGeneralBillDataRow["BillTime"].ToString();

                TellerLbl.Text = UsersMgmt.SelectUserNameByID(int.Parse(aGeneralBillDataRow["TellerID"].ToString()));
                if (TellerLbl.Text == null)
                {
                    //MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-UsersMgmt.UsrById Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new Exception("[EditBill-UsersMgmt.UsrById Returned Null]");
                }
                aUserDataRow = CustomerMgmt.SelectCustomerRowByID(int.Parse(aGeneralBillDataRow["CustomerID"].ToString()));
                if (aUserDataRow == null)
                {
                    // MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectCustomerRowByID Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new Exception("EditBill-SelectCustomerRowByID Returned Null");
                }
                PriceLevelComboBox.Text = PriceLevelsMgmt.SelectPriceLevelNameByID(int.Parse(aGeneralBillDataRow["PriceLevelID"].ToString()));
                if (PriceLevelComboBox.Text == null)
                {
                    //MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectPriceLevelNameByID Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new Exception("EditBill-SelectPriceLevelNameByID Returned Null");
                }
                PhoneTxtBox.Text        = aUserDataRow["Phone1"].ToString();
                CustomerNameTxtBox.Text = aUserDataRow["Name"].ToString();
                CommentsTxtBox.Text     = aGeneralBillDataRow["Comments"].ToString();
                PriceLevelDiscount.Text = aGeneralBillDataRow["SalesDiscount"].ToString();
                DiscountPercTxtBox.Text = aGeneralBillDataRow["DiscountPerc"].ToString();
                SubtotalTxtBox.Text     = aGeneralBillDataRow["Subtotal"].ToString();
                NetAmountTxtBox.Text    = aGeneralBillDataRow["NetAmount"].ToString();
                TaxTxtBox.Text          = aGeneralBillDataRow["TotalTax"].ToString();
                DiscountBillTxtBox.Text = (double.Parse(DiscountPercTxtBox.Text) / 100 * double.Parse(NetAmountTxtBox.Text)).ToString();

                TotalDiscountTxtBox.Text = aGeneralBillDataRow["TotalDiscount"].ToString();
                TotalTxtBox.Text         = aGeneralBillDataRow["TotalPrice"].ToString();

                if (aGeneralBillDataRow["IsRevised"].ToString() == "1")
                {
                    ReviseInfoGB.Show();
                    ReviseDatelbl.Text       = DateTime.Parse(aGeneralBillDataRow["ReviseDate"].ToString()).ToShortDateString();
                    RevisedBylbl.Text        = aGeneralBillDataRow["RevisedBy"].ToString();
                    IsRevisedLbl.Visible     = true;
                    ReviseLossProfitLbl.Text = aGeneralBillDataRow["ReviseLoss"].ToString();
                }
                else
                {
                    ReviseInfoGB.Hide();
                }

                if (aGeneralBillDataRow["IsChecked"].ToString() == "1")
                {
                    ChkedByUserNameLbl.Text = aGeneralBillDataRow["CheckedBy"].ToString();
                    ChkDateLbl.Text         = DateTime.Parse(aGeneralBillDataRow["CheckedDate"].ToString()).ToShortDateString();
                    CheckInfoGB.Show();
                }
                else
                {
                    CheckInfoGB.Hide();
                }

                //PaymentInformation
                DataRow aMethodRow = PaymentMethodMgmt.SelectMethodRowByID(int.Parse(aGeneralBillDataRow["PaymentMethodID"].ToString()));
                if (aMethodRow == null)
                {
                    // MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectMethodRowByID Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new Exception("EditBill-SelectMethodRowByID Returned Null");
                }
                PaymentMethodCheckBox.Text      = aMethodRow["Name"].ToString();
                PaymentMethodDescripTxtBox.Text = aMethodRow["Description"].ToString();//PaymentMethodMgmt.SelectDescriptionByID(int.Parse(PaymentMethodCheckBox.SelectedValue.ToString()));

                if (aMethodRow["IsCash"].ToString() == "1")
                {
                    CashPaymentGB.Show();
                    CashPaymentGB.BringToFront();
                    PayInVisaGB.Hide();
                    CheckGB.Hide();
                }
                else if (aMethodRow["IsCredit"].ToString() == "1")
                {
                    PayInVisaGB.Show();
                    PayInVisaGB.BringToFront();
                    CashPaymentGB.Hide();
                    CheckGB.Hide();
                }
                else
                {
                    CheckGB.Show();
                    CheckGB.BringToFront();
                    CashPaymentGB.Hide();
                    PayInVisaGB.Hide();
                    CheckNumberTxtBox.Text = aGeneralBillDataRow["CheckNumber"].ToString();

                    DataRow aCheckDataRow = ChecksMgmt.SelectCheckRowByNumber(int.Parse(aGeneralBillDataRow["CheckNumber"].ToString()));
                    if (aCheckDataRow == null)
                    {
                        //MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectCheckRowByNumber Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        throw new Exception("EditBill-SelectCheckRowByNumber Returned Null");
                    }

                    HolderNameTxtBox.Text    = aCheckDataRow["HolderName"].ToString();
                    CheckCommentsTxtBox.Text = aCheckDataRow["Comments"].ToString();
                    CheckDatePicker.Text     = aCheckDataRow["PaymentDate"].ToString();
                }

                DataRow aAccountRow = AccountsMgmt.SelectAccountRowByID(int.Parse(aGeneralBillDataRow["AccountID"].ToString()));
                if (aAccountRow == null)
                {
                    // MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectAccountRowByID Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new Exception("EditBill-SelectAccountRowByID Returned Null");
                }
                else
                {
                    AccountComboBox.Text          = aAccountRow["Name"].ToString();
                    AccountDescriptionTxtBox.Text = aAccountRow["Description"].ToString();

                    CurrencyComboBox.Text = CurrencyMgmt.SelectCurrencyNameByID(int.Parse(aGeneralBillDataRow["CurrencyID"].ToString()));
                    if (CurrencyComboBox.Text == null)
                    {
                        MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectCurrencyNameByID Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.Close();
                    }
                    CashInCurrency.Text       = CurrencyComboBox.Text;
                    CashInTxtBox.Text         = aGeneralBillDataRow["CashIn"].ToString();
                    BuyRateTxtBox.Text        = CurrencyMgmt.SelectBuyRateByID(int.Parse(aGeneralBillDataRow["CurrencyID"].ToString())).ToString();
                    SellRateTxtBox.Text       = CurrencyMgmt.SelectSellRateByID(int.Parse(aGeneralBillDataRow["CurrencyID"].ToString())).ToString();
                    ExchangeTxtBox.Text       = (double.Parse(CashInTxtBox.Text) * double.Parse(BuyRateTxtBox.Text) - double.Parse(TotalTxtBox.Text)).ToString();
                    CreditCardInfoTxtBox.Text = aGeneralBillDataRow["CreditCardInfo"].ToString();
                }

                if (aBillGeneralRow["IsCashCredit"].ToString() == "1")
                {
                    CashMethodComboBox.SelectedIndex = 1;

                    //CustomerAccountAmountlbl.Show();
                    CustomerAccountAmountTxtBox.Show();
                    CustomersAccountAmount.Show();

                    CustomerAccountAmountTxtBox.Text = aBillGeneralRow["CustomerAccountAmountOld"].ToString();
                    CashInTxtBox.Hide();
                    ExchangeTxtBox.Hide();
                    CashInLbl.Hide();
                    ExchangeLbl.Hide();
                    JODstatic.Hide();
                    CurrencyLbl.Hide();
                    IsCreditLbl.Show();
                }
                else
                {
                    CashMethodComboBox.SelectedIndex = 0;
                    //CustomerAccountAmountlbl.Hide();
                    CustomerAccountAmountTxtBox.Hide();
                    CustomersAccountAmount.Hide();

                    CashInTxtBox.Show();
                    ExchangeTxtBox.Show();
                    CashInLbl.Show();
                    ExchangeLbl.Show();
                    JODstatic.Show();
                    CurrencyLbl.Show();

                    IsCreditLbl.Hide();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-UpdateVariables] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
예제 #7
0
        private void AddNewItem_Load(object sender, EventArgs e)
        {
            try
            {
                // AvgCostTxtBox.BackColor = Color.Transparent;
                this.WindowState = FormWindowState.Maximized;
                // TODO: This line of code loads data into the 'dBDataSet.Items' table. You can move, or remove it, as needed.
                this.itemsTableAdapter.Fill(this.dBDataSet.Items);
                // TODO: This line of code loads data into the 'dBDataSet.TaxLevel' table. You can move, or remove it, as needed.
                this.taxLevelTableAdapter.Fill(this.dBDataSet.TaxLevel);
                // TODO: This line of code loads data into the 'dBDataSet.Vendors' table. You can move, or remove it, as needed.
                this.vendorsTableAdapter.Fill(this.dBDataSet.Vendors);
                // TODO: This line of code loads data into the 'dBDataSet.ItemCategory' table. You can move, or remove it, as needed.
                this.itemCategoryTableAdapter.Fill(this.dBDataSet.ItemCategory);
                // TODO: This line of code loads data into the 'dBDataSet.ItemType' table. You can move, or remove it, as needed.
                this.itemTypeTableAdapter.Fill(this.dBDataSet.ItemType);

                aPriceLevelsTable = PriceLevelsMgmt.SelectAll();
                if (aPriceLevelsTable != null)
                {
                    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();
                                TextBox aTextBox = new TextBox();
                                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.ErrorLoadingFrom + "\n" + MsgTxt.CannotFindTxt + " " + MsgTxt.PriceLevelsTxt + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.Close();
                }

                DataRow aWeightRow = WeightMgmt.SelectWeightRow();
                if (aWeightRow != null)
                {
                    if (int.TryParse(aWeightRow["DivisionScale"].ToString(), out DivisionScale) && int.TryParse(aWeightRow["BarcodeLength"].ToString(), out BarcodeLength))
                    {
                        if (DivisionScale > 0 && BarcodeLength > 0)
                        {
                            aThereIsWeigth = true;
                        }
                    }
                }
                else
                {
                    //show error or no ?
                }
            }
            catch (Exception ex) //Launching Error Please Report It To Sari King [Database error 99%]
            {
                MessageBox.Show(MsgTxt.ErrorLoadingFrom + "\nException: IN[AddNewItem_Load] \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
예제 #8
0
        private void AddItemBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (Validators.TxtBoxNotEmpty(BarcodeTxtBox.Text) || WithoutBarcodeChkBox.Checked)
                {
                    BarcodeTxtBox.BackColor = BarcodeTxtBoxBGColor;
                    double ParsingOutTester = 0;
                    if (Validators.TxtBoxNotEmpty(QtyTxtBox.Text) && double.TryParse(QtyTxtBox.Text, out ParsingOutTester))
                    {
                        QtyTxtBox.BackColor = QtyTxtBoxBGColor;
                        if (Validators.TxtBoxNotEmpty(RenderPointTxtBox.Text) && double.TryParse(RenderPointTxtBox.Text, out ParsingOutTester))
                        {
                            RenderPointTxtBox.BackColor = RenderTxtBoxBGColor;
                            if (Validators.TxtBoxNotEmpty(DescriptionTxtBox.Text))
                            {
                                DescriptionTxtBox.BackColor = DescriptionBGColor;
                                if (Validators.TxtBoxNotEmpty(SellPriceTxtBox.Text) && double.TryParse(SellPriceTxtBox.Text, out ParsingOutTester))
                                {
                                    SellPriceTxtBox.BackColor = SellPriceBGColor;
                                    if (Validators.TxtBoxNotEmpty(AvgCostTxtBox.Text) && double.TryParse(AvgCostTxtBox.Text, out ParsingOutTester))
                                    {
                                        AvgCostTxtBox.BackColor = AvgUnitCostBGColor;

                                        bool IsPriceLevelsEmpty = false;

                                        foreach (var tb in Pricing.Controls.OfType <TextBox>())
                                        {
                                            if (!Validators.TxtBoxNotEmpty(tb.Text) || !double.TryParse(tb.Text, out ParsingOutTester))
                                            {
                                                IsPriceLevelsEmpty = true;
                                                tb.BackColor       = SharedVariables.TxtBoxRequiredColor;
                                            }
                                            else
                                            {
                                                tb.BackColor = Color.White;
                                            }
                                        }
                                        if (IsPriceLevelsEmpty)
                                        {
                                            MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.PriceLevelsTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                            return;
                                        }
                                        else
                                        {
                                            Items aItem = new Items();
                                            if (TypeComboBox.SelectedValue == null || CategoryComboBox.SelectedValue == null || VendorComboBox.SelectedValue == null || TaxLevelComboBox.SelectedValue == null)
                                            {
                                                MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                                return;
                                            }
                                            aItem.Item_Type      = (int)TypeComboBox.SelectedValue;
                                            aItem.Item_Category  = (int)CategoryComboBox.SelectedValue;
                                            aItem.Vendor         = (int)VendorComboBox.SelectedValue;
                                            aItem.Item_Tax_Level = (int)TaxLevelComboBox.SelectedValue;

                                            if (WithoutBarcodeChkBox.Checked)
                                            {
                                                aItem.IsWithoutBarcode = 1;
                                                int aWithoutBarcode_Barcode = ItemsMgmt.SelectWithoutBarcode_Barcode();;
                                                if (aWithoutBarcode_Barcode == 0)
                                                {
                                                    MessageBox.Show(MsgTxt.UnexpectedError + "\nException: IN[AddItemBtn_Click:Cannot Select Without Barcode _ Barcode] \n" + MsgTxt.PleaseTryAgainLaterTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                    return;
                                                }
                                                while (ItemsMgmt.IsItemExist(aWithoutBarcode_Barcode.ToString()))
                                                {
                                                    aWithoutBarcode_Barcode++;
                                                }
                                                aItem.Item_Barcode = "NOBC" + aWithoutBarcode_Barcode.ToString();
                                            }
                                            else
                                            {
                                                if (aThereIsWeigth && WeightChkBox.Checked && BarcodeTxtBox.Text.Length >= BarcodeLength)
                                                {
                                                    aItem.IsWeight         = 1;
                                                    aItem.IsWithoutBarcode = 0;
                                                    aItem.Item_Barcode     = BarcodeTxtBox.Text.Substring(0, BarcodeLength);
                                                }
                                                else
                                                {
                                                    aItem.IsWeight         = 0;
                                                    aItem.IsWithoutBarcode = 0;
                                                    aItem.Item_Barcode     = BarcodeTxtBox.Text;
                                                }
                                            }
                                            if (!ItemsMgmt.IsItemExist(aItem.Item_Barcode))
                                            {
                                                aItem.Item_Description = DescriptionTxtBox.Text;
                                                aItem.Avalable_Qty     = double.Parse(QtyTxtBox.Text);
                                                aItem.Render_Point     = double.Parse(RenderPointTxtBox.Text);
                                                aItem.Entry_Date       = DateTime.Now.ToShortDateString();

                                                double aSellPrice = double.Parse(SellPriceTxtBox.Text);
                                                double aUnitCost  = double.Parse(AvgCostTxtBox.Text);
                                                double aTax       = double.Parse(ItemTaxLevelMgmt.SelectItemTaxByID(aItem.Item_Tax_Level));

                                                if (TaxEnclodedChkBox.Checked)
                                                {
                                                    aItem.Sell_Price    = Math.Round(aSellPrice / ((aTax / 100) + 1), 5);
                                                    aItem.Avg_Unit_Cost = Math.Round(aUnitCost / ((aTax / 100) + 1), 5);
                                                }
                                                else
                                                {
                                                    aItem.Sell_Price    = aSellPrice;
                                                    aItem.Avg_Unit_Cost = aUnitCost;
                                                }
                                                if (!ItemsMgmt.AddItem(aItem))
                                                {
                                                    MessageBox.Show(MsgTxt.UnexpectedError + "DataBase: ItemsMgmt.AddItem" + MsgTxt.DidnotAdded + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                    this.Close();
                                                }
                                                int ItemID = ItemsMgmt.SelectItemIDByBarcode(aItem.Item_Barcode);
                                                foreach (var tb in Pricing.Controls.OfType <TextBox>())
                                                {
                                                    double atbSellPrice = double.Parse(tb.Text);
                                                    if (TaxEnclodedChkBox.Checked)
                                                    {
                                                        atbSellPrice = Math.Round(atbSellPrice / ((aTax / 100) + 1), 5);
                                                    }
                                                    Nullable <int> PriceLevelID = PriceLevelsMgmt.SelectPriceLevelIDByName(tb.Name);
                                                    if (PriceLevelID != null)
                                                    {
                                                        Nullable <int> IsAddSpecialPriceOK = SpecialPricesMgmt.AddSpecialPrice(ItemID, (int)PriceLevelID, atbSellPrice);
                                                        if (IsAddSpecialPriceOK == null)
                                                        {
                                                            MessageBox.Show(MsgTxt.PriceLevelsTxt + " " + tb.Name + " " + MsgTxt.DidnotAdded + "\n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        MessageBox.Show(MsgTxt.UnexpectedError + "DataBase: " + MsgTxt.PriceLevelsTxt + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                        this.Close();
                                                    }
                                                }

                                                MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                                DialogResult ret;
                                                ret = MessageBox.Show(MsgTxt.AddAnotherItemTxt, MsgTxt.InformationCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                                                if (ret == DialogResult.Yes)
                                                {
                                                    ReloadForm();
                                                }
                                                else
                                                {
                                                    this.Close();
                                                }
                                            }
                                            else
                                            {
                                                MessageBox.Show(MsgTxt.BarcodeTxt + " " + MsgTxt.AlreadyUsedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                                BarcodeTxtBox.Text = "";
                                            }
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.UnitCostTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        AvgCostTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                                        AvgCostTxtBox.Focus();
                                    }
                                }
                                else
                                {
                                    MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.SellingPriceTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    SellPriceTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                                    SellPriceTxtBox.Focus();
                                }
                            }
                            else
                            {
                                MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.DescriptionTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                DescriptionTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                                DescriptionTxtBox.Focus();
                            }
                        }
                        else
                        {
                            MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.RenderPointTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            RenderPointTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                            RenderPointTxtBox.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.ValidQtyTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        QtyTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                        QtyTxtBox.Focus();
                    }
                }
                else
                {
                    MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.BarcodeTxt + "\n2)" + MsgTxt.IfNotBarChkWithoutBarcodeTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    BarcodeTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                    BarcodeTxtBox.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\nException: IN[AddItemBtn_Click] \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                throw;
            }
        }
예제 #9
0
        private void AddNewPriceLevelBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (Validators.TxtBoxNotEmpty(NameTxtBox.Text) && Validators.TxtBoxNotEmpty(DescriptionTxtBox.Text))
                {
                    Nullable <int> Check = PriceLevelsMgmt.IsPriceLevelUsed(NameTxtBox.Text);
                    if (Check == 10)
                    {
                        PriceLevels aPriceLevel = new PriceLevels();
                        aPriceLevel.Price_Level_Name        = NameTxtBox.Text;
                        aPriceLevel.Price_Level_Description = DescriptionTxtBox.Text;

                        try
                        {
                            PriceLevelsMgmt.AddPriceLevel(aPriceLevel);
                            MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Close();
                        }
                        catch (Exception)
                        {
                        }
                    }
                    else if (Check == 5)
                    {
                        MessageBox.Show(MsgTxt.PriceLevelsTxt + "[" + NameTxtBox.Text + "]" + MsgTxt.AlreadyUsedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    else if (Check == null)
                    {
                        MessageBox.Show(MsgTxt.UnexpectedError + " \n[DataBase Error]:IN [AddNewPriceLevelBtn_Click]" + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (!Validators.TxtBoxNotEmpty(DescriptionTxtBox.Text))
                    {
                        DescriptionTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                        DescriptionTxtBox.Focus();
                    }
                    else
                    {
                        DescriptionTxtBox.BackColor = DescriptionBGColor;
                    }

                    if (!Validators.TxtBoxNotEmpty(NameTxtBox.Text))
                    {
                        NameTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                        NameTxtBox.Focus();
                    }
                    else
                    {
                        NameTxtBox.BackColor = NameBGColor;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + " \n[Exception]:IN [AddNewPriceLevelBtn_Click]" + "\n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }