Exemple #1
0
        private void AddTaxBtn_Click(object sender, EventArgs e)
        {
            try
            {
                double TestParser;
                if (Validators.TxtBoxNotEmpty(PercentageTxtBox.Text) && Validators.TxtBoxNotEmpty(DescriptionTxtBox.Text))
                {
                    if (!double.TryParse(PercentageTxtBox.Text, out TestParser))
                    {
                        MessageBox.Show(MsgTxt.PleaseSelectCorrectAmountTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        PercentageTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                        return;
                    }
                    else
                    {
                        PercentageTxtBox.BackColor = PercentageBGColor;
                    }

                    Nullable <int> Check = ItemTaxLevelMgmt.IsTaxLevelUsed(PercentageTxtBox.Text);
                    if (Check == 10)
                    {
                        ItemTaxLevel aItemTaxLevel = new ItemTaxLevel();
                        aItemTaxLevel.Item_Tax_Percentage  = PercentageTxtBox.Text;
                        aItemTaxLevel.Item_Tax_Description = DescriptionTxtBox.Text;

                        if (ItemTaxLevelMgmt.AddTaxLevel(aItemTaxLevel))
                        {
                            MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show(MsgTxt.UnexpectedError + " \n[DataBase Error]:IN [AddTaxBtn_Click]" + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            this.Close();
                        }
                    }
                    else if (Check == 5)
                    {
                        MessageBox.Show(MsgTxt.PercentageTxt + " [ " + PercentageTxtBox.Text + " ] " + MsgTxt.AlreadyUsedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else if (Check == null)
                    {
                        MessageBox.Show(MsgTxt.UnexpectedError + " \n[DataBase Error2]:IN [AddTaxBtn_Click]" + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    if (!Validators.TxtBoxNotEmpty(DescriptionTxtBox.Text))
                    {
                        DescriptionTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                        DescriptionTxtBox.Focus();
                    }
                    else
                    {
                        DescriptionTxtBox.BackColor = DescriptionBGColor;
                    }

                    if (!Validators.TxtBoxNotEmpty(PercentageTxtBox.Text))
                    {
                        PercentageTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                        PercentageTxtBox.Focus();
                    }
                    else
                    {
                        PercentageTxtBox.BackColor = PercentageBGColor;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + " \n[Exception]:IN [AddUserBtn_Click]" + "\n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
Exemple #2
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();
            }
        }