Esempio n. 1
0
    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();
                }
            }
        }
    }