public virtual StateTaxRate UpdateStateTaxRate(StateTaxRate entity) { if (entity.IsTransient()) { return(entity); } StateTaxRate other = GetStateTaxRate(entity.StateTaxId); if (entity.Equals(other)) { return(entity); } string sql = @"Update StateTaxRate set [StateID]=@StateID , [TaxClassID]=@TaxClassID , [TaxRate]=@TaxRate , [CreatedOn]=@CreatedOn where StateTaxID=@StateTaxID" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@StateTaxID", entity.StateTaxId) , new SqlParameter("@StateID", entity.StateId) , 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(GetStateTaxRate(entity.StateTaxId)); }
public async Task <IActionResult> Edit(string id, [Bind("STATE,TAXRATE")] StateTaxRate stateTaxRate) { if (id != stateTaxRate.STATE) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(stateTaxRate); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StateTaxRateExists(stateTaxRate.STATE)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(stateTaxRate)); }
public virtual StateTaxRate InsertStateTaxRate(StateTaxRate entity) { StateTaxRate other = new StateTaxRate(); other = entity; if (entity.IsTransient()) { string sql = @"Insert into StateTaxRate ( [StateID] ,[TaxClassID] ,[TaxRate] ,[CreatedOn] ) Values ( @StateID , @TaxClassID , @TaxRate , @CreatedOn ); Select scope_identity()" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@StateTaxID", entity.StateTaxId) , new SqlParameter("@StateID", entity.StateId) , 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(GetStateTaxRate(Convert.ToInt32(identity))); } return(entity); }
public async Task <IActionResult> Create([Bind("STATE,TAXRATE")] StateTaxRate stateTaxRate) { if (ModelState.IsValid) { _context.Add(stateTaxRate); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(stateTaxRate)); }
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 StateID = Localization.ParseUSInt(keys[1]); int DispOrd = 1; try { DispOrd = Localization.ParseUSInt(Request.Form[Request.Form.Keys[i]]); } catch { } DB.ExecuteSQL("update State set DisplayOrder=" + DispOrd.ToString() + " where StateID=" + StateID.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 StateID = 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 { } StateTaxRate ctr = AppLogic.StateTaxRatesTable[StateID, ClassID]; try { if (ctr == null) { AppLogic.StateTaxRatesTable.Add(StateID, ClassID, tax); } else { ctr.Update(tax); } } catch (Exception ex) { string err = ex.Message; } } } }
public virtual StateTaxRate StateTaxRateFromDataRow(DataRow dr) { if (dr == null) { return(null); } StateTaxRate entity = new StateTaxRate(); entity.StateTaxId = (System.Int32)dr["StateTaxID"]; entity.StateId = (System.Int32)dr["StateID"]; 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 StateTaxRate DeleteStateTaxRate(StateTaxRate entity) { this.DeleteStateTaxRate(entity.StateTaxId); return(entity); }
public StateTaxRate InsertStateTaxRate(StateTaxRate entity) { return(_iStateTaxRateRepository.InsertStateTaxRate(entity)); }
public StateTaxRate UpdateStateTaxRate(StateTaxRate entity) { return(_iStateTaxRateRepository.UpdateStateTaxRate(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 abbr = ((TextBox)row.FindControl("txtAbbreviation")).Text.Trim(); bool published = ((CheckBox)row.FindControl("cbPublished")).Checked; int country = Localization.ParseNativeInt(((DropDownList)row.FindControl("ddCountry")).SelectedValue); int order = Localization.ParseNativeInt(((TextBox)row.FindControl("txtOrder")).Text.Trim()); // see if already exists: int N = DB.GetSqlN("select count(Name) as N from State with (NOLOCK) where StateID<>" + iden + " and lower(Name)=" + DB.SQuote(name.ToLowerInvariant())); if (N != 0) { resetError("There is already another state with that name.", true); return; } StringBuilder sql = new StringBuilder(4096); sql.Append("update State set "); sql.Append("Name=" + DB.SQuote(name) + ","); sql.Append("CountryID=" + country + ","); sql.Append("Published=" + CommonLogic.IIF(published, 1, 0) + ","); sql.Append("DisplayOrder=" + order + ","); sql.Append("Abbreviation=" + DB.SQuote(CommonLogic.Left(abbr, 5))); sql.Append(" where StateID=" + iden); try { DB.ExecuteSQL(sql.ToString()); resetError("Item updated", false); gMain.EditIndex = -1; ViewState["SQLString"] = selectSQL; //UpdateTaxOrder(); 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 StateID = Localization.ParseUSInt(keys[2]); int ClassID = Localization.ParseUSInt(keys[1]); if (StateID == Localization.ParseUSInt(iden)) { decimal tax = Decimal.Zero; try { tax = Localization.ParseNativeDecimal(Request.Form[Request.Form.Keys[i]]); } catch { } StateTaxRate str = AppLogic.StateTaxRatesTable[StateID, ClassID]; try { if (str == null) { AppLogic.StateTaxRatesTable.Add(StateID, ClassID, tax); } else { str.Update(tax); } } catch (Exception ex) { string err = ex.Message; } } } } buildGridData(); } catch (Exception ex) { throw new Exception("Couldn't update database: " + sql.ToString() + ex.ToString()); } } }