Example #1
0
        internal static void Update(Tax entity)
        {
            Tax TaxEntity = (Tax)(entity);

            using (SqlConnection sqlConnection = new SqlConnection(CMSCoreBase.CMSCoreConnectionString))
            {
                SqlCommand sqlCommand = new SqlCommand(SN_TAX_UPDATE, sqlConnection);
                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;

                SqlParameter sqlParameter = null;

                sqlParameter = new SqlParameter(PN_TAX_ID, System.Data.SqlDbType.Int);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = TaxEntity.ID;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlParameter = new SqlParameter(PN_TAX_PORTAL_ID, System.Data.SqlDbType.Int);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = TaxEntity.PortalID;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlParameter = new SqlParameter(PN_TAX_RATE, System.Data.SqlDbType.Decimal);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = TaxEntity.Rate;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlParameter = new SqlParameter(PN_TAX_IS_ENABLED, System.Data.SqlDbType.Bit);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = TaxEntity.IsEnabled;
                sqlCommand.Parameters.Add(sqlParameter);


                try
                {
                    sqlCommand.Connection.Open();
                    sqlCommand.ExecuteNonQuery();
                    sqlCommand.Connection.Close();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Example #2
0
        internal static int Add(Tax taxEntity)
        {
            using (SqlConnection sqlConnection = new SqlConnection(CMSCoreBase.CMSCoreConnectionString))
            {
                SqlCommand sqlCommand = new SqlCommand(SN_TAX_ADD, sqlConnection);
                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;

                SqlParameter sqlParameter = null;

                sqlParameter = new SqlParameter(PN_TAX_ID, System.Data.SqlDbType.Int);
                sqlParameter.Direction = System.Data.ParameterDirection.Output;
                sqlParameter.Value = taxEntity.ID;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlParameter = new SqlParameter(PN_TAX_PORTAL_ID, System.Data.SqlDbType.Int);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = taxEntity.PortalID;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlParameter = new SqlParameter(PN_TAX_RATE, System.Data.SqlDbType.Decimal);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = taxEntity.Rate;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlParameter = new SqlParameter(PN_TAX_IS_ENABLED, System.Data.SqlDbType.Bit);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = taxEntity.IsEnabled;
                sqlCommand.Parameters.Add(sqlParameter);

                try
                {
                    sqlCommand.Connection.Open();
                    sqlCommand.ExecuteNonQuery();
                    sqlCommand.Connection.Close();

                    taxEntity.ID = Convert.ToInt32(sqlCommand.Parameters[PN_TAX_ID].Value);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return taxEntity.ID;
        }
Example #3
0
 public static int Add(Tax tax)
 {
     return TaxDataMapper.Add(tax);
 }
Example #4
0
 public static void Update(Tax tax)
 {
     TaxDataMapper.Update(tax);
 }
        void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Tax Tax = new Tax();
                Tax.Rate = Convert.ToDecimal(txtRate.Text);
                Tax.IsEnabled = cbIsEnabled.Checked;
                Tax.PortalID = CMSContext.PortalID;
                Tax.IsDeleted = false;

                TaxManager.Add(Tax);
                BeginAddMode();

                FillTaxs(-1);
                upnlTax.Update();
            }
            catch (Exception ex)
            {
                dvProblems.Visible = true;
                dvProblems.InnerText = ex.ToString();
                upnlTax.Update();
            }
        }
Example #6
0
        internal static void FillFromReader(Tax Tax, SqlDataReader reader)
        {
            int colIndex = 0;
            colIndex = reader.GetOrdinal(CN_TAX_ID);
            if (!reader.IsDBNull(colIndex))
                Tax.ID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_TAX_PORTAL_ID);
            if (!reader.IsDBNull(colIndex))
                Tax.PortalID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_TAX_RATE);
            if (!reader.IsDBNull(colIndex))
                Tax.Rate = reader.GetDecimal(colIndex);

            colIndex = reader.GetOrdinal(CN_TAX_IS_ENABLED);
            if (!reader.IsDBNull(colIndex))
                Tax.IsEnabled = reader.GetBoolean(colIndex);

            colIndex = reader.GetOrdinal(CN_TAX_IS_DELETED);
            if (!reader.IsDBNull(colIndex))
                Tax.IsDeleted = reader.GetBoolean(colIndex);

        }
Example #7
0
        internal static Tax GetTax(List<Tax> Taxs, SqlDataReader reader)
        {
            int colIndex = 0;
            colIndex = reader.GetOrdinal(CN_TAX_ID);
            int value = reader.GetInt32(colIndex);

            Tax Tax = Taxs.Where(c => c.ID == value).FirstOrDefault();
            if (Tax == null)
            {
                Tax = new Tax();
                Taxs.Add(Tax);
            }
            return Tax;
        }