protected void dvCurrencyConversion_ItemInserting(object sender, DetailsViewInsertEventArgs e) { // Check for duplicate currency. string currency = e.Values["currency"].ToString().Trim(); string sql = "select count(*) from [CurrencyRate] where [currency]='" + currency + "'"; if (Convert.ToInt32(myExternalData.getAggregateValue(sql)) != 0) { lblInsertMessage.Text = "Duplicate currency."; lblInsertMessage.CssClass = "label label-warning"; lblInsertMessage.Visible = true; e.Cancel = true; } else { lblInsertMessage.Text = "Currency " + currency + " added."; lblInsertMessage.CssClass = "label label-success"; lblInsertMessage.Visible = true; } }
protected void dvBond_ItemInserting(object sender, DetailsViewInsertEventArgs e) { // Remove leading zeros and check for duplicate bond code. string code = Convert.ToInt32(e.Values["code"]).ToString(); string sql = "select count(*) from [Bond] where [code]='" + code + "'"; if (Convert.ToInt32(myExternalData.getAggregateValue(sql)) != 0) { lblInsertMessage.Text = "Duplicate bond code."; lblInsertMessage.CssClass = "label label-warning"; lblInsertMessage.Visible = true; e.Cancel = true; getBond(); } else { // Change code value to remove possible leading zeros before inserting. e.Values["code"] = code; lblInsertMessage.Text = "Bond " + code + " added."; lblInsertMessage.CssClass = "label label-success"; lblInsertMessage.Visible = true; } }