Ejemplo n.º 1
0
 /// <summary>
 /// Save or edit function to check the references and invalid entries
 /// </summary>
 public void SaveOrEditFunction()
 {
     try
     {
         FinancialYearInfo infoFinancialYear = new FinancialYearInfo();
         FinancialYearSP   spFinancialYear   = new FinancialYearSP();
         if (PublicVariables.isMessageAdd)
         {
             if (Messages.SaveMessage())
             {
                 if (spFinancialYear.FinancialYearExistenceCheck(Convert.ToDateTime(txtFromDate.Text), Convert.ToDateTime(txtToDate.Text)))
                 {
                     SaveFunction();
                 }
                 else
                 {
                     Messages.InformationMessage("Financial year already exist.");
                     txtFromDate.Focus();
                 }
             }
         }
         else
         {
             SaveFunction();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("NFY 3 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Function to save the items to database
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         decimal           decIdentity       = 0;
         FinancialYearInfo infoFinancialYear = new FinancialYearInfo();
         FinancialYearSP   spFinancialYear   = new FinancialYearSP();
         CompanySP         spCompany         = new CompanySP();
         infoFinancialYear.FromDate  = Convert.ToDateTime(txtFromDate.Text);
         infoFinancialYear.ToDate    = Convert.ToDateTime(txtToDate.Text);
         infoFinancialYear.ExtraDate = System.DateTime.Now;
         infoFinancialYear.Extra1    = string.Empty;
         infoFinancialYear.Extra2    = string.Empty;
         decIdentity       = spFinancialYear.FinancialYearAddWithReturnIdentity(infoFinancialYear);
         infoFinancialYear = spFinancialYear.FinancialYearView(decIdentity);
         PublicVariables._decCurrentFinancialYearId = infoFinancialYear.FinancialYearId;
         PublicVariables._dtFromDate    = infoFinancialYear.FromDate;
         PublicVariables._dtToDate      = infoFinancialYear.ToDate;
         PublicVariables._dtCurrentDate = infoFinancialYear.FromDate;
         spCompany.CompanyCurrentDateEdit(PublicVariables._dtCurrentDate);
         formMDI.MDIObj.ShowCurrentDate();
         isSave = true;
         this.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show("NFY 2 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Function to Fill the grid
        /// </summary>
        public void GridFill()
        {
            try
            {
                FinancialYearSP spFinancialYear = new FinancialYearSP();
                DataTable       dtbl            = new DataTable();

                dtbl = spFinancialYear.FinancialYearViewAll();
                dgvChangeFinancialYear.DataSource = dtbl;
            }
            catch (Exception ex)
            {
                MessageBox.Show("CHGFINYR:1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Function to Get the Current Date
        /// </summary>
        public void CurrentDate()
        {
            try
            {
                CompanyInfo       infoComapany      = new CompanyInfo();
                CompanySP         spCompany         = new CompanySP();
                FinancialYearInfo infoFinancialYear = new FinancialYearInfo();
                FinancialYearSP   spFinancialYear   = new FinancialYearSP();

                infoComapany = spCompany.CompanyView(1);
                PublicVariables._dtCurrentDate = infoComapany.CurrentDate;
                infoFinancialYear           = spFinancialYear.FinancialYearView(1);
                PublicVariables._dtFromDate = infoFinancialYear.FromDate;
                PublicVariables._dtToDate   = infoFinancialYear.ToDate;
            }
            catch (Exception ex)
            {
                MessageBox.Show("SELCMPNY :2 " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Changing company's  financial year
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSelect_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("Are you sure you want to change the financial year?", "OpenMiracle", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             FinancialYearInfo infoFinancialYear = new FinancialYearInfo();
             FinancialYearSP   spFinancialYear   = new FinancialYearSP();
             decimal           decFinacialId     = Convert.ToDecimal(dgvChangeFinancialYear.CurrentRow.Cells["dgvtxtfinancialYearId"].Value);
             DateTime          dtmFromDate       = Convert.ToDateTime(dgvChangeFinancialYear.CurrentRow.Cells["dgvtxtFromDate"].Value);
             DateTime          dtmToDate         = Convert.ToDateTime(dgvChangeFinancialYear.CurrentRow.Cells["dgvtxtToDate"].Value);
             PublicVariables._decCurrentFinancialYearId = decFinacialId;
             PublicVariables._dtFromDate = dtmFromDate;
             PublicVariables._dtToDate   = dtmToDate;
             DateTime  dtGetCurrentdate = DateTime.Now;
             CompanySP spCompany        = new CompanySP();
             spCompany.CompanyCurrentDateEdit(dtmFromDate);
             if (dtGetCurrentdate < dtmFromDate)
             {
                 PublicVariables._dtCurrentDate = dtmFromDate;
                 spCompany.CompanyCurrentDateEdit(dtmFromDate);
                 formMDI.MDIObj.ShowCurrentDate();
             }
             else
             {
                 PublicVariables._dtCurrentDate = dtGetCurrentdate;
                 spCompany.CompanyCurrentDateEdit(dtmFromDate);
                 formMDI.MDIObj.ShowCurrentDate();
             }
             CompanyInfo infoCompany = new CompanyInfo();
             infoCompany         = spCompany.CompanyView(1);
             formMDI.MDIObj.Text = "OpenMiracle " + infoCompany.CompanyName + " [ " + PublicVariables._dtFromDate.ToString("dd-MMM-yyyy") + " To " + PublicVariables._dtToDate.ToString("dd-MMM-yyyy") + " ]";
             this.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("CHGFINYR:5" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Ejemplo n.º 6
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.Branch_ID         = 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);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Function to create new financial year
        /// </summary>
        public void NewFinancialYear()
        {
            FinancialYearSP spFinancialYear = new FinancialYearSP();
            //DateTime dtFromDate = System.DateTime.Now;
            //DateTime dtToDate = System.DateTime.Now;
            DateTime dtFromDate;
            DateTime dtToDate;

            try
            {
                if (frmCompanyCreationObj != null)
                {
                    DateTime dtCurrentDate = System.DateTime.Now;
                    int      inMonth       = dtCurrentDate.Month;
                    int      inYear        = dtCurrentDate.Year;
                    int      inDay         = dtCurrentDate.Day;
                    if (inMonth < 4 && inDay < 31)
                    {
                        string strFromDateDate = "1-Apr-" + (inYear - 1);
                        string strToDate       = "31-Mar-" + inYear;
                        dtFromDate = Convert.ToDateTime(strFromDateDate);
                        dtToDate   = Convert.ToDateTime(strToDate);
                    }
                    else
                    {
                        string strFromDateDate = "1-Apr-" + inYear;
                        string strToDate       = "31-Mar-" + (inYear + 1);
                        dtFromDate = Convert.ToDateTime(strFromDateDate);
                        dtToDate   = Convert.ToDateTime(strToDate);
                    }
                    //dtpFromDate.MinDate = dtFromDate;
                    //dtpToDate.MaxDate = dtToDate;
                    dtpFromDate.Value = dtFromDate;
                    dtpToDate.Value   = dtToDate;
                    strFromDateToKeep = dtFromDate.ToString("dd-MMM-yyyy");
                    strToDateToKeep   = dtToDate.ToString("dd-MMM-yyyy");
                }
                else
                {
                    string strFromDate = spFinancialYear.FinancialYearGetMax();
                    string strToDate   = string.Empty;
                    dtFromDate        = Convert.ToDateTime(strFromDate);
                    dtFromDate        = dtFromDate.AddDays(1);
                    dtpFromDate.Value = dtFromDate;
                    txtFromDate.Text  = dtFromDate.ToString("dd-MMM-yyyy");
                    int inMonth = dtFromDate.Month;
                    int inYear  = dtFromDate.Year;
                    int inDay   = dtFromDate.Day;
                    if (inMonth >= 4)
                    {
                        strToDate = "31-Mar-" + (inYear + 1);
                    }
                    else
                    {
                        strToDate = "31-Mar-" + (inYear);
                    }
                    dtToDate        = Convert.ToDateTime(strToDate);
                    dtpToDate.Value = dtToDate;
                    txtToDate.Text  = dtToDate.ToString("dd-MMM-yyyy");
                    //dtpToDate.MaxDate = dtToDate;
                    dtpToDate.MinDate = dtFromDate;
                    strFromDateToKeep = dtFromDate.ToString("dd-MMM-yyyy");
                    strToDateToKeep   = dtToDate.ToString("dd-MMM-yyyy");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("NFY 6 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }