protected void imgbtndiscard_Click(object sender, EventArgs e) { Int32 MsgId = 0; DataTable dtMain = new DataTable(); if (gridDelete.Rows.Count > 0) { foreach (GridViewRow GR in gridDelete.Rows) { CheckBox chk = (CheckBox)GR.FindControl("chkMsg"); if (chk.Checked == true) { Int32 MsgDetailId = Convert.ToInt32(gridDelete.DataKeys[GR.RowIndex].Value); dtMain = clsMessage.SelectMsgIdUsingMsgDetailId(MsgDetailId); if (dtMain.Rows.Count > 0) { MsgId = Convert.ToInt32(dtMain.Rows[0]["MsgId"].ToString()); } bool MsgMasterDelete = clsMessage.DeleteMsgMaster(MsgId); if (MsgMasterDelete == true) { lblmsg.Visible = true; lblmsg.Text = "Record deleted successfully"; SelectMsgforDeleteBox(); } } } } }
protected void imgbtndiscard_Click(object sender, EventArgs e) { bool Gcheck = false; if (gridDraft.Rows.Count > 0) { foreach (GridViewRow GR in gridDraft.Rows) { CheckBox chk = (CheckBox)GR.FindControl("chkMsg"); if (chk.Checked == true) { Gcheck = true; break; } } if (Gcheck == false) { lblmsg.Text = "Please select atleast one Draft Message to Delete."; pnlmsg.Visible = true; return; } else { bool MsgMasterDelete = false; foreach (GridViewRow GR in gridDraft.Rows) { CheckBox chk = (CheckBox)GR.FindControl("chkMsg"); if (chk.Checked == true) { Int32 MsgId = Convert.ToInt32(gridDraft.DataKeys[GR.RowIndex].Value); bool MsgDetailDelete = clsMessage.DeleteMsgDetail(MsgId); bool FileDelete = clsMessage.DeleteMsgFileAttachDetail(MsgId); MsgMasterDelete = clsMessage.DeleteMsgMaster(MsgId); } } if (MsgMasterDelete == true) { lblmsg.Visible = true; pnlmsg.Visible = true; lblmsg.Text = "Message Deleted Successfully."; SelectMsgforDraft(); } } } }