public int DeleteCustomerAndGroupAccount(CustomerAndGroupAccountFormUI customerAndGroupAccountFormUI)
    {
        int resutl = 0;

        resutl = customerAndGroupAccountFormDAl.DeleteCustomerAndGroupAccount(customerAndGroupAccountFormUI);
        return(resutl);
    }
    public DataTable GetCustomerAndGroupAccountListById(CustomerAndGroupAccountFormUI customerAndGroupAccountFormUI)
    {
        DataTable dtb = new DataTable();

        dtb = customerAndGroupAccountFormDAl.GetCustomerAndGroupAccountListById(customerAndGroupAccountFormUI);
        return(dtb);
    }
    protected override void Page_Load(object sender, EventArgs e)
    {
        CustomerAndGroupAccountFormUI customerAndGroupAccountFormUI = new CustomerAndGroupAccountFormUI();

        if (!Page.IsPostBack)
        {
            if (Request.QueryString["CustomerAndGroupAccountId"] != null)
            {
                customerAndGroupAccountFormUI.Tbl_CustomerAndGroupAccountId = Request.QueryString["CustomerAndGroupAccountId"];

                BindOptionAccountTypeDropDown();

                FillForm(customerAndGroupAccountFormUI);

                btnSave.Visible   = false;
                btnClear.Visible  = false;
                btnUpdate.Visible = true;
                btnDelete.Visible = true;
                lblHeading.Text   = "Update Customer And GroupAccount";
            }
            else
            {
                BindOptionAccountTypeDropDown();
                btnSave.Visible   = true;
                btnClear.Visible  = true;
                btnUpdate.Visible = false;
                btnDelete.Visible = false;
                lblHeading.Text   = "Add New Customer And GroupAccount";
            }
        }
    }
    private void FillForm(CustomerAndGroupAccountFormUI customerAndGroupAccountFormUI)
    {
        try
        {
            DataTable dtb = customerAndGroupAccountFormBAL.GetCustomerAndGroupAccountListById(customerAndGroupAccountFormUI);

            if (dtb.Rows.Count > 0)
            {
                txtCustomerGroup.Text     = dtb.Rows[0]["tbl_CustomerGroup"].ToString();
                txtCustomerGroupGuid.Text = dtb.Rows[0]["Tbl_CustomerGroupId"].ToString();

                ddlOpt_AccountType.SelectedValue = dtb.Rows[0]["Opt_AccountType"].ToString();
                if (Convert.ToBoolean(dtb.Rows[0]["PaymentMode"]) == true)
                {
                    chkPaymentMode.Checked = true;
                }
                else
                {
                    chkPaymentMode.Checked = false;
                }
                txtGLAccountId_Cash.Text     = dtb.Rows[0]["Cash"].ToString();
                txtGLAccountId_CashGuid.Text = dtb.Rows[0]["Tbl_GLAccountId_Cash"].ToString();

                txtChequeBook.Text     = dtb.Rows[0]["ChequeBookName"].ToString();
                txtChequeBookGuid.Text = dtb.Rows[0]["tbl_ChequeBookId"].ToString();

                txtAccountReceivable.Text     = dtb.Rows[0]["AccountReceivable"].ToString();
                txtAccountReceivableGuid.Text = dtb.Rows[0]["tbl_GLAccountId_AccountReceivable"].ToString();

                txtSales.Text     = dtb.Rows[0]["Sales"].ToString();
                txtSalesGuid.Text = dtb.Rows[0]["tbl_GLAccountId_Sales"].ToString();

                txtCostOfSales.Text     = dtb.Rows[0]["CostOfSales"].ToString();
                txtCostOfSalesGuid.Text = dtb.Rows[0]["tbl_GLAccountId_CostOfSales"].ToString();

                txtInventory.Text     = dtb.Rows[0]["Inventory"].ToString();
                txtInventoryGuid.Text = dtb.Rows[0]["tbl_GLAccountId_Inventory"].ToString();

                txtAccuralDifferedA_C.Text     = dtb.Rows[0]["AccuralDifferedA_C"].ToString();
                txtAccuralDifferedA_CGuid.Text = dtb.Rows[0]["tbl_GLAccountId_AccuralDifferedA_C"].ToString();
            }
            else
            {
                lblError.Text    = Resources.GlobalResource.msgCouldNotLoadData;
                divError.Visible = true;
            }
        }
        catch (Exception exp)
        {
            logExcpUIobj.MethodName       = "FillForm()";
            logExcpUIobj.ResourceName     = "Finance_Accounts_Receivable_Customer_Master_Creation_CustomerAndGroupAccount.CS";
            logExcpUIobj.RecordId         = customerAndGroupAccountFormUI.Tbl_CustomerAndGroupAccountId;
            logExcpUIobj.ExceptionDetails = "Error Occured. System Generated Error is: " + exp.ToString();
            logExcpDALobj.SaveExceptionToDB(logExcpUIobj);

            log.Error("[Finance_Accounts_Receivable_Customer_Master_Creation_CustomerAndGroupAccount : FillForm] An error occured in the processing of Record Details : [" + exp.ToString() + "]");
        }
    }
    public DataTable GetCustomerAndGroupAccountListById(CustomerAndGroupAccountFormUI customerAndGroupAccountFormUI)
    {
        DataSet   ds   = new DataSet();
        DataTable dtbl = new DataTable();

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

                sqlCmd.Parameters.Add("@tbl_CustomerAndGroupAccountId", SqlDbType.NVarChar);
                sqlCmd.Parameters["@tbl_CustomerAndGroupAccountId"].Value = customerAndGroupAccountFormUI.Tbl_CustomerAndGroupAccountId;

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

            log.Error("[CustomerAndGroupAccountFormDAL : getCustomerAndGroupAccountListById] An error occured in the processing of Record Id : " + customerAndGroupAccountFormUI.Tbl_CustomerAndGroupAccountId + ". Details : [" + exp.ToString() + "]");
        }
        finally
        {
            ds.Dispose();
        }

        return(dtbl);
    }
    public int DeleteCustomerAndGroupAccount(CustomerAndGroupAccountFormUI customerAndGroupAccountFormUI)
    {
        int result = 0;

        try
        {
            using (SqlConnection SupportCon = new SqlConnection(connectionString))
            {
                SupportCon.Open();
                SqlCommand sqlCmd = new SqlCommand("SP_CustomerAndGroupAccount_Delete", SupportCon);

                sqlCmd.CommandType    = CommandType.StoredProcedure;
                sqlCmd.CommandTimeout = commandTimeout;

                sqlCmd.Parameters.Add("@tbl_CustomerAndGroupAccountId", SqlDbType.NVarChar);
                sqlCmd.Parameters["@tbl_CustomerAndGroupAccountId"].Value = customerAndGroupAccountFormUI.Tbl_CustomerAndGroupAccountId;

                result = sqlCmd.ExecuteNonQuery();

                sqlCmd.Dispose();
                SupportCon.Close();
            }
        }
        catch (Exception exp)
        {
            logExcpUIobj.MethodName       = "DeleteCustomerAndGroupAccount()";
            logExcpUIobj.ResourceName     = "CustomerAndGroupAccountFormDAL.CS";
            logExcpUIobj.RecordId         = customerAndGroupAccountFormUI.Tbl_CustomerAndGroupAccountId;
            logExcpUIobj.ExceptionDetails = "Error Occured. System Generated Error is: " + exp.ToString();
            logExcpDALobj.SaveExceptionToDB(logExcpUIobj);

            log.Error("[CustomerAndGroupAccountFormDAL : DeleteCustomerAndGroupAccount] An error occured in the processing of Record Id : " + customerAndGroupAccountFormUI.Tbl_CustomerAndGroupAccountId + ". Details : [" + exp.ToString() + "]");
        }

        return(result);
    }
    public int AddCustomerAndGroupAccount(CustomerAndGroupAccountFormUI customerAndGroupAccountFormUI)
    {
        int result = 0;

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

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

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

                sqlCmd.Parameters.Add("@tbl_CustomerGroupId", SqlDbType.NVarChar);
                sqlCmd.Parameters["@tbl_CustomerGroupId"].Value = customerAndGroupAccountFormUI.Tbl_CustomerGroupId;

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

                sqlCmd.Parameters.Add("@AccountType", SqlDbType.TinyInt);
                sqlCmd.Parameters["@AccountType"].Value = customerAndGroupAccountFormUI.Opt_AccountType;

                sqlCmd.Parameters.Add("@PaymentMode", SqlDbType.Bit);
                sqlCmd.Parameters["@PaymentMode"].Value = customerAndGroupAccountFormUI.PaymentMode;

                sqlCmd.Parameters.Add("@tbl_GLAccountId_Cash", SqlDbType.NVarChar);
                sqlCmd.Parameters["@tbl_GLAccountId_Cash"].Value = customerAndGroupAccountFormUI.Tbl_GLAccountId_Cash;

                sqlCmd.Parameters.Add("@tbl_GLAccountId_AccountReceivable", SqlDbType.NVarChar);
                sqlCmd.Parameters["@tbl_GLAccountId_AccountReceivable"].Value = customerAndGroupAccountFormUI.Tbl_GLAccountId_AccountReceivable;

                sqlCmd.Parameters.Add("@tbl_GLAccountId_Sales", SqlDbType.NVarChar);
                sqlCmd.Parameters["@tbl_GLAccountId_Sales"].Value = customerAndGroupAccountFormUI.Tbl_GLAccountId_Sales;

                sqlCmd.Parameters.Add("@tbl_GLAccountId_CostOfSales", SqlDbType.NVarChar);
                sqlCmd.Parameters["@tbl_GLAccountId_CostOfSales"].Value = customerAndGroupAccountFormUI.Tbl_GLAccountId_CostOfSales;

                sqlCmd.Parameters.Add("@tbl_GLAccountId_Inventory", SqlDbType.NVarChar);
                sqlCmd.Parameters["@tbl_GLAccountId_Inventory"].Value = customerAndGroupAccountFormUI.Tbl_GLAccountId_Inventory;

                sqlCmd.Parameters.Add("@tbl_GLAccountId_AccuralDifferedA_C", SqlDbType.NVarChar);
                sqlCmd.Parameters["@tbl_GLAccountId_AccuralDifferedA_C"].Value = customerAndGroupAccountFormUI.Tbl_GLAccountId_AccuralDifferedA_C;

                result = sqlCmd.ExecuteNonQuery();

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

            log.Error("[CustomerAndGroupAccountFormDAL : AddCustomerAndGroupAccount] An error occured in the processing of Record. Details : [" + exp.ToString() + "]");
        }

        return(result);
    }