protected void btnSave_Click(object sender, EventArgs e) { lblError.Text = string.Empty; lblError.Visible = false; lblSave.Text = string.Empty; lblSave.Visible = false; lblMessage.Visible = false; lblMessage.Text = string.Empty; try { bool exists = WindPolicyManager.IsExist(txtWindPolicy.Text.Trim(), Convert.ToInt32(hdId.Value)); if (exists) { lblMessage.Text = "Wind Policy allready exists."; lblMessage.Visible = true; txtWindPolicy.Focus(); return; } WindPolicyMaster obj = WindPolicyManager.GetbyWindPolicyId(Convert.ToInt32(hdId.Value)); obj.WindPolicy = txtWindPolicy.Text; obj.Status = true; WindPolicyManager.Save(obj); saveMsg = hdId.Value == "0" ? "Record Saved Sucessfully." : "Record Updated Sucessfully."; btnCancel_Click(null, null); lblSave.Text = saveMsg; lblSave.Visible = true; } catch (Exception ex) { lblError.Visible = true; lblError.Text = "Record Not Saved !!!"; } }
protected void lvData_ItemCommand(object sender, ListViewCommandEventArgs e) { lblError.Text = string.Empty; lblSave.Text = string.Empty; lblMessage.Text = string.Empty; lblMessage.Visible = false; lblError.Visible = false; lblSave.Visible = false; if (e.CommandName.Equals("DoEdit")) { int ReportedtoinsId = Convert.ToInt32(e.CommandArgument); hdId.Value = ReportedtoinsId.ToString(); Label lblWindPolicy = (Label)e.Item.FindControl("lblWindPolicy"); txtWindPolicy.Text = lblWindPolicy.Text; } else if (e.CommandName.Equals("DoDelete")) { // In Case of delete try { var list = CheckPrimaryValue.CheckPrimaryValueExists(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(e.CommandArgument), 0, 0, 0, 0); if (list.ToList().Count > 0) { lblMessage.Text = "Wind Policy is used so you can't delete !!!"; lblMessage.Visible = true; return; } var dt = WindPolicyManager.GetbyWindPolicyId(Convert.ToInt32(e.CommandArgument)); dt.Status = false; WindPolicyManager.Save(dt); DoBind(); lblSave.Text = "Record Deleted Sucessfully."; lblSave.Visible = true; } catch (Exception ex) { lblError.Text = "Record Not Deleted."; lblError.Visible = true; } } }