Ejemplo n.º 1
0
        protected void BtnPostToLedger_Click(object sender, EventArgs e)
        {
            foreach (GridViewRow row in GvJrShow.Rows)
            {
                LDTO.JournalId = Convert.ToInt32(row.Cells[1].Text);
                if (row.Cells[5].Text.ToString() != " ")
                {
                    LDTO.DRAmount = Convert.ToDouble(row.Cells[5].Text);
                    LDTO.CRAmount = null;
                }

                if (row.Cells[6].Text.ToString() != " ")
                {
                    LDTO.DRAmount = null;
                    LDTO.CRAmount = Convert.ToDouble(row.Cells[6].Text);
                }


                LDTO.CreateBy   = HttpContext.Current.User.Identity.Name;
                LDTO.CreateDate = System.DateTime.Now;



                //start clbal, opbal

                List <COAInfoDTO> coa = new List <COAInfoDTO>();
                coa = CBLL.LoadCoAInfo(Convert.ToInt32(row.Cells[10].Text), "", "", 0, "", "", "", "", "", "");
                double?balance;
                if (coa.First().Balance != null)
                {
                    balance = coa.First().Balance;
                }
                else
                {
                    balance = 0;
                }
                List <LedgerDTO> ld = new List <LedgerDTO>();
                ld = LBLL.LoadLedgerData(0, 0, Convert.ToInt32(row.Cells[10].Text));
                double?opbal;
                double?clbal;
                double?dramoun  = 0;
                double?cramount = 0;
                if (ld.Count != 0)
                {
                    if (ld.First().OPBAL != null)
                    {
                        opbal = ld.First().OPBAL;
                    }
                    else
                    {
                        opbal = 0;
                    }
                    if (ld.First().CLBAL != null)
                    {
                        clbal = ld.First().CLBAL;
                    }
                    else
                    {
                        clbal = 0;
                    }

                    if (ld.First().DRAmount != null)
                    {
                        dramoun = ld.First().DRAmount;
                    }
                    else
                    {
                        dramoun = 0;
                    }

                    if (ld.First().CRAmount != null)
                    {
                        cramount = ld.First().CRAmount;
                    }
                    else
                    {
                        cramount = 0;
                    }


                    LDTO.OPBAL = clbal;
                    if (row.Cells[5].Text.ToString() != "&nbsp;")
                    {
                        LDTO.CLBAL = clbal + Convert.ToDouble(row.Cells[5].Text);
                    }
                    if (row.Cells[6].Text.ToString() != "&nbsp;")
                    {
                        LDTO.CLBAL = clbal + Convert.ToDouble(row.Cells[6].Text);
                    }
                }

                else
                {
                    LDTO.OPBAL = balance;
                    if (row.Cells[5].Text.ToString() != "&nbsp;")
                    {
                        LDTO.CLBAL = balance + Convert.ToDouble(row.Cells[5].Text);
                    }
                    if (row.Cells[6].Text.ToString() != "&nbsp;")
                    {
                        LDTO.CLBAL = balance + Convert.ToDouble(row.Cells[6].Text);
                    }
                }

                // end of clbal,opbal

                CDTO.COAId   = Convert.ToInt32(row.Cells[10].Text);
                CDTO.Balance = LDTO.CLBAL;
                CBLL.Edit_COAUpdate(CDTO);

                JDTO.JournalId         = Convert.ToInt32(row.Cells[1].Text);
                JDTO.PostLeadgerStatus = "Y";
                JBLL.Edit_JournalUpdate(JDTO);

                LBLL.Add(LDTO);
            }

            PanelGVShow.Visible = false;
            PanelEntity.Visible = false;
            int TransectionNo;

            TransectionNo = Convert.ToInt32(HFTransectionNo.Value);
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", "window.open('/AccSysManagment/AccountingReport/JournalUpdateRptUI.aspx?TransectionNo=" + TransectionNo.ToString() + "');", true);
            PanleAdd.Visible = false;
            pagingLoal();
        }
Ejemplo n.º 2
0
        protected void BtnSave_Click(object sender, EventArgs e)
        {
            DataTable dt    = (DataTable)ViewState["CurrentData"];
            int       count = dt.Rows.Count;

            int    rowCount = 0;
            double drAmount = 0;
            double crAmount = 0;

            rowCount = GvJrEntry.Rows.Count;
            for (int i = 0; i < rowCount; i++)
            {
                if (Convert.ToString(dt.Rows[i][1]) == "DR")
                {
                    drAmount = drAmount + Convert.ToDouble(dt.Rows[i][6]);
                }
                else
                {
                    crAmount = crAmount + Convert.ToDouble(dt.Rows[i][6]);
                }
            }


            if (Convert.ToInt32(drAmount) != Convert.ToInt32(crAmount))
            {
                lblCheckDRC_R.Visible = true;
                lblCheckDRC_R.Text    = "Please Check DR. & CR. Amount";
            }
            else
            {
                // Start for LOG File Journal Update In Ladger page
                for (int i = 0; i < count; i++)
                {
                    string logField    = "";
                    var    Journalinfo = JBLL.LoadJournalUpdate_ladger(Convert.ToInt32(dt.Rows[i][0]), 0);
                    if (Convert.ToString(dt.Rows[i][4]) != Journalinfo.First().SubCode2Id.ToString())
                    {
                        logField += "SubCode2Id" + "-" + Journalinfo.First().SubCode2Id.ToString() + "#" + dt.Rows[i][4] + ";";
                    }
                    if (Convert.ToString(dt.Rows[i][2]) != Journalinfo.First().COAId.ToString())
                    {
                        logField += "COAId" + "-" + Journalinfo.First().COAId.ToString() + "#" + dt.Rows[i][2] + ";";
                    }
                    if (Convert.ToString(dt.Rows[i][9]) != Journalinfo.First().SubVoucherId.ToString())
                    {
                        logField += "SubVoucherId" + "-" + Journalinfo.First().SubVoucherId.ToString() + "#" + dt.Rows[i][9] + ";";
                    }
                    if (Convert.ToString(dt.Rows[i][1]) != Journalinfo.First().JournalType.ToString())
                    {
                        logField += "JournalType" + "-" + Journalinfo.First().JournalType.ToString() + "#" + dt.Rows[i][1] + ";";
                    }
                    if (Convert.ToString(dt.Rows[i][1]) == "DR")
                    {
                        if (Convert.ToString(dt.Rows[i][6]) != Journalinfo.First().DRAmount.ToString()) // problem
                        {
                            logField += "DRAmount" + "-" + Journalinfo.First().DRAmount.ToString() + "#" + dt.Rows[i][6] + ";";
                        }
                    }
                    else
                    {
                        if (Convert.ToString(dt.Rows[i][6]) != Journalinfo.First().CRAmount.ToString()) // problem
                        {
                            logField += "CRAmount" + "-" + Journalinfo.First().CRAmount.ToString() + "#" + dt.Rows[i][6] + ";";
                        }
                    }

                    if (txtTransectionDate.Text != Journalinfo.First().TransectionDate.ToString())
                    {
                        logField += "TransectionDate" + "-" + Journalinfo.First().TransectionDate.ToString() + "#" + txtTransectionDate.Text + ";";
                    }

                    if (Convert.ToString(dt.Rows[i][7]) != Journalinfo.First().VONO.ToString()) // problem
                    {
                        logField += "VONO" + "-" + Journalinfo.First().VONO.ToString() + "#" + dt.Rows[i][7] + ";";
                    }
                    if (Convert.ToString(dt.Rows[i][8]) != Journalinfo.First().MRNO.ToString()) // problem
                    {
                        logField += "MRNO" + "-" + Journalinfo.First().MRNO.ToString() + "#" + dt.Rows[i][8] + ";";
                    }
                    if (Convert.ToString(dt.Rows[i][11]) != Journalinfo.First().Remarks.ToString()) // problem
                    {
                        logField += "Remarks" + "-" + Journalinfo.First().Remarks.ToString() + "#" + dt.Rows[i][11] + ";";
                    }

                    if (logField.Length > 0)
                    {
                        logField       = " JournalId" + "-" + Convert.ToInt32(dt.Rows[i][0]) + ";" + logField;
                        JLDTO.LogField = logField;
                        JLDTO.LogDate  = System.DateTime.Now;
                        JLDTO.LogBy    = "ABHI";
                        JLBLL.AddLogAccJournal(JLDTO);
                    }
                }
                // End for LOG File Journal Update In Ladger page

                for (int i = 0; i < count; i++)
                {
                    JDTO.JournalId    = Convert.ToInt32(dt.Rows[i][0]);
                    JDTO.SubCode2Id   = Convert.ToInt32(dt.Rows[i][4]);
                    JDTO.COAId        = Convert.ToInt32(dt.Rows[i][2]);
                    JDTO.SubVoucherId = Convert.ToInt32(dt.Rows[i][9]);
                    JDTO.JournalType  = Convert.ToString(dt.Rows[i][1]);
                    if (Convert.ToString(dt.Rows[i][1]) == "DR")
                    {
                        JDTO.DRAmount = Convert.ToInt32(dt.Rows[i][6]);
                        JDTO.CRAmount = null;
                    }
                    else
                    {
                        JDTO.DRAmount = null;
                        JDTO.CRAmount = Convert.ToInt32(dt.Rows[i][6]);
                    }
                    JDTO.VONO          = Convert.ToString(dt.Rows[i][7]);
                    JDTO.MRNO          = Convert.ToString(dt.Rows[i][8]);
                    JDTO.Remarks       = Convert.ToString(dt.Rows[i][11]);
                    JDTO.TransectionNo = Convert.ToInt32(dt.Rows[i][12]);
                    if (txtTransectionDate.Text == "Today")
                    {
                        JDTO.TransectionDate = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                    }
                    else
                    {
                        JDTO.TransectionDate = Convert.ToDateTime(txtTransectionDate.Text.ToString());
                    }
                    JDTO.PostLeadgerStatus = "Y";
                    JDTO.UpdateBy          = HttpContext.Current.User.Identity.Name;
                    JDTO.UpdateDate        = System.DateTime.Now;
                    JBLL.Edit(JDTO);
                }


                // insert in to ledger
                for (int i = 0; i < count; i++)
                {
                    LDTO.JournalId = Convert.ToInt32(dt.Rows[i][0]);
                    //  LDTO.OPBAL = 0;
                    if (Convert.ToString(dt.Rows[i][1]) == "DR")
                    {
                        LDTO.DRAmount = Convert.ToDouble(dt.Rows[i][6]);
                        LDTO.CRAmount = null;
                    }
                    else
                    {
                        LDTO.DRAmount = null;
                        LDTO.CRAmount = Convert.ToDouble(dt.Rows[i][6]);
                    }

                    //  LDTO.CLBAL = 0;
                    LDTO.CreateBy   = HttpContext.Current.User.Identity.Name;
                    LDTO.CreateDate = System.DateTime.Now;

                    //start clbal, opbal

                    List <COAInfoDTO> coa = new List <COAInfoDTO>();
                    coa = CBLL.LoadCoAInfo(Convert.ToInt32(dt.Rows[i][2]), "", "", 0, "", "", "", "", "", "");
                    double?balance;
                    if (coa.First().Balance != null)
                    {
                        balance = coa.First().Balance;
                    }
                    else
                    {
                        balance = 0;
                    }
                    List <LedgerDTO> ld = new List <LedgerDTO>();
                    ld = LBLL.LoadLedgerData(0, 0, Convert.ToInt32(dt.Rows[i][2]));
                    double?opbal;
                    double?clbal;
                    double?dramoun  = 0;
                    double?cramount = 0;
                    if (ld.Count != 0)
                    {
                        if (ld.First().OPBAL != null)
                        {
                            opbal = ld.First().OPBAL;
                        }
                        else
                        {
                            opbal = 0;
                        }
                        if (ld.First().CLBAL != null)
                        {
                            clbal = ld.First().CLBAL;
                        }
                        else
                        {
                            clbal = 0;
                        }

                        if (ld.First().DRAmount != null)
                        {
                            dramoun = ld.First().DRAmount;
                        }
                        else
                        {
                            dramoun = 0;
                        }

                        if (ld.First().CRAmount != null)
                        {
                            cramount = ld.First().CRAmount;
                        }
                        else
                        {
                            cramount = 0;
                        }


                        LDTO.OPBAL = clbal;

                        LDTO.CLBAL = clbal + Convert.ToDouble(dt.Rows[i][6]);
                    }

                    else
                    {
                        LDTO.OPBAL = balance;
                        if (Convert.ToString(dt.Rows[i][1]) == "DR")
                        {
                            LDTO.CLBAL = balance + Convert.ToDouble(dt.Rows[i][6]);
                        }
                        else
                        {
                            LDTO.CLBAL = balance + Convert.ToDouble(dt.Rows[i][6]);
                        }
                    }

                    // end of clbal,opbal
                    CDTO.COAId   = Convert.ToInt32(dt.Rows[i][2]);
                    CDTO.Balance = LDTO.CLBAL;
                    CBLL.Edit_COAUpdate(CDTO);
                    LBLL.Add(LDTO);
                }
                CLearContorl();



                int TransectionNo;
                TransectionNo = Convert.ToInt32(HFTransectionNo.Value);
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", "window.open('AccSysManagment/AccountingReport/JournalUpdateRptUI.aspx?TransectionNo=" + TransectionNo.ToString() + "');", true);
                pagingLoal();
            }
        }