protected void btnSaveExcessPct_Click(object sender, EventArgs e) { const string METHOD_NAME = "btnSaveExcessPct_Click"; try { WSCSecurity auth = Globals.SecurityState; string userName = auth.UserName; string tmpValue = ""; // Iterate on each grid row and save that row back to the database using // the entered Excess Percentage. foreach (GridViewRow row in grdPayDescStation.Rows) { tmpValue = row.Cells[(int)grdPayDescStationColumns.pdecnt_description_contract_id].Text.Replace(" ", "0"); int pdecnt_description_contract_id = 0; if (!int.TryParse(tmpValue, out pdecnt_description_contract_id)) { Common.CWarning warn = new Common.CWarning("Cannot read grid value pdecnt_description_contract_id"); throw (warn); } tmpValue = row.Cells[(int)grdPayDescStationColumns.pdecnt_description_id].Text.Replace(" ", ""); int pdecnt_description_id = 0; if (tmpValue != "" && !int.TryParse(tmpValue, out pdecnt_description_id)) { Common.CWarning warn = new Common.CWarning("Cannot read grid value pdecnt_description_id"); throw (warn); } tmpValue = row.Cells[(int)grdPayDescStationColumns.pdecnt_factory_id].Text.Replace(" ", ""); int pdecnt_factory_id = 0; if (tmpValue != "" && !int.TryParse(tmpValue, out pdecnt_factory_id)) { Common.CWarning warn = new Common.CWarning("Cannot read grid value pdecnt_factory_id"); throw (warn); } tmpValue = row.Cells[(int)grdPayDescStationColumns.pdecnt_station_id].Text.Replace(" ", ""); int pdecnt_station_id = 0; if (tmpValue != "" && !int.TryParse(tmpValue, out pdecnt_station_id)) { Common.CWarning warn = new Common.CWarning("Cannot read grid value pdecnt_station_id"); throw (warn); } tmpValue = row.Cells[(int)grdPayDescStationColumns.pdecnt_contract_id].Text.Replace(" ", ""); int pdecnt_contract_id = 0; if (tmpValue != "" && !int.TryParse(tmpValue, out pdecnt_contract_id)) { Common.CWarning warn = new Common.CWarning("Cannot read grid value pdecnt_contract_id"); throw (warn); } tmpValue = Common.UILib.GetDropDownText(ddlCropYear); int pdecnt_icrop_year = Convert.ToInt32(tmpValue); tmpValue = txtExcessPct.Text; decimal pdecnt_excess_beet_pct = 0; if (!Decimal.TryParse(tmpValue, out pdecnt_excess_beet_pct)) { Common.CWarning warn = new Common.CWarning("Please enter a number for Excess Percent. This can be zero."); throw (warn); } tmpValue = row.Cells[(int)grdPayDescStationColumns.pdecnt_rowversion].Text.Replace(" ", ""); string pdecnt_rowversion = tmpValue; WSCPayment.PaymentDescriptionContractSave(pdecnt_description_contract_id, pdecnt_description_id, pdecnt_factory_id, pdecnt_station_id, pdecnt_contract_id, pdecnt_icrop_year, pdecnt_excess_beet_pct, userName, pdecnt_rowversion); FillGridPayDescStation(); } } catch (System.Exception ex) { Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex); ((PrimaryTemplate)Page.Master).ShowWarning(ex); } }