protected void GrdSMSText_RowUpdated(object sender, GridViewUpdatedEventArgs e) { try { System.Threading.Thread.Sleep(1000); GrdSMSText.DataBind(); } catch (Exception ex) { TroyLiteExceptionManager.HandleException(ex); } }
protected void lnkBtnAdd_Click(object sender, EventArgs e) { try { GrdSMSText.DataBind(); GrdSMSText.ShowFooter = true; lnkBtnAdd.Visible = false; } catch (Exception ex) { TroyLiteExceptionManager.HandleException(ex); } }
protected void GrdSMSText_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "Cancel") { GrdSMSText.FooterRow.Visible = false; lnkBtnAdd.Visible = true; } else if (e.CommandName == "Insert") { if (!Page.IsValid) { foreach (IValidator validator in Page.Validators) { if (!validator.IsValid) { //errDisp.AddItem(validator.ErrorMessage, DisplayIcons.Error, true); } } } else { BusinessLogic objBus = new BusinessLogic(); int nextSeq = objBus.GetNextSequence(GetConnectionString(), "Select Max(ID) from tblSMSText"); string smsType = ((TextBox)GrdSMSText.FooterRow.FindControl("txtAddSMSType")).Text; string smsText = ((TextBox)GrdSMSText.FooterRow.FindControl("txtAddSMSText")).Text; string Username = Request.Cookies["LoggedUserName"].Value; //srcGridView.InsertParameters.Add("Usernam", TypeCode.String, Username); if (nextSeq == -1) { return; } string sQl = string.Format("Insert Into tblSMSText Values({0},'{1}','{2}')", nextSeq + 1, smsType, smsText); srcGridView.InsertParameters.Add("sQl", TypeCode.String, sQl); srcGridView.InsertParameters.Add("connection", TypeCode.String, GetConnectionString()); srcGridView.InsertParameters.Add("Usernam", TypeCode.String, Username); srcGridView.InsertParameters.Add("types", TypeCode.String, "SMS"); srcGridView.InsertParameters.Add("smstext", TypeCode.String, smsText); try { srcGridView.Insert(); System.Threading.Thread.Sleep(1000); GrdSMSText.DataBind(); } catch (Exception ex) { if (ex.InnerException != null) { StringBuilder script = new StringBuilder(); script.Append("alert('SMS with this name already exists, Please try with a different name.');"); if (ex.InnerException.Message.IndexOf("duplicate values in the index") > -1) { ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), script.ToString(), true); } return; } } lnkBtnAdd.Visible = true; } } else if (e.CommandName == "Update") { if (!Page.IsValid) { foreach (IValidator validator in Page.Validators) { if (!validator.IsValid) { //errDisp.AddItem(validator.ErrorMessage, DisplayIcons.Error, true); } } return; } } else if (e.CommandName == "Edit") { lnkBtnAdd.Visible = false; } else if (e.CommandName == "Page") { lnkBtnAdd.Visible = true; } } catch (Exception ex) { TroyLiteExceptionManager.HandleException(ex); } }