예제 #1
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url);

        using (Utils utility = new Utils())
        {
            utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
        _caseDetailsBO = new CaseDetailsBO();
        Bill_Sys_NF3_Template objNF3Template = new Bill_Sys_NF3_Template();

        try
        {
            bool flagdelete = false;
            foreach (DataGridItem grdItem in grdCaseMaster.Items)
            {
                CheckBox chkDelete = (CheckBox)grdItem.FindControl("chkHardDelete");
                if (chkDelete.Checked)
                {
                    LinkButton lnk = (LinkButton)grdItem.FindControl("lnkSelectCase");
                    _caseDetailsBO.HardDelete(lnk.CommandArgument.ToString(), txtCompanyID.Text);

                    flagdelete = true;
                    String szDefaultPath    = objNF3Template.getPhysicalPath();
                    String szDestinationDir = "";

                    if (((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).BT_REFERRING_FACILITY == true && ((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID == (((Bill_Sys_CaseObject)Session["CASE_OBJECT"]).SZ_COMAPNY_ID))
                    {
                        szDestinationDir = objNF3Template.GetCompanyName(((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID);
                    }
                    else
                    {
                        szDestinationDir = objNF3Template.GetCompanyName(grdItem.Cells[31].Text);
                    }
                    szDestinationDir = szDestinationDir + "/" + lnk.CommandArgument.ToString();

                    if (Directory.Exists(szDefaultPath + szDestinationDir))
                    {
                        string[] files = Directory.GetFiles(szDefaultPath + szDestinationDir, "*.*", SearchOption.AllDirectories);
                        foreach (string file in files)
                        {
                            System.IO.File.Delete(file);
                        }

                        Directory.Delete(szDefaultPath + szDestinationDir, true);
                    }
                    this._DAO_NOTES_EO = new DAO_NOTES_EO();
                    this._DAO_NOTES_EO.SZ_MESSAGE_TITLE = "CASE_DELETED";
                    this._DAO_NOTES_EO.SZ_ACTIVITY_DESC = "Case Id " + lnk.CommandArgument.ToString() + "deleted.";
                    this._DAO_NOTES_BO               = new DAO_NOTES_BO();
                    this._DAO_NOTES_EO.SZ_USER_ID    = (((Bill_Sys_UserObject)this.Session["USER_OBJECT"]).SZ_USER_ID);
                    this._DAO_NOTES_EO.SZ_CASE_ID    = (((Bill_Sys_CaseObject)this.Session["CASE_OBJECT"]).SZ_CASE_ID);
                    this._DAO_NOTES_EO.SZ_COMPANY_ID = this.txtCompanyID.Text;
                    this._DAO_NOTES_BO.SaveActivityNotes(this._DAO_NOTES_EO);
                }
            }

            if (flagdelete == true)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "mm", "<script language='javascript'>alert('Case deleted successfully');</script>");
            }
            BindGrid();
        }
        catch (Exception ex)
        {
            log.Debug("Shared_MasterPage. Method - Page_Load : " + ex.Message.ToString());
            log.Debug("Shared_MasterPage. Method - Page_Load : " + ex.StackTrace.ToString());
            log.Debug("Shared_MasterPage. Method - Page_Load : " + ex.InnerException.Message.ToString());
            log.Debug("Shared_MasterPage. Method - Page_Load : " + ex.InnerException.StackTrace.ToString());
            Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            using (Utils utility = new Utils())
            {
                utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
            }
            string str2 = "Error Request=" + id + ".Please share with Technical support.";
            base.Response.Redirect("Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2);
        }
        //Method End
        using (Utils utility = new Utils())
        {
            utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
    }