Esempio n. 1
0
    protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
    {
        SegCoa segcoa = SegCoaManager.getSegCoa(TreeView1.SelectedNode.Value.ToString());

        if (segcoa != null)
        {
            txtSegCode.Text              = segcoa.GlSegCode;
            txtSegDesc.Text              = segcoa.SegCoaDesc;
            ddlAccType.SelectedValue     = segcoa.AccType;
            ddlBudAllowed.SelectedValue  = segcoa.BudAllowed;
            txtLvlCode.Text              = segcoa.LvlCode;
            txtOpenDate.Text             = segcoa.OpenDate;
            txtParentCode.Text           = segcoa.ParentCode;
            ddlPostAllowed.SelectedValue = segcoa.PostAllowed;
            ddlRootLeaf.SelectedValue    = segcoa.RootLeaf;
            ddlTaxable.SelectedValue     = segcoa.Taxable;
            ddlStatus.SelectedValue      = segcoa.Status;

            foreach (GridViewRow gvr in dgGlCoaGen.Rows)
            {
                string           lvl = "";
                string           connectionString = DataManager.OraConnString();
                OracleDataReader dReader;
                OracleConnection conn = new OracleConnection();
                conn.ConnectionString = connectionString;
                OracleCommand cmd = new OracleCommand();
                cmd             = new OracleCommand();
                cmd.Connection  = conn;
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "select lvl_code from gl_level_type where lvl_desc='" + gvr.Cells[0].Text.ToString().Trim() + "'";
                conn.Open();
                dReader = cmd.ExecuteReader();
                if (dReader.HasRows == true)
                {
                    while (dReader.Read())
                    {
                        lvl = dReader["lvl_code"].ToString();
                    }
                }
                if (lvl == segcoa.LvlCode)
                {
                    gvr.Cells[1].Text = segcoa.GlSegCode;
                    gvr.Cells[2].Text = segcoa.SegCoaDesc;
                }
            }
            lblTransStatus.Text = "";
        }
    }
Esempio n. 2
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     System.Threading.Thread.Sleep(3000);
     if (txtSegCode.Text != "")
     {
         SegCoa sgcoa = SegCoaManager.getSegCoa(txtSegCode.Text);
         if (sgcoa != null)
         {
             sgcoa.SegCoaDesc  = txtSegDesc.Text;
             sgcoa.RootLeaf    = ddlRootLeaf.SelectedValue;
             sgcoa.Taxable     = ddlTaxable.SelectedValue;
             sgcoa.Status      = ddlStatus.SelectedValue;
             sgcoa.PostAllowed = ddlPostAllowed.SelectedValue;
             sgcoa.ParentCode  = txtParentCode.Text;
             sgcoa.OpenDate    = txtOpenDate.Text;
             sgcoa.LvlCode     = txtLvlCode.Text;
             sgcoa.BudAllowed  = ddlBudAllowed.SelectedValue;
             sgcoa.AccType     = ddlAccType.SelectedValue;
             SegCoaManager.UpdateSegCoa(sgcoa);
         }
         else
         {
             sgcoa             = new SegCoa();
             sgcoa.GlSegCode   = txtSegCode.Text;
             sgcoa.BookName    = Session["book"].ToString();
             sgcoa.SegCoaDesc  = txtSegDesc.Text;
             sgcoa.RootLeaf    = ddlRootLeaf.SelectedValue;
             sgcoa.Taxable     = ddlTaxable.SelectedValue;
             sgcoa.Status      = ddlStatus.SelectedValue;
             sgcoa.PostAllowed = ddlPostAllowed.SelectedValue;
             sgcoa.ParentCode  = txtParentCode.Text;
             sgcoa.OpenDate    = txtOpenDate.Text;
             sgcoa.LvlCode     = txtLvlCode.Text;
             sgcoa.BudAllowed  = ddlBudAllowed.SelectedValue;
             sgcoa.AccType     = ddlAccType.SelectedValue;
             SegCoaManager.CreateSegCoa(sgcoa);
         }
         TreeView1.Nodes.Clear();
         Populate();
         TreeNode node = TreeView1.FindNode(Server.HtmlEncode(txtParentCode.Text));
         if (node != null)
         {
             node.Expand();
         }
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ale", "alert('***Segment Codes Saved in Database Successfully!!');", true);
         //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ale", "alert('***Segment Codes Saved in Database Successfully!!');", true);
     }
 }
Esempio n. 3
0
    public void PopChild(string segcode, TreeNode node)
    {
        DataTable dt = SegCoaManager.GetSegCoaChild("parent_code='" + segcode + "' order by to_number(seg_coa_code)");
        TreeNode  newNode;

        foreach (DataRow dr in dt.Rows)
        {
            newNode       = new TreeNode();
            newNode.Text  = dr["seg_coa_code"].ToString() + " - " + dr["seg_coa_desc"].ToString();
            newNode.Value = dr["seg_coa_code"].ToString();
            //newNode.SelectAction = TreeNodeSelectAction.Expand;
            node.ChildNodes.Add(newNode);
            if (dr["rootleaf"].ToString() == "R")
            {
                PopChild(dr["seg_coa_code"].ToString(), newNode);
            }
        }
    }
Esempio n. 4
0
    public void Populate()
    {
        dtSegParent = SegCoaManager.GetSegCoaAll();
        TreeNode newNode;

        foreach (DataRow row in dtSegParent.Rows)
        {
            newNode       = new TreeNode();
            newNode.Text  = row["seg_coa_code"].ToString() + " - " + row["seg_coa_desc"].ToString();
            newNode.Value = row["seg_coa_code"].ToString();
            //newNode.SelectAction = TreeNodeSelectAction.Expand;
            //node.ChildNodes.Add(newNode);
            TreeView1.Nodes.Add(newNode);

            if (row["rootleaf"].ToString() == "R")
            {
                PopChild(row["seg_coa_code"].ToString(), newNode);
            }
        }
    }
Esempio n. 5
0
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     System.Threading.Thread.Sleep(3000);
     if (txtSegCode.Text != "")
     {
         int coaF = SegCoaManager.getChild(txtSegCode.Text.ToString());
         if (coaF < 1)
         {
             SegCoa sgcoa = SegCoaManager.getSegCoa(txtSegCode.Text.ToString());
             if (sgcoa != null)
             {
                 SegCoaManager.DeleteSegCoa(sgcoa);
                 TreeView1.Nodes.Clear();
                 Populate();
                 ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ale", "alert('***Segment Codes deleted from Database Successfully!!');", true);
                 btnClear_Click(sender, e);
             }
         }
         else
         {
             ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ale", "alert('*** You cannnot delete this segment code while child segment is exist!!');", true);
         }
     }
 }
Esempio n. 6
0
    protected void btnGenCoa_Click(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(3000);
        foreach (GridViewRow gvr in dgGlCoaGen.Rows)
        {
            if (gvr.Cells[1].Text.ToString().Replace("&nbsp;", "").ToString().Trim() == "")
            {
                //lblTransStatus.Visible = true;
                //lblTransStatus.ForeColor = System.Drawing.Color.Red;
                //lblTransStatus.Text = "Please input all segment code in Chart-of-Account Generation table";
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ale", "alert('Please input all segment code in Chart-of-Account Generation table!!');", true);
                return;
            }
        }
        DataTable[] dtm    = new DataTable[dgGlCoaGen.Rows.Count];
        DataTable   dtCoa  = new DataTable();
        string      sepTyp = Session["septyp"].ToString();

        int[]    lvlSize = new int[dgGlCoaGen.Rows.Count];
        string[] lvlcode = new string[dgGlCoaGen.Rows.Count];

        string criteria = "";

        string[] criteriaN = new string[dgGlCoaGen.Rows.Count];
        int      x         = 0;
        int      y         = 0;

        foreach (GridViewRow gvr in dgGlCoaGen.Rows)
        {
            string           connectionString = DataManager.OraConnString();
            OracleDataReader dReader;
            OracleConnection conn = new OracleConnection();
            conn.ConnectionString = connectionString;
            OracleCommand cmd = new OracleCommand();
            cmd             = new OracleCommand();
            cmd.Connection  = conn;
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select lvl_code,lvl_max_size from gl_level_type where lvl_desc='" + gvr.Cells[0].Text.ToString().Trim() + "'";
            if (conn.State != ConnectionState.Open)
            {
                conn.Open();
            }
            dReader = cmd.ExecuteReader();
            if (dReader.HasRows == true)
            {
                while (dReader.Read())
                {
                    lvlSize[x] = int.Parse(dReader["lvl_max_size"].ToString());
                    lvlcode[x] = dReader["lvl_code"].ToString();
                }
            }
            if (conn.State == ConnectionState.Open)
            {
                conn.Close();
            }
            if (x == 0 & gvr.Cells[1].Text.ToString().Replace("&nbsp;", "").ToString().Trim() != String.Empty)
            {
                criteria += "substr(gl_coa_code,instr(gl_coa_code,'" + sepTyp + "',0)+1," + lvlSize[x].ToString() + ") in (SELECT SEG_COA_CODE  FROM GL_SEG_COA S where rootleaf='L' and lvl_code='" + lvlcode[x] + "' CONNECT BY PRIOR SEG_COA_CODE=PARENT_CODE START WITH seg_coa_code = " +
                            " '" + gvr.Cells[1].Text.ToString().Trim() + "')  ";
            }
            else if (x > 0 & gvr.Cells[1].Text.ToString().Replace("&nbsp;", "").ToString().Trim() != String.Empty)
            {
                criteria += "and substr(gl_coa_code,instr(gl_coa_code,'" + sepTyp + "'," + y + ")+1," + lvlSize[x].ToString() + ") in (SELECT SEG_COA_CODE  FROM GL_SEG_COA S where rootleaf='L' and lvl_code='" + lvlcode[x] + "' CONNECT BY PRIOR SEG_COA_CODE=PARENT_CODE START WITH seg_coa_code = " +
                            " '" + gvr.Cells[1].Text.ToString().Trim() + "' )  ";
            }
            criteriaN[x] = "seg_coa_code in (SELECT SEG_COA_CODE  FROM GL_SEG_COA S where rootleaf='L' and lvl_code='" + lvlcode[x] + "' CONNECT BY PRIOR SEG_COA_CODE=PARENT_CODE START WITH seg_coa_code = '" + gvr.Cells[1].Text.ToString().Trim() + "') ";
            dtm[x]       = SegCoaManager.GetSegCoas(criteriaN[x]);

            y = y + lvlSize[x];
            x = x + 1;
        }
        DataTable dtAlready = GlCoaManager.GetGlCoaCode(criteria);

        dtCoa = dtAlready.Clone();

        DataTable dt = new DataTable();

        dt.Columns.Add("seg_coa_code", typeof(string));
        dt.Columns.Add("seg_coa_desc", typeof(string));
        dt.Columns.Add("acc_type", typeof(string));
        DataRow dr;

        for (int i = 0; i < dgGlCoaGen.Rows.Count - 1; i++)
        {
            dt.Clear();
            for (int m = 0; m <= dtm[i].Rows.Count - 1; m++)
            {
                for (int n = 0; n <= dtm[i + 1].Rows.Count - 1; n++)
                {
                    dr = dt.NewRow();
                    dr["seg_coa_code"] = ((DataRow)dtm[i].Rows[m])["seg_coa_code"].ToString().Trim() + sepTyp + ((DataRow)dtm[i + 1].Rows[n])["seg_coa_code"].ToString().Trim();
                    dr["seg_coa_desc"] = ((DataRow)dtm[i].Rows[m])["seg_coa_desc"].ToString().Trim() + ", " + ((DataRow)dtm[i + 1].Rows[n])["seg_coa_desc"].ToString().Trim();
                    if (((DataRow)dtm[i].Rows[m])["acc_type"].ToString().Trim() != "N")
                    {
                        dr["acc_type"] = ((DataRow)dtm[i].Rows[m])["acc_type"].ToString().Trim();
                    }
                    else if (((DataRow)dtm[i + 1].Rows[n])["acc_type"].ToString().Trim() != "N")
                    {
                        dr["acc_type"] = ((DataRow)dtm[i + 1].Rows[n])["acc_type"].ToString().Trim();
                    }
                    dt.Rows.Add(dr);
                }
            }
            dtm[i + 1] = dt.Copy();
        }
        DataRow drCoa;

        foreach (DataRow drC in dtm[dgGlCoaGen.Rows.Count - 1].Rows)
        {
            drCoa = dtCoa.NewRow();
            drCoa["gl_coa_code"] = drC["seg_coa_code"].ToString().Trim();
            drCoa["coa_desc"]    = drC["seg_coa_desc"].ToString().Trim();
            drCoa["acc_type"]    = drC["acc_type"].ToString().Trim();
            drCoa["status"]      = "U";
            dtCoa.Rows.Add(drCoa);
        }
        for (int i = 0; i < dtAlready.Rows.Count; i++)
        {
            for (int j = 0; j < dtCoa.Rows.Count; j++)
            {
                if (((DataRow)dtCoa.Rows[j])["gl_coa_code"].ToString().Trim() == ((DataRow)dtAlready.Rows[i])["gl_coa_code"].ToString().Trim())
                {
                    dtCoa.Rows.RemoveAt(j);
                }
            }
        }
        char sep = Convert.ToChar(Session["septyp"].ToString());

        foreach (DataRow drc in dtCoa.Rows)
        {
            string   mainseg = "";
            string[] segcode = drc["gl_coa_code"].ToString().Split(sep);
            for (int i = 0; i < segcode.Length; i++)
            {
                string a = SegCoaManager.getMainSeg(segcode[i].ToString());
                if (a == "N")
                {
                    mainseg = segcode[i].ToString();
                }
            }
            drc.BeginEdit();
            drc["coa_natural_code"] = mainseg;
            drc.AcceptChanges();
        }

        dgGlCoa.EditIndex = -1;
        if (dtCoa.Rows.Count > 0)
        {
            btnSaveCoa.Visible = true;
            //lblTransStatus.ForeColor = System.Drawing.Color.Orange;
            //lblTransStatus.Text = "***To Save Gl COA Codes in Database Click on SaveCoa Link.***";
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ale", "alert('To Save Gl COA Codes in Database Click on SaveCoa Link!!');", true);
            btnSaveCoa.Visible = true;
        }
        else
        {
            btnSaveCoa.Visible = false;
            //lblTransStatus.ForeColor = System.Drawing.Color.Orange;
            //lblTransStatus.Text = "***Possible Gl COA Codes Are Already in Database.***";
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ale", "alert('Possible Gl COA Codes Are Already in Database!!');", true);
            btnSaveCoa.Visible = false;
        }
        dgGlCoa.DataSource = dtCoa;
        Session["coa"]     = dtCoa;
        dgGlCoa.DataBind();
        foreach (GridViewRow gvr in dgGlCoa.Rows)
        {
            ((LinkButton)gvr.FindControl("lbEdit")).Visible   = false;
            ((LinkButton)gvr.FindControl("lbDelete")).Visible = false;
            ((CheckBox)gvr.FindControl("chkInc")).Visible     = true;
        }
    }