Beispiel #1
0
        public void FillControls()
        {
            try
            {
                AccountLedgerSP   spAccountLedger   = new AccountLedgerSP();
                AccountLedgerInfo accountLedgerInfo = new AccountLedgerInfo();
                accountLedgerInfo            = spAccountLedger.AccountLedgerViewOne(ledgerId);
                txtLedgerName.Text           = accountLedgerInfo.LedgerName;
                cmbGroup.SelectedValue       = accountLedgerInfo.AccountGroupId;
                txtOpeningBalance.Text       = Convert.ToString(accountLedgerInfo.OpeningBalance);
                cmbOpeningBalanceCrOrDr.Text = accountLedgerInfo.CrOrDr;
                if (accountLedgerInfo.Active)
                {
                    chkactive.Checked = true;
                }

                else
                {
                    chkactive.Checked = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Function to fill the grid
        /// </summary>
        public void AccountLedgerReportFill()
        {
            decimal         decTotalClosing = 0;
            AccountLedgerSP SpAccountLedger = new AccountLedgerSP();

            try
            {
                dgvAccountLedgerReport.DataSource = SpAccountLedger.AccountLedgerReportFill(Convert.ToDateTime(txtFromDate.Text), Convert.ToDateTime(txtToDate.Text), Convert.ToDecimal(cmbAccountGroup.SelectedValue.ToString()), Convert.ToDecimal(cmbAccountLedger.SelectedValue.ToString()));
                if (dgvAccountLedgerReport.RowCount > 0)
                {
                    for (int i = 0; i < dgvAccountLedgerReport.RowCount; i++)
                    {
                        decTotalClosing = decTotalClosing + Convert.ToDecimal(dgvAccountLedgerReport.Rows[i].Cells["dgvtxtClosing1"].Value.ToString());
                    }
                }
                if (decTotalClosing < 0)
                {
                    decTotalClosing     = -1 * decTotalClosing;
                    lblTotalAmount.Text = decTotalClosing.ToString() + "Cr";
                }
                else
                {
                    lblTotalAmount.Text = decTotalClosing.ToString() + "Dr";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("ALREP4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #3
0
        public void SaveOrEdit()
        {
            try
            {
                if (txtLedgerName.Text == string.Empty)
                {
                    MessageBox.Show("Enter a ledger name");
                }

                else if (cmbGroup.SelectedIndex == -1)
                {
                    MessageBox.Show("Select an accountGroup");
                }

                else
                {
                    AccountLedgerInfo accountLedgerInfo = new AccountLedgerInfo();
                    AccountLedgerSP   spAccountLedger   = new AccountLedgerSP();
                    accountLedgerInfo.LedgerName     = txtLedgerName.Text.Trim();
                    accountLedgerInfo.AccountGroupId = Convert.ToDecimal(cmbGroup.SelectedValue.ToString());
                    accountLedgerInfo.CrOrDr         = cmbOpeningBalanceCrOrDr.Text;
                    accountLedgerInfo.OpeningBalance = Convert.ToDecimal(txtOpeningBalance.Text.Trim());
                    if (chkactive.Checked)
                    {
                        accountLedgerInfo.Active = true;
                    }

                    else
                    {
                        accountLedgerInfo.Active = false;
                    }

                    if (btnSave.Text == "Save")
                    {
                        if (Messages.SaveConfirmation())
                        {
                            spAccountLedger.AccountLedgerAdd(accountLedgerInfo);
                            ClearFunction();
                            Messages.SavedMessage();
                        }
                    }

                    else
                    {
                        if (Messages.UpdateMessage())
                        {
                            accountLedgerInfo.LedgerId = ledgerId;
                            spAccountLedger.AccountLedgerUpdate(accountLedgerInfo);
                            ClearFunction();
                            Messages.UpdatedMessage();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #4
0
 /// <summary>
 /// Function to fill accountledger combobox
 /// </summary>
 /// <param name="cmbAccountLedger"></param>
 public void AccountLedgerComboFill(ComboBox cmbAccountLedger)
 {
     try
     {
         cmbAccountLedger.Enabled = true;
         AccountLedgerSP spAccountLedger = new AccountLedgerSP();
         spAccountLedger.BillAllocationLedgerFill(cmbAccountLedger, cmbAccountGroup.Text, true);
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "BA3:" + ex.Message;
     }
 }
Beispiel #5
0
 /// <summary>
 /// Function to fill accountledger combobox
 /// </summary>
 /// <param name="cmbAccountLedger"></param>
 public void AccountLedgerComboFill(ComboBox cmbAccountLedger)
 {
     try
     {
         cmbAccountLedger.Enabled = true;
         AccountLedgerSP spAccountLedger = new AccountLedgerSP();
         spAccountLedger.BillAllocationLedgerFill(cmbAccountLedger, cmbAccountGroup.Text, true);
     }
     catch (Exception ex)
     {
         MessageBox.Show("BA:03" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill the grid
 /// </summary>
 public void Gridfill()
 {
     try
     {
         DataTable       dtbl            = new DataTable();
         AccountLedgerSP spAccountLedger = new AccountLedgerSP();
         if (cmbAccountGroup.Text.Trim() == string.Empty)
         {
             cmbAccountGroup.Text = "All";
         }
         if (txtMobile.Text.Trim() == string.Empty)
         {
             txtMobile.Text = "All";
         }
         if (txtPhone.Text.Trim() == string.Empty)
         {
             txtPhone.Text = "All";
         }
         if (txtEmail.Text.Trim() == string.Empty)
         {
             txtEmail.Text = "All";
         }
         if (txtLedgerName.Text.Trim() == string.Empty)
         {
             txtLedgerName.Text = "All";
         }
         if (txtMobile.Text == "All")
         {
             txtMobile.Text = string.Empty;
         }
         if (txtPhone.Text == "All")
         {
             txtPhone.Text = string.Empty;
         }
         if (txtEmail.Text == "All")
         {
             txtEmail.Text = string.Empty;
         }
         if (txtLedgerName.Text == "All")
         {
             txtLedgerName.Text = string.Empty;
         }
         dtbl = spAccountLedger.PartyAddressBookSearch(cmbAccountGroup.Text, txtMobile.Text, txtPhone.Text, txtEmail.Text, txtLedgerName.Text);
         dvgPartyAddressBook.DataSource = dtbl;
     }
     catch (Exception ex)
     {
         MessageBox.Show("PAB:1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #7
0
 /// <summary>
 /// Function to fill the grid
 /// </summary>
 public void Gridfill()
 {
     try
     {
         DataTable       dtbl            = new DataTable();
         AccountLedgerSP spAccountLedger = new AccountLedgerSP();
         if (cmbAccountGroup.Text.Trim() == string.Empty)
         {
             cmbAccountGroup.Text = "All";
         }
         if (txtMobile.Text.Trim() == string.Empty)
         {
             txtMobile.Text = "All";
         }
         if (txtPhone.Text.Trim() == string.Empty)
         {
             txtPhone.Text = "All";
         }
         if (txtEmail.Text.Trim() == string.Empty)
         {
             txtEmail.Text = "All";
         }
         if (txtLedgerName.Text.Trim() == string.Empty)
         {
             txtLedgerName.Text = "All";
         }
         if (txtMobile.Text == "All")
         {
             txtMobile.Text = string.Empty;
         }
         if (txtPhone.Text == "All")
         {
             txtPhone.Text = string.Empty;
         }
         if (txtEmail.Text == "All")
         {
             txtEmail.Text = string.Empty;
         }
         if (txtLedgerName.Text == "All")
         {
             txtLedgerName.Text = string.Empty;
         }
         dtbl = spAccountLedger.PartyAddressBookSearch(cmbAccountGroup.Text, txtMobile.Text, txtPhone.Text, txtEmail.Text, txtLedgerName.Text);
         dvgPartyAddressBook.DataSource = dtbl;
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "PAB1:" + ex.Message;
     }
 }
Beispiel #8
0
        /// <summary>
        /// Function to fill AccountLedgers for combobox
        /// </summary>
        /// <returns></returns>
        public DataTable AccountLedgerComboFill()
        {
            DataTable dtbl = new DataTable();

            try
            {
                AccountLedgerSP spaccountledger = new AccountLedgerSP();
                dtbl = spaccountledger.AccountLedgerViewAll();
            }
            catch (Exception ex)
            {
                MessageBox.Show("legerdComboFill:" + ex.Message, "Niambie School ERP", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(dtbl);
        }
        public List <DataTable> AccountLedgerComboFill()
        {
            List <DataTable> ListObj = new List <DataTable>();

            try
            {
                AccountLedgerSP spAccountLedger = new AccountLedgerSP();
                ListObj = spAccountLedger.AccountLedgerViewAll();
            }
            catch (Exception ex)
            {
                MessageBox.Show("TGFBll:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(ListObj);
        }
Beispiel #10
0
        /// <summary>
        /// Function to fill AccountLedgers for combobox
        /// </summary>
        /// <returns></returns>
        public DataTable AccountLedgerComboFill()
        {
            DataTable dtbl = new DataTable();

            try
            {
                AccountLedgerSP spaccountledger = new AccountLedgerSP();
                dtbl = spaccountledger.AccountLedgerViewAll();
            }
            catch (Exception ex)
            {
                MessageBox.Show("TGF:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(dtbl);
        }
Beispiel #11
0
 /// <summary>
 /// Function to fill ledgers as TreeMode
 /// </summary>
 /// <param name="tn"></param>
 public void FillTree(TreeNode tn)
 {
     try
     {
         DataTable      dtb            = new DataTable();
         AccountGroupSP spAccountGroup = new AccountGroupSP();
         dtb = spAccountGroup.AccountGroupViewAllByGroupUnder(Convert.ToDecimal(tn.Name));
         AccountLedgerSP ledgerSP = new AccountLedgerSP();
         if (dtb.Rows.Count > 0)
         {
             foreach (DataRow dr in dtb.Rows)
             {
                 tn.Nodes.Add(dr["accountGroupId"].ToString(), dr["accountGroupName"].ToString());
                 tn.ExpandAll();
                 if (tn.LastNode != null)
                 {
                     tn.LastNode.ForeColor = Color.Red;
                 }
                 else
                 {
                     tn.LastNode.ForeColor = Color.Blue;
                 }
             }
             foreach (TreeNode tn1 in tn.Nodes)
             {
                 FillTree(tn1);
                 DataTable dtb1 = ledgerSP.AccountLedgerViewAllByLedgerName(Convert.ToDecimal(tn1.Name));
                 foreach (DataRow dr in dtb1.Rows)
                 {
                     tn1.Nodes.Add(dr["ledgerId"].ToString(), dr["ledgerName"].ToString());
                     tn1.ExpandAll();
                     if (tn1.LastNode != null)
                     {
                         tn1.LastNode.ForeColor = Color.Blue;
                     }
                     else
                     {
                         tn.LastNode.ForeColor = Color.Red;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "COA1:" + ex.Message;
     }
 }
        /// <summary>
        /// Function to print the report
        /// </summary>
        public void Print()
        {
            AccountLedgerSP SpAccountLedger = new AccountLedgerSP();

            try
            {
                DataSet   dsAccountLedgerReport = SpAccountLedger.AccountLedgerReportPrinting(1, dtFromDate, dtTodate, decAccountGroupId, decLedgerId);
                frmReport frmReport             = new frmReport();
                frmReport.MdiParent = formMDI.MDIObj;
                frmReport.AccountLedgerReportPrinting(dsAccountLedgerReport);
            }
            catch (Exception ex)
            {
                formMDI.infoError.ErrorString = "ALREP5:" + ex.Message;
            }
        }
Beispiel #13
0
 /// <summary>
 /// account group combo fill function
 /// </summary>
 public void cmbComboFill()
 {
     try
     {
         AccountLedgerSP spAccountLedger   = new AccountLedgerSP();
         DataTable       dtblAccountLedger = new DataTable();
         dtblAccountLedger             = spAccountLedger.MultipleAccountLedgerComboFill();
         cmbAccountGroup.DataSource    = dtblAccountLedger;
         cmbAccountGroup.ValueMember   = "accountGroupId";
         cmbAccountGroup.DisplayMember = "accountGroupName";
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "MAL1:" + ex.Message;
     }
 }
Beispiel #14
0
        /// <summary>
        /// Function to print the report
        /// </summary>
        public void Print()
        {
            AccountLedgerSP SpAccountLedger = new AccountLedgerSP();

            try
            {
                DataSet dsAccountLedgerReport = SpAccountLedger.AccountLedgerReportPrinting(1, dtFromDate, dtTodate, decAccountGroupId, decLedgerId);
                ////frmReport //frmReport = new frmReport();
                //frmReport.MdiParent = formMDI.MDIObj;
                //    frmreport.AccountLedgerReportPrinting(dsAccountLedgerReport);
            }
            catch (Exception ex)
            {
                MessageBox.Show("ALREP5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #15
0
 /// <summary>
 /// account group combo fill function
 /// </summary>
 public void cmbComboFill()
 {
     try
     {
         AccountLedgerSP spAccountLedger   = new AccountLedgerSP();
         DataTable       dtblAccountLedger = new DataTable();
         dtblAccountLedger             = spAccountLedger.MultipleAccountLedgerComboFill();
         cmbAccountGroup.DataSource    = dtblAccountLedger;
         cmbAccountGroup.ValueMember   = "accountGroupId";
         cmbAccountGroup.DisplayMember = "accountGroupName";
     }
     catch (Exception ex)
     {
         MessageBox.Show("MAL1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #16
0
 /// <summary>
 /// BankAccount Combobox fill function
 /// </summary>
 public void bankAccountComboFill()
 {
     try
     {
         DataTable               dtbl            = new DataTable();
         AccountLedgerSP         spAccountLedger = new AccountLedgerSP();
         TransactionsGeneralFill obj             = new TransactionsGeneralFill();
         dtbl = obj.BankComboFill();
         cmbBankAccount.DataSource    = dtbl;
         cmbBankAccount.ValueMember   = "ledgerId";
         cmbBankAccount.DisplayMember = "ledgerName";
         cmbBankAccount.SelectedIndex = -1;
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "BR2:" + ex.Message;
     }
 }
Beispiel #17
0
 /// <summary>
 /// BankAccount Combobox fill function
 /// </summary>
 public void bankAccountComboFill()
 {
     try
     {
         DataTable               dtbl            = new DataTable();
         AccountLedgerSP         spAccountLedger = new AccountLedgerSP();
         TransactionsGeneralFill obj             = new TransactionsGeneralFill();
         dtbl = obj.BankComboFill();
         cmbBankAccount.DataSource    = dtbl;
         cmbBankAccount.ValueMember   = "ledgerId";
         cmbBankAccount.DisplayMember = "ledgerName";
         cmbBankAccount.SelectedIndex = -1;
     }
     catch (Exception ex)
     {
         MessageBox.Show("BR:2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill the accountledger combbox
 /// </summary>
 public void AccountLedgerComboFill()
 {
     try
     {
         AccountLedgerSP spAccountLedger   = new AccountLedgerSP();
         DataTable       dtblAccountLedger = new DataTable();
         dtblAccountLedger = spAccountLedger.AccountLedgerViewByAccountGroup(Convert.ToDecimal(cmbAccountGroup.SelectedValue.ToString()));
         DataRow dr = dtblAccountLedger.NewRow();
         dr["ledgerName"] = "All";
         dr["ledgerId"]   = 0;
         dtblAccountLedger.Rows.InsertAt(dr, 0);
         cmbAccountLedger.DataSource    = dtblAccountLedger;
         cmbAccountLedger.ValueMember   = "ledgerId";
         cmbAccountLedger.DisplayMember = "ledgerName";
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "ALREP3:" + ex.Message;
     }
 }
Beispiel #19
0
 /// <summary>
 /// Function to fill the accountledger combbox
 /// </summary>
 public void AccountLedgerComboFill()
 {
     try
     {
         AccountLedgerSP spAccountLedger   = new AccountLedgerSP();
         DataTable       dtblAccountLedger = new DataTable();
         dtblAccountLedger = spAccountLedger.AccountLedgerViewByAccountGroup(Convert.ToDecimal(cmbAccountGroup.SelectedValue.ToString()));
         DataRow dr = dtblAccountLedger.NewRow();
         dr["ledgerName"] = "All";
         dr["ledgerId"]   = 0;
         dtblAccountLedger.Rows.InsertAt(dr, 0);
         cmbAccountLedger.DataSource    = dtblAccountLedger;
         cmbAccountLedger.ValueMember   = "ledgerId";
         cmbAccountLedger.DisplayMember = "ledgerName";
     }
     catch (Exception ex)
     {
         MessageBox.Show("ALREP3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #20
0
 /// <summary>
 /// Function to fill AccountLedger combobox
 /// </summary>
 public void AccountLedgerComboFill()
 {
     try
     {
         DataTable       dtbl            = new DataTable();
         AccountLedgerSP spaccountledger = new AccountLedgerSP();
         dtbl = spaccountledger.AccountLedgerViewAll();
         DataRow dr = dtbl.NewRow();
         dr[0] = 0;
         dr[2] = "ALL";
         dtbl.Rows.InsertAt(dr, 0);
         cmbAccountLedger.DataSource    = dtbl;
         cmbAccountLedger.ValueMember   = "ledgerId";
         cmbAccountLedger.DisplayMember = "ledgerName";
         cmbAccountLedger.SelectedIndex = 0;
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "DRNTREP3:" + ex.Message;
     }
 }
 /// <summary>
 /// Function to fill AccountLedger combobox
 /// </summary>
 public void AccountLedgerComboFill()
 {
     try
     {
         DataTable       dtbl            = new DataTable();
         AccountLedgerSP spaccountledger = new AccountLedgerSP();
         dtbl = spaccountledger.AccountLedgerViewAll();
         DataRow dr = dtbl.NewRow();
         dr[0] = 0;
         dr[2] = "All";
         dtbl.Rows.InsertAt(dr, 0);
         cmbAccountLedger.DataSource    = dtbl;
         cmbAccountLedger.ValueMember   = "ledgerId";
         cmbAccountLedger.DisplayMember = "ledgerName";
         cmbAccountLedger.SelectedIndex = -1;
     }
     catch (Exception ex)
     {
         MessageBox.Show("PPREP2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #22
0
 /// <summary>
 /// Function to print partyaddress book
 /// </summary>
 public void Print()
 {
     try
     {
         if (dvgPartyAddressBook.RowCount > 0)
         {
             DataSet         ds              = new DataSet();
             CompanySP       spCompany       = new CompanySP();
             frmReport       reportobj       = new frmReport();
             AccountLedgerSP spAccountLedger = new AccountLedgerSP();
             DataTable       dtblCompany     = spCompany.CompanyViewDataTable(1);
             DataTable       dtbl            = spAccountLedger.PartyAddressBookPrint(cmbAccountGroup.Text, txtMobile.Text, txtPhone.Text, txtEmail.Text, txtLedgerName.Text);
             ds.Tables.Add(dtblCompany);
             ds.Tables.Add(dtbl);
             reportobj.MdiParent = formMDI.MDIObj;
             reportobj.PartyAddressBookPrint(ds);
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "PAB3:" + ex.Message;
     }
 }
 /// <summary>
 /// Function to print partyaddress book
 /// </summary>
 public void Print()
 {
     try
     {
         if (dvgPartyAddressBook.RowCount > 0)
         {
             DataSet   ds        = new DataSet();
             CompanySP spCompany = new CompanySP();
             //frmReport reportobj = new frmReport();
             AccountLedgerSP spAccountLedger = new AccountLedgerSP();
             DataTable       dtblCompany     = spCompany.CompanyViewDataTable(1);
             DataTable       dtbl            = spAccountLedger.PartyAddressBookPrint(cmbAccountGroup.Text, txtMobile.Text, txtPhone.Text, txtEmail.Text, txtLedgerName.Text);
             ds.Tables.Add(dtblCompany);
             ds.Tables.Add(dtbl);
             //    frmreport.MdiParent = formMDI.MDIObj;
             //    frmreport.PartyAddressBookPrint(ds);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PAB:3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #24
0
        /// <summary>
        /// check if data present in database
        /// </summary>
        /// <returns></returns>
        public bool CheckAlreadyExist()
        {
            bool isOk = true;

            try
            {
                AccountLedgerSP spAccountledger = new AccountLedgerSP();
                int             inCompleteRow   = 0;
                int             inCurrentindex  = 0;
                string          strMessage      = "Row";
                foreach (DataGridViewRow dgvRow in dgvMultipleAccountLedger.Rows)
                {
                    if (dgvRow.Cells["dgvtxtLedgerName"].Value != null)
                    {
                        string LedgerName = dgvRow.Cells["dgvtxtLedgerName"].Value.ToString();
                        if (spAccountledger.AccountLedgerCheckExistence(LedgerName, 0) == true)
                        {
                            isOk = false;
                            if (inCompleteRow == 0)
                            {
                                strMessage     = strMessage + Convert.ToString(dgvRow.Index + 1);
                                inCurrentindex = dgvRow.Index;
                                inCompleteRow++;
                            }
                            else
                            {
                                strMessage = strMessage + ", " + Convert.ToString(dgvRow.Index + 1);
                            }
                        }
                    }
                }
                if (!isOk)
                {
                    strMessage = strMessage + " contains already exisitng ledgers. Do you want to continue?";
                    if (MessageBox.Show(strMessage, "OpenMiracle", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                    {
                        isOk = true;
                        for (int inK = 0; inK < dgvMultipleAccountLedger.Rows.Count; inK++)
                        {
                            if (dgvMultipleAccountLedger.Rows[inK].Cells["dgvtxtLedgerName"].Value != null)
                            {
                                string strLedgerName = dgvMultipleAccountLedger.Rows[inK].Cells["dgvtxtLedgerName"].Value.ToString().Trim();
                                if (spAccountledger.AccountLedgerCheckExistence(strLedgerName, 0) == true)
                                {
                                    if (!dgvMultipleAccountLedger.Rows[inK].IsNewRow)
                                    {
                                        dgvMultipleAccountLedger.Rows.RemoveAt(inK);
                                        inK--;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        dgvMultipleAccountLedger.Rows[inCurrentindex].Cells["dgvtxtLedgerName"].Selected = true;
                        dgvMultipleAccountLedger.CurrentCell = dgvMultipleAccountLedger.Rows[inCurrentindex].Cells["dgvtxtLedgerName"];
                        dgvMultipleAccountLedger.Focus();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("MAL5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            return(isOk);
        }
Beispiel #25
0
        /// <summary>
        /// Save data to the database
        /// </summary>
        public void SaveFunction()
        {
            try
            {
                int               inRowcount        = dgvMultipleAccountLedger.RowCount;//edited by Runali
                int               inRowcountDec     = (dgvMultipleAccountLedger.RowCount) - 1;
                decimal           decOpeningBalance = 0;
                decimal           decLedgerId       = 0;
                bool              isSave            = false;
                AccountLedgerInfo infoAccountledger = new AccountLedgerInfo();
                AccountLedgerSP   spAccountledger   = new AccountLedgerSP();
                LedgerPostingSP   spLedgerPosting   = new LedgerPostingSP();
                LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo();
                FinancialYearSP   spFinancialYear   = new FinancialYearSP();
                FinancialYearInfo infoFinancialYear = new FinancialYearInfo();

                for (int i = 0; i < inRowcount - 1; i++)
                {
                    infoAccountledger.AccountGroupId = Convert.ToDecimal(cmbAccountGroup.SelectedValue.ToString());

                    infoAccountledger.LedgerName = dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtLedgerName"].Value.ToString();
                    if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value != null)
                    {
                        infoAccountledger.OpeningBalance = Convert.ToDecimal(dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString());
                    }
                    else
                    {
                        infoAccountledger.OpeningBalance = 0;
                    }
                    infoAccountledger.CrOrDr = dgvMultipleAccountLedger.Rows[i].Cells["dgvcmbDebitOrCredit"].Value.ToString();

                    if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtNarration"].Value != null)
                    {
                        infoAccountledger.Narration = dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtNarration"].Value.ToString();
                    }
                    else
                    {
                        infoAccountledger.Narration = string.Empty;
                    }
                    infoAccountledger.MailingName       = string.Empty;
                    infoAccountledger.Address           = string.Empty;
                    infoAccountledger.State             = string.Empty;
                    infoAccountledger.Phone             = string.Empty;
                    infoAccountledger.Mobile            = string.Empty;
                    infoAccountledger.Email             = string.Empty;
                    infoAccountledger.CreditPeriod      = 0;
                    infoAccountledger.CreditLimit       = 0;
                    infoAccountledger.PricinglevelId    = 0;
                    infoAccountledger.BillByBill        = false;
                    infoAccountledger.Tin               = string.Empty;
                    infoAccountledger.Cst               = string.Empty;
                    infoAccountledger.Pan               = string.Empty;
                    infoAccountledger.RouteId           = 0;
                    infoAccountledger.BankAccountNumber = string.Empty;
                    infoAccountledger.BranchName        = string.Empty;
                    infoAccountledger.BranchCode        = string.Empty;
                    infoAccountledger.Extra1            = string.Empty;
                    infoAccountledger.Extra2            = string.Empty;
                    infoAccountledger.AreaId            = 0;
                    infoAccountledger.IsDefault         = false;
                    decLedgerId = spAccountledger.AccountLedgerAddWithIdentity(infoAccountledger);

                    if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value != null && dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString() != "0")
                    {
                        if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString() != string.Empty)
                        {
                            string strfinancialId;
                            decOpeningBalance = Convert.ToDecimal(dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString());
                            infoFinancialYear = spFinancialYear.FinancialYearViewForAccountLedger(1);
                            strfinancialId    = infoFinancialYear.FromDate.ToString("dd-MMM-yyyy");
                            infoLedgerPosting.VoucherTypeId = 1;
                            infoLedgerPosting.Date          = Convert.ToDateTime(strfinancialId.ToString());
                            infoLedgerPosting.LedgerId      = decLedgerId;
                            infoLedgerPosting.VoucherNo     = decLedgerId.ToString();
                            if (dgvMultipleAccountLedger.Rows[i].Cells["dgvcmbDebitOrCredit"].Value.ToString() == "Dr")
                            {
                                infoLedgerPosting.Debit = decOpeningBalance;
                            }
                            else
                            {
                                infoLedgerPosting.Credit = decOpeningBalance;
                            }
                            infoLedgerPosting.DetailsId = 0;
                            infoLedgerPosting.YearId    = PublicVariables._decCurrentFinancialYearId;
                            infoLedgerPosting.InvoiceNo = decLedgerId.ToString();

                            infoLedgerPosting.ChequeNo   = string.Empty;
                            infoLedgerPosting.ChequeDate = DateTime.Now;

                            infoLedgerPosting.Extra1 = string.Empty;
                            infoLedgerPosting.Extra2 = string.Empty;
                            spLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
                        }
                    }
                    isSave = true;
                }
                if (isSave)
                {
                    Messages.SavedMessage();
                    cmbAccountGroup.Focus();
                    cmbAccountGroup.SelectedIndex = -1;
                    dgvMultipleAccountLedger.Rows.Clear();
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("MAL6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }