protected override void Page_Load(object sender, EventArgs e)
    {
        ChequeBookFormUI chequeBookFormUI = new ChequeBookFormUI();

        if (!Page.IsPostBack)
        {
            if (Request.QueryString["ChequeBookId"] != null)
            {
                chequeBookFormUI.Tbl_ChequeBookId = Request.QueryString["ChequeBookId"];


                FillForm(chequeBookFormUI);

                btnSave.Visible   = false;
                btnClear.Visible  = false;
                btnUpdate.Visible = true;
                btnDelete.Visible = true;
                lblHeading.Text   = "Update Cheque Book";
            }
            else
            {
                btnSave.Visible   = true;
                btnClear.Visible  = true;
                btnUpdate.Visible = false;
                btnDelete.Visible = false;
                lblHeading.Text   = "Add New Cheque Book";
            }
        }
    }
    private void FillForm(ChequeBookFormUI chequeBookFormUI)
    {
        try
        {
            DataTable dtb = chequeBookFormBAL.GetChequeBookListById(chequeBookFormUI);

            if (dtb.Rows.Count > 0)
            {
                txtChequeBookNumber.Text = dtb.Rows[0]["ChequeBookNumber"].ToString();
                txtChequeBookName.Text   = dtb.Rows[0]["ChequeBookName"].ToString();
            }
            else
            {
                lblError.Text    = Resources.GlobalResource.msgCouldNotLoadData;
                divError.Visible = true;
            }
        }
        catch (Exception exp)
        {
            logExcpUIobj.MethodName       = "FillForm()";
            logExcpUIobj.ResourceName     = "System_Settings_BatchForm.CS";
            logExcpUIobj.RecordId         = chequeBookFormUI.Tbl_ChequeBookId;
            logExcpUIobj.ExceptionDetails = "Error Occured. System Generated Error is: " + exp.ToString();
            logExcpDALobj.SaveExceptionToDB(logExcpUIobj);

            log.Error("[System_Settings_ChequeBookForm : FillForm] An error occured in the processing of Record Details : [" + exp.ToString() + "]");
        }
    }
    public int DeleteChequeBook(ChequeBookFormUI chequeBookFormUI)
    {
        int resutl = 0;

        resutl = chequeBookFormDAL.DeleteChequeBook(chequeBookFormUI);
        return(resutl);
    }
    public int AddChequeBook(ChequeBookFormUI chequeBookFormUI)
    {
        int resutl = 0;

        resutl = chequeBookFormDAL.AddChequeBook(chequeBookFormUI);
        return(resutl);
    }
    public DataTable GetChequeBookListById(ChequeBookFormUI chequeBookFormUI)
    {
        DataTable dtb = new DataTable();

        dtb = chequeBookFormDAL.GetChequeBookListById(chequeBookFormUI);
        return(dtb);
    }
    public int UpdateChequeBook(ChequeBookFormUI chequeBookFormUI)
    {
        int result = 0;

        try
        {
            using (SqlConnection SupportCon = new SqlConnection(connectionString))
            {
                SupportCon.Open();
                SqlCommand sqlCmd = new SqlCommand("SP_ChequeBook_Update", SupportCon);
                sqlCmd.CommandType    = CommandType.StoredProcedure;
                sqlCmd.CommandTimeout = commandTimeout;

                sqlCmd.Parameters.Add("@ModifiedBy", SqlDbType.NVarChar);
                sqlCmd.Parameters["@ModifiedBy"].Value = chequeBookFormUI.ModifiedBy;

                sqlCmd.Parameters.Add("@tbl_ChequeBookId", SqlDbType.NVarChar);
                sqlCmd.Parameters["@tbl_ChequeBookId"].Value = chequeBookFormUI.Tbl_ChequeBookId;

                sqlCmd.Parameters.Add("@tbl_OrganizationId", SqlDbType.NVarChar);
                sqlCmd.Parameters["@tbl_OrganizationId"].Value = chequeBookFormUI.Tbl_OrganizationId;

                sqlCmd.Parameters.Add("@ChequeBookName", SqlDbType.NVarChar);
                sqlCmd.Parameters["@ChequeBookName"].Value = chequeBookFormUI.ChequeBookName;

                sqlCmd.Parameters.Add("@ChequeBookNumber", SqlDbType.NVarChar);
                sqlCmd.Parameters["@ChequeBookNumber"].Value = chequeBookFormUI.ChequeBookNumber;

                result = sqlCmd.ExecuteNonQuery();

                sqlCmd.Dispose();
                SupportCon.Close();
            }
        }
        catch (Exception exp)
        {
            logExcpUIobj.MethodName       = "UpdateChequeBook()";
            logExcpUIobj.ResourceName     = "ChequeBookFormDAL.CS";
            logExcpUIobj.RecordId         = chequeBookFormUI.Tbl_ChequeBookId;
            logExcpUIobj.ExceptionDetails = "Error Occured. System Generated Error is: " + exp.ToString();
            logExcpDALobj.SaveExceptionToDB(logExcpUIobj);

            log.Error("[ChequeBookFormDAL : UpdateChequeBook] An error occured in the processing of Record Id : " + chequeBookFormUI.Tbl_ChequeBookId + ". Details : [" + exp.ToString() + "]");
        }

        return(result);
    }
    public DataTable GetChequeBookListById(ChequeBookFormUI chequeBookFormUI)
    {
        DataSet   ds   = new DataSet();
        DataTable dtbl = new DataTable();

        try
        {
            using (SqlConnection SupportCon = new SqlConnection(connectionString))
            {
                SqlCommand sqlCmd = new SqlCommand("SP_ChequeBook_SelectById", SupportCon);
                sqlCmd.CommandType    = CommandType.StoredProcedure;
                sqlCmd.CommandTimeout = commandTimeout;

                sqlCmd.Parameters.Add("@tbl_ChequeBookId", SqlDbType.NVarChar);
                sqlCmd.Parameters["@tbl_ChequeBookId"].Value = chequeBookFormUI.Tbl_ChequeBookId;

                using (SqlDataAdapter adapter = new SqlDataAdapter(sqlCmd))
                {
                    adapter.Fill(ds);
                }
            }
            if (ds.Tables.Count > 0)
            {
                dtbl = ds.Tables[0];
            }
        }
        catch (Exception exp)
        {
            logExcpUIobj.MethodName       = "getChequeBookListById()";
            logExcpUIobj.ResourceName     = "ChequeBookFormDAL.CS";
            logExcpUIobj.RecordId         = chequeBookFormUI.Tbl_ChequeBookId;
            logExcpUIobj.ExceptionDetails = "Error Occured. System Generated Error is: " + exp.ToString();
            logExcpDALobj.SaveExceptionToDB(logExcpUIobj);

            log.Error("[ChequeBookFormDAL : getChequeBookListById] An error occured in the processing of Record Id : " + chequeBookFormUI.Tbl_ChequeBookId + ". Details : [" + exp.ToString() + "]");
        }
        finally
        {
            ds.Dispose();
        }

        return(dtbl);
    }