Exemplo n.º 1
0
        public static void UpdateTaxLevel(ItemTaxLevel aItemTaxLevel)
        {
            if (Helper.Instance.con.State == ConnectionState.Closed)
            {
                try
                {
                    Helper.Instance.con.Open();
                    SqlCommand cmd = new SqlCommand("UPDATE TaxLevel SET Percentage=@Percentage,Description=@Description WHERE ID=@ID", Helper.Instance.con);
                    cmd.Parameters.Add("@Percentage", SqlDbType.NVarChar).Value  = aItemTaxLevel.Item_Tax_Percentage;
                    cmd.Parameters.Add("@Description", SqlDbType.NVarChar).Value = aItemTaxLevel.Item_Tax_Description;
                    cmd.Parameters.Add("@ID", SqlDbType.Int).Value = aItemTaxLevel.Item_Tax_ID;

                    cmd.ExecuteNonQuery();
                    Helper.Instance.con.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("ERROR IN *ItemTaxLevel* MGMT (UpdateTaxLevel FUNCTION) EX=" + ex.Message.ToString());
                }
            }
        }
Exemplo n.º 2
0
        public static bool AddTaxLevel(ItemTaxLevel aItemTaxLevel)
        {
            if (Helper.Instance.con.State == ConnectionState.Closed)
            {
                try
                {
                    Helper.Instance.con.Open();
                    SqlCommand cmd = new SqlCommand("INSERT INTO TaxLevel (Percentage,Description) VALUES (@Percentage,@Description)", Helper.Instance.con);
                    cmd.Parameters.Add("@Percentage", SqlDbType.NVarChar).Value  = aItemTaxLevel.Item_Tax_Percentage;
                    cmd.Parameters.Add("@Description", SqlDbType.NVarChar).Value = aItemTaxLevel.Item_Tax_Description;
                    cmd.ExecuteNonQuery();
                    Helper.Instance.con.Close();
                    return(true);
                }
                catch (Exception ex)
                {
                    Helper.Instance.con.Close();

                    MessageBox.Show("ERROR IN *ItemTaxLevel* MGMT (AddTaxLevel FUNCTION) EX=" + ex.Message.ToString());
                    return(false);
                }
            }
            return(false);
        }
Exemplo n.º 3
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();
            }
        }