public virtual CountryTaxRate UpdateCountryTaxRate(CountryTaxRate entity) { if (entity.IsTransient()) { return(entity); } CountryTaxRate other = GetCountryTaxRate(entity.CountryTaxId); if (entity.Equals(other)) { return(entity); } string sql = @"Update CountryTaxRate set [CountryID]=@CountryID , [TaxClassID]=@TaxClassID , [TaxRate]=@TaxRate , [CreatedOn]=@CreatedOn where CountryTaxID=@CountryTaxID" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@CountryTaxID", entity.CountryTaxId) , new SqlParameter("@CountryID", entity.CountryId) , new SqlParameter("@TaxClassID", entity.TaxClassId) , new SqlParameter("@TaxRate", entity.TaxRate ?? (object)DBNull.Value) , new SqlParameter("@CreatedOn", entity.CreatedOn) }; SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray); return(GetCountryTaxRate(entity.CountryTaxId)); }
public virtual CountryTaxRate InsertCountryTaxRate(CountryTaxRate entity) { CountryTaxRate other = new CountryTaxRate(); other = entity; if (entity.IsTransient()) { string sql = @"Insert into CountryTaxRate ( [CountryID] ,[TaxClassID] ,[TaxRate] ,[CreatedOn] ) Values ( @CountryID , @TaxClassID , @TaxRate , @CreatedOn ); Select scope_identity()" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@CountryTaxID", entity.CountryTaxId) , new SqlParameter("@CountryID", entity.CountryId) , new SqlParameter("@TaxClassID", entity.TaxClassId) , new SqlParameter("@TaxRate", entity.TaxRate ?? (object)DBNull.Value) , new SqlParameter("@CreatedOn", entity.CreatedOn) }; var identity = SqlHelper.ExecuteScalar(this.ConnectionString, CommandType.Text, sql, parameterArray); if (identity == DBNull.Value) { throw new DataException("Identity column was null as a result of the insert operation."); } return(GetCountryTaxRate(Convert.ToInt32(identity))); } return(entity); }
protected void UpdateTaxOrder() { for (int i = 0; i <= Request.Form.Count - 1; i++) { if (Request.Form.Keys[i].IndexOf("DisplayOrder_") != -1) { String[] keys = Request.Form.Keys[i].Split('_'); int CountryID = Localization.ParseUSInt(keys[1]); int DispOrd = 1; try { DispOrd = Localization.ParseUSInt(Request.Form[Request.Form.Keys[i]]); } catch { } DB.ExecuteSQL("update Country set DisplayOrder=" + DispOrd.ToString() + " where CountryID=" + CountryID.ToString()); } } //handle taxes for (int i = 0; i <= Request.Form.Count - 1; i++) { //TR_CLASSID_STATEID if (Request.Form.Keys[i].IndexOf("TR_") != -1) { String[] keys = Request.Form.Keys[i].Split('_'); int CountryID = Localization.ParseUSInt(keys[2]); int ClassID = Localization.ParseUSInt(keys[1]); decimal tax = Decimal.Zero; try { tax = Localization.ParseNativeDecimal(Request.Form[Request.Form.Keys[i]]); } catch { } CountryTaxRate ctr = AppLogic.CountryTaxRatesTable[CountryID, ClassID]; try { if (ctr == null) { AppLogic.CountryTaxRatesTable.Add(CountryID, ClassID, tax); } else { ctr.Update(tax); } } catch (Exception ex) { string err = ex.Message; } } } }
public virtual CountryTaxRate CountryTaxRateFromDataRow(DataRow dr) { if (dr == null) { return(null); } CountryTaxRate entity = new CountryTaxRate(); entity.CountryTaxId = (System.Int32)dr["CountryTaxID"]; entity.CountryId = (System.Int32)dr["CountryID"]; entity.TaxClassId = (System.Int32)dr["TaxClassID"]; entity.TaxRate = dr["TaxRate"] == DBNull.Value?(System.Decimal?)null : (System.Decimal?)dr["TaxRate"]; entity.CreatedOn = (System.DateTime)dr["CreatedOn"]; return(entity); }
public virtual CountryTaxRate DeleteCountryTaxRate(CountryTaxRate entity) { this.DeleteCountryTaxRate(entity.CountryTaxId); return(entity); }
protected void gMain_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = gMain.Rows[e.RowIndex]; if (row != null) { string iden = row.Cells[1].Text.ToString(); string name = ((TextBox)row.FindControl("txtName")).Text.Trim(); string twoLetter = ((TextBox)row.FindControl("txt2LetterIso")).Text.Trim(); string threeLetter = ((TextBox)row.FindControl("txt3LetterIso")).Text.Trim(); string numericISO = ((TextBox)row.FindControl("txtNumericISOCode")).Text.Trim(); bool published = ((CheckBox)row.FindControl("cbPublished")).Checked; bool postalCodeReq = ((CheckBox)row.FindControl("cbPostalCodeRequired")).Checked; string postalCodeRegEx = ((TextBox)row.FindControl("txtPostalCodeRegex")).Text.Trim(); string postalCodeExample = ((TextBox)row.FindControl("txtPostalCodeExample")).Text.Trim(); int order = Localization.ParseNativeInt(((TextBox)row.FindControl("txtOrder")).Text.Trim()); // see if already exists: int N = DB.GetSqlN("select count(Name) as N from Country with (NOLOCK) where CountryID<>" + iden + " and lower(Name)=" + DB.SQuote(name.ToLowerInvariant())); if (N != 0) { resetError(AppLogic.GetString("admin.countries.ExistingCountry", SkinID, LocaleSetting), true); return; } StringBuilder sql = new StringBuilder(1024); sql.Append("update Country set "); sql.Append("Name=" + DB.SQuote(name) + ","); sql.Append("TwoLetterISOCode=" + DB.SQuote(CommonLogic.Left(twoLetter, 2)) + ","); sql.Append("ThreeLetterISOCode=" + DB.SQuote(CommonLogic.Left(threeLetter, 3)) + ","); sql.Append("NumericISOCode=" + DB.SQuote(CommonLogic.Left(numericISO, 3)) + ","); sql.Append("Published=" + CommonLogic.IIF(published, 1, 0) + ","); sql.Append("PostalCodeRequired=" + CommonLogic.IIF(postalCodeReq, 1, 0) + ","); sql.Append("PostalCodeRegex=" + DB.SQuote(postalCodeRegEx) + ","); sql.Append("PostalCodeExample=" + DB.SQuote(postalCodeExample) + ","); sql.Append("DisplayOrder=" + order); sql.Append(" where CountryID=" + iden.ToString()); try { DB.ExecuteSQL(sql.ToString()); resetError("Item updated", false); gMain.EditIndex = -1; ViewState["SQLString"] = selectSQL; for (int i = 0; i <= Request.Form.Count - 1; i++) { //TR_CLASSID_STATEID if (Request.Form.Keys[i].IndexOf("TR_") != -1) { String[] keys = Request.Form.Keys[i].Split('_'); int CountryID = Localization.ParseUSInt(keys[2]); int ClassID = Localization.ParseUSInt(keys[1]); decimal tax = Decimal.Zero; if (CountryID == Localization.ParseUSInt(iden)) { try { tax = Localization.ParseNativeDecimal(Request.Form[Request.Form.Keys[i]]); } catch { } CountryTaxRate ctr = AppLogic.CountryTaxRatesTable[CountryID, ClassID]; try { if (ctr == null) { AppLogic.CountryTaxRatesTable.Add(CountryID, ClassID, tax); } else { ctr.Update(tax); } } catch (Exception ex) { string err = ex.Message; } } } } BuildGridData(); } catch (Exception ex) { throw new Exception(String.Format(AppLogic.GetString("admin.common.ErrUpdateDB", SkinID, LocaleSetting), sql.ToString() + ex.ToString())); } } }
public CountryTaxRate InsertCountryTaxRate(CountryTaxRate entity) { return(_iCountryTaxRateRepository.InsertCountryTaxRate(entity)); }
public CountryTaxRate UpdateCountryTaxRate(CountryTaxRate entity) { return(_iCountryTaxRateRepository.UpdateCountryTaxRate(entity)); }