protected void OnClientStatusDeleteClicked(object sender, EventArgs e) { LinkButton lnkItem = (LinkButton)sender; int clientStatusID = int.Parse(lnkItem.CommandArgument); ParamClientStatus deleteItem = new ParamClientStatus(clientStatusID); ParamClientStatusRepository repo = new ParamClientStatusRepository(); repo.Delete(deleteItem); BindGridData(); gridClientStatus.DataBind(); }
protected void OnBtnSaveClicked(object sender, EventArgs e) { ParamClientStatusRepository repo = new ParamClientStatusRepository(); ParamClientStatus saveItem = new ParamClientStatus(); saveItem.Status = txtClientStatus.Text.Trim(); if (string.IsNullOrEmpty(Request.QueryString["StatusID"])) { IList<ParamClientStatus> oldList = repo.GetAllClientStatuses(saveItem.Status); if (oldList.Count > 0) { string message = ResourceManager.GetString("itemAlreadyExist"); string script1 = "<script type=\"text/javascript\">"; script1 += " alert(\"" + message + "\");"; script1 += " </script>"; if (!ClientScript.IsClientScriptBlockRegistered("redirectUser")) ClientScript.RegisterStartupScript(this.GetType(), "redirectUser", script1); } else { IList<ParamClientStatus> allItems = repo.GetAllClientStatuses(); int statusID = 1; if (allItems.Count > 0) { statusID = allItems[allItems.Count - 1].StatusID + 1; } saveItem.StatusID = statusID; repo.Insert(saveItem); } } else { saveItem.StatusID = int.Parse(Request.QueryString["StatusID"]); repo.Update(saveItem); } string script = "<script type=\"text/javascript\">"; script += " OnBtnSaveClientClicked();"; script += " </script>"; if (!ClientScript.IsClientScriptBlockRegistered("redirectUser")) ClientScript.RegisterStartupScript(this.GetType(), "redirectUser", script); }