Exemplo n.º 1
0
        private void UpdateFields(tTaxSetup tax)
        {
            txtTaxCode.Text        = tax.TaxCode;
            txtTaxRate.Text        = tax.TaxRate.ToString();
            txtTaxDescription.Text = tax.Description;

            cboAccount.SelectedIndex = -1;
            if (tax.AccountCode != 0)
            {
                for (int i = 0; i < cboAccount.Items.Count; i++)
                {
                    var item = cboAccount.Items[i] as string;
                    if (!string.IsNullOrWhiteSpace(item))
                    {
                        var findIndex = item.IndexOf("|", 0);
                        if (findIndex != -1)
                        {
                            int accountCode = Convert.ToInt16(item.Substring(0, findIndex));
                            if (accountCode == tax.AccountCode)
                            {
                                cboAccount.SelectedItem = item;
                                break;
                            }
                        }
                    }
                }
            }
        }
        public static int DeleteTax(tTaxSetup tTaxSetup)
        {
            int rowsAdded;

            using (IDbConnection connection = DbConnectionHelper.GetConnection())
            {
                var query =
                    new StringBuilder("DELETE FROM tTaxSetup WHERE  CompanyID=@CompanyID and TaxCode = @TaxCode");

                rowsAdded = connection.Execute(query.ToString(), tTaxSetup);
            }

            return(rowsAdded);
        }
        public static int UpdateTax(tTaxSetup tTaxSetup)
        {
            int rowsAdded;

            using (IDbConnection connection = DbConnectionHelper.GetConnection())
            {
                var query =
                    new StringBuilder(
                        "UPDATE tTaxSetup SET TaxRate=@TaxRate,AccountCode = @AccountCode, Description = @Description ");
                query.Append("WHERE  CompanyID=@CompanyID and TaxCode = @TaxCode");

                rowsAdded = connection.Execute(query.ToString(), tTaxSetup);
            }

            return(rowsAdded);
        }
        public static int AddTax(tTaxSetup tTaxSetup)
        {
            int rowsAdded;

            using (IDbConnection connection = DbConnectionHelper.GetConnection())
            {
                var query =
                    new StringBuilder(
                        "INSERT INTO tTaxSetup(CompanyID,TaxCode,TaxRate,AccountCode,  Description)");
                query.Append("VALUES(@CompanyID,@TaxCode, @TaxRate,@AccountCode, @Description)");

                rowsAdded = connection.Execute(query.ToString(), tTaxSetup);
            }

            return(rowsAdded);
        }
 public static bool DeleteTax(tTaxSetup taxSetup)
 {
     try
     {
         var result = AccountingDataProvider.DeleteTax(taxSetup);
         if (result == 1)
         {
             return(true);
         }
         return(false);
     }
     catch (Exception exception)
     {
         throw new Exception(exception.Message);
     }
 }
Exemplo n.º 6
0
        private tTaxSetup GetTax()
        {
            var taxSetup = new tTaxSetup
            {
                CompanyId   = ShatedData.ApplicationState.SelectedCompanyId,
                TaxCode     = txtTaxCode.Text,
                TaxRate     = Convert.ToInt16(txtTaxRate.Text),
                Description = txtTaxDescription.Text //,
                                                     //AccountCode=cboAccount
            };

            var findIndex = cboAccount.SelectedValue.ToString().IndexOf("|", 0);

            if (findIndex != -1)
            {
                taxSetup.AccountCode = Convert.ToInt16(cboAccount.SelectedValue.ToString().Substring(0, findIndex));
            }


            return(taxSetup);
        }