Ejemplo n.º 1
0
    void GetGroupDetails()
    {
        if (Level == 5)
        {
        }
        else if (Level == 4)
        {
            LabelErrorMessage.Text = "Can not create more groups, must select account";
            return;
        }
        else if (Level == 3)
        {
            string P   = "";
            char   pad = '0';
            Int16  ii  = Convert.ToInt16(Level4);
            ii += 1;
            P   = ii.ToString();
            P   = P.PadLeft(Level4.Length, pad);

            COAChartCode = Level1 + Level2 + Level3 + P + Level5;
            Level        = 4;
        }
        else if (Level == 2)
        {
            string P   = "";
            char   pad = '0';
            Int16  ii  = Convert.ToInt16(Level3);
            ii += 1;
            P   = ii.ToString();
            P   = P.PadLeft(Level3.Length, pad);

            COAChartCode = Level1 + Level2 + P + Level4 + Level5;
            Level        = 3;
        }
        else if (Level == 1)
        {
            string P   = "";
            char   pad = '0';
            Int16  ii  = Convert.ToInt16(Level2);
            ii += 1;
            P   = ii.ToString();
            P   = P.PadLeft(Level2.Length, pad);

            COAChartCode = Level1 + P + Level3 + Level4 + Level5;
            Level        = 2;
        }
        TxtNewAccountNo.Text = COAChartCode.ToString();
        ChartCat             = "T" + Level1.ToString();
    }
Ejemplo n.º 2
0
    protected void BtnAddGroup_Click(object sender, EventArgs e)
    {
        if (_Typelist.SelectedValue == "0")
        {
            LastLevel = "N";
        }
        else
        {
            LastLevel = "W";
        }
        Class1 queryResult = new Class1();

        try
        {
            accountantCls.Cmd.Connection.ConnectionString = accountantCls.GetConnStr();
            accountantCls.Cmd.CommandType = CommandType.StoredProcedure;
            accountantCls.Cmd.CommandText = "USP_ChartOfAccount_Save";
            accountantCls.Cmd.Parameters.Add("@ChartId", SqlDbType.Int).Value            = 0;
            accountantCls.Cmd.Parameters.Add("@CompanyId", SqlDbType.Int).Value          = Session["CompanyId"];
            accountantCls.Cmd.Parameters.Add("@COAChartName", SqlDbType.NVarChar).Value  = _LedgerNameText.Text;
            accountantCls.Cmd.Parameters.Add("@ParentChartID", SqlDbType.NVarChar).Value = ParentChartID.ToString();
            accountantCls.Cmd.Parameters.Add("@ChartLevel", SqlDbType.NVarChar).Value    = Level;
            accountantCls.Cmd.Parameters.Add("@COAChartCode", SqlDbType.NVarChar).Value  = COAChartCode.ToString();
            accountantCls.Cmd.Parameters.Add("@ChartCat", SqlDbType.NVarChar).Value      = "T1";
            accountantCls.Cmd.Parameters.Add("@LastLevel", SqlDbType.NVarChar).Value     = LastLevel;
            accountantCls.Cmd.Parameters.Add("@AccountType", SqlDbType.NVarChar).Value   = _Typelist.SelectedValue;
            if (ChartId == 0)
            {
                accountantCls.Cmd.Parameters.Add("@UserId", SqlDbType.Int).Value = Session["UserCode"].ToString();
            }
            else
            {
                accountantCls.Cmd.Parameters.Add("@UserId", SqlDbType.Int).Value = Session["UserCode"].ToString();
            }
            queryResult.ErrorNo = 0;
            accountantCls.beginTrans();
            queryResult.RecordId = Convert.ToInt32(accountantCls.Cmd.ExecuteNonQuery());
            accountantCls.commitTrans();
            if (queryResult.RecordId == 0)
            {
                queryResult.ErrorNo       = -1;
                queryResult.ErrorDesc     = Resources.ResourceMain.ChartAlreadyExists;
                queryResult.ErrorFunction = " Finance.DAL.ChartOfAccount.SaveGroup";
            }
            else if (queryResult.RecordId == -1)
            {
                queryResult.ErrorNo       = -1;
                queryResult.ErrorDesc     = Resources.ResourceMain.EndOfLevel;
                queryResult.ErrorFunction = " Finance.DAL.ChartOfAccount.SaveGroup";
            }
            //accountantCls.Cmd.CommandType = CommandType.Text;
            //accountantCls.Cmd.CommandText = "select COAChartCode From tChartOfAccounts where ChartId = " + queryResult.RecordId;
            //queryResult.OtherData = accountantCls.Cmd.ExecuteScalar();

            LabelErrorMessage.Text = "Saved Successfully";
            Clear();
        }
        catch (Exception ex)
        {
            accountantCls.rollBackTrans();
            queryResult.ErrorDesc     = ex.Message;
            queryResult.ErrorNo       = -1;
            queryResult.ErrorFunction = " Finance.DAL.ChartOfAccount.SaveGroup";
        }
    }