Example #1
0
 /// <summary>
 /// On leave from txtToDate
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtToDate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation dv = new DateValidation();
         dv.DateValidationFunction(txtToDate);
         if (txtToDate.Text == string.Empty)
         {
             txtToDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         }
         string d = txtToDate.Text;
         dtpToDate.Value = Convert.ToDateTime(d.ToString());
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "VRR12:" + ex.Message;
     }
 }
 /// <summary>
 /// For date validation and set the dtp value as text box value
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtToDate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation obj       = new DateValidation();
         bool           isInvalid = obj.DateValidationFunction(txtToDate);
         if (!isInvalid)
         {
             txtToDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         }
         string date = txtToDate.Text;
         dtpToDate.Value = Convert.ToDateTime(date);
     }
     catch (Exception ex)
     {
         MessageBox.Show("ROREP16:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #3
0
        /// <summary>
        /// Date Validation in Text leave event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtCompanyCurrentdate_Leave(object sender, EventArgs e)
        {
            bool isValid = true;

            try
            {
                DateValidation obj = new DateValidation();
                isValid = obj.DateValidationFunction(txtCompanyCurrentdate);
                if (!isValid)
                {
                    txtCompanyCurrentdate.Text = string.Empty;
                }
            }
            catch (Exception ex)
            {
                formMDI.infoError.ErrorString = "CCD 9 : " + ex.Message;
            }
        }
 /// <summary>
 /// For enter key and backspace navigation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtFromDate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation obj = new DateValidation();
         obj.DateValidationFunction(txtFromDate);
         if (txtFromDate.Text == string.Empty)
         {
             txtFromDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         }
         string strdate = txtFromDate.Text;
         dtpFrmDate.Value = Convert.ToDateTime(strdate.ToString());
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "PRREP21:" + ex.Message;
     }
 }
Example #5
0
        /// <summary>
        /// DateValidation
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtFromDate_Leave(object sender, EventArgs e)
        {
            try
            {
                DateValidation dateValidationObj = new DateValidation();
                dateValidationObj.DateValidationFunction(txtFromDate);

                if (txtFromDate.Text == String.Empty)
                {
                    txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy");
                }
                dtpFrmDate.Value = DateTime.Parse(txtFromDate.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("RIReport:12" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #6
0
 /// <summary>
 /// For date validation and set the dtp value as text box value
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtToDate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation obj       = new DateValidation();
         bool           isInvalid = obj.DateValidationFunction(txtToDate);
         if (!isInvalid)
         {
             txtToDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         }
         string date = txtToDate.Text;
         dtpToDate.Value = Convert.ToDateTime(date);
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "ROREP16:" + ex.Message;
     }
 }
 /// <summary>
 /// Date validation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtFromDate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation DateValidationObj = new DateValidation();
         DateValidationObj.DateValidationFunction(txtFromDate);
         if (txtFromDate.Text == string.Empty)
         {
             txtFromDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         }
         //---for change date in Date time picker----//
         dtpFromDate.Value = Convert.ToDateTime(txtFromDate.Text);
     }
     catch (Exception ex)
     {
         MessageBox.Show("PSR:6" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Date validation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtFromDate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation obj = new DateValidation();
         obj.DateValidationFunction(txtFromDate);
         if (txtFromDate.Text == string.Empty)
         {
             txtFromDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         }
         string strdate = txtFromDate.Text;
         dtpFromDate.Value = Convert.ToDateTime(strdate.ToString());
     }
     catch (Exception ex)
     {
         MessageBox.Show("SRR11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #9
0
        /// <summary>
        /// Date Validation in Text leave event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtCompanyCurrentdate_Leave(object sender, EventArgs e)
        {
            bool isValid = true;

            try
            {
                DateValidation obj = new DateValidation();
                isValid = obj.DateValidationFunction(txtCompanyCurrentdate);
                if (!isValid)
                {
                    txtCompanyCurrentdate.Text = string.Empty;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("CCD 9 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Date validation and fill datagridview
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtCompanyCurrentdate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation obj = new DateValidation();
         obj.DateValidationFunction(txtCompanyCurrentdate);
         if (txtCompanyCurrentdate.Text == String.Empty)
         {
             txtCompanyCurrentdate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         }
         dtpCompanyCurrentDate.Value = DateTime.Parse(txtCompanyCurrentdate.Text);
         GridFill();
         HolidayIndication();
     }
     catch (Exception ex)
     {
         MessageBox.Show("A24" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #11
0
 /// <summary>
 /// Date validation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txttoDate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation ObjValidation = new DateValidation();
         ObjValidation.DateValidationFunction(txttoDate);
         if (txttoDate.Text == string.Empty)
         {
             txttoDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
         }
         DateTime dt;
         DateTime.TryParse(txttoDate.Text, out dt);
         dtpToDate.Value = dt;
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "CF8:" + ex.Message;
     }
 }
 /// <summary>
 /// DateValidation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtSalaryMonth_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation DateValidationObj = new DateValidation();
         DateValidationObj.DateValidationFunction(txtSalaryMonth);
         if (txtSalaryMonth.Text == string.Empty)
         {
             txtSalaryMonth.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         }
         //---for change date in Date time picker----//
         string strDate = txtSalaryMonth.Text;
         dtpSalaryMonth.Value = Convert.ToDateTime(strDate.ToString());
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "APR:15 " + ex.Message;
     }
 }
Example #13
0
 /// <summary>
 /// Function for initial date settings
 /// </summary>
 public void InitialDateSettings()
 {
     try
     {
         dtpAgeingDate.Value   = PublicVariables._dtToDate;
         dtpAgeingDate.MinDate = PublicVariables._dtFromDate;
         dtpAgeingDate.MaxDate = PublicVariables._dtToDate;
         DateValidation objValidation = new DateValidation();
         objValidation.DateValidationFunction(txtToDate);
         if (txtToDate.Text == string.Empty)
         {
             txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "AR10:" + ex.Message;
     }
 }
Example #14
0
        /// <summary>
        /// DateValidation
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtToDate_Leave(object sender, EventArgs e)
        {
            try
            {
                DateValidation dateValidationObj = new DateValidation();
                dateValidationObj.DateValidationFunction(txtToDate);

                if (txtToDate.Text == String.Empty)
                {
                    txtToDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
                }

                dtpToDate.Value = DateTime.Parse(txtToDate.Text);
            }
            catch (Exception ex)
            {
                formMDI.infoError.ErrorString = "RIReport14:" + ex.Message;
            }
        }
 /// <summary>
 /// On textbox leave event for Date validation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtFromDate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation ObjValidation = new DateValidation();
         ObjValidation.DateValidationFunction(txtFromDate);
         if (txtFromDate.Text == string.Empty)
         {
             txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy");
         }
         DateTime dt;
         DateTime.TryParse(txtFromDate.Text, out dt);
         dtpFromDate.Value = dt;
     }
     catch (Exception ex)
     {
         MessageBox.Show("PORP:9" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function for initial date settings
 /// </summary>
 public void InitialDateSettings()
 {
     try
     {
         dtpAgeingDate.Value   = PublicVariables._dtToDate;
         dtpAgeingDate.MinDate = PublicVariables._dtFromDate;
         dtpAgeingDate.MaxDate = PublicVariables._dtToDate;
         DateValidation objValidation = new DateValidation();
         objValidation.DateValidationFunction(txtToDate);
         if (txtToDate.Text == string.Empty)
         {
             txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("AR10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #17
0
 /// <summary>
 /// Datevalidation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtSalaryMonth_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation obj = new DateValidation();
         obj.DateValidationFunction(txtSalaryMonth);
         if (txtSalaryMonth.Text == string.Empty)
         {
             txtSalaryMonth.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         }
         //---for change date in Date time picker----//
         string strdate = txtSalaryMonth.Text;
         dtpSalaryMonth.Value = Convert.ToDateTime(strdate.ToString());
     }
     catch (Exception ex)
     {
         MessageBox.Show("MSR:14" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #18
0
 /// <summary>
 /// Date validation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtToDate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation obj = new DateValidation();
         obj.DateValidationFunction(txtToDate);
         if (txtToDate.Text == string.Empty)
         {
             txtToDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         }
         //---for change date in Date time picker----//
         string strdate = txtToDate.Text.Trim();
         dtpToDate.Value = Convert.ToDateTime(strdate);
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "CR9:" + ex.Message;
     }
 }
 /// <summary>
 /// Date validation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtToDate_Leave(object sender, EventArgs e)
 {
     try
     {
         if (txtToDate.Text == string.Empty)
         {
             txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
         }
         DateValidation DateValidationObj = new DateValidation();
         DateValidationObj.DateValidationFunction(txtToDate);
         if (txtToDate.Text == string.Empty)
         {
             txtToDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PAL :13" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #20
0
 /// <summary>
 /// Date validation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtToDate_Leave(object sender, EventArgs e)
 {
     try
     {
         if (txtToDate.Text == string.Empty)
         {
             txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
         }
         DateValidation DateValidationObj = new DateValidation();
         DateValidationObj.DateValidationFunction(txtToDate);
         if (txtToDate.Text == string.Empty)
         {
             txtToDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "PAL13:" + ex.Message;
     }
 }
 /// <summary>
 /// Date validation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtFromDate_TextChanged(object sender, EventArgs e)
 {
     try
     {
         if (txtFromDate.Text == string.Empty && !txtFromDate.Focused)
         {
             DateValidation obj       = new DateValidation();
             bool           isInvalid = obj.DateValidationFunction(txtFromDate);
             if (!isInvalid)
             {
                 txtFromDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
             }
             string date = txtFromDate.Text;
             dtpFromDate.Value = Convert.ToDateTime(date);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PIREG19:" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to check or validate dates
 /// </summary>
 /// <param name="txt"></param>
 /// <param name="dtp"></param>
 public void DateValidation(TextBox txt, DateTimePicker dtp)
 {
     try
     {
         DateValidation obj = new DateValidation();
         obj.DateValidationFunction(txt);
         if (txtFromDate.Text == String.Empty)
         {
             txt.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy");
         }
         if (txtToDate.Text == String.Empty)
         {
             txt.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         }
         dtp.Value = DateTime.Parse(txt.Text);
     }
     catch (Exception ex)
     {
         MessageBox.Show("SVRT 11 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #23
0
 /// <summary>
 /// Function to check or validate dates
 /// </summary>
 /// <param name="txt"></param>
 /// <param name="dtp"></param>
 public void DateValidation(TextBox txt, DateTimePicker dtp)
 {
     try
     {
         DateValidation obj = new DateValidation();
         obj.DateValidationFunction(txt);
         if (txtFromDate.Text == String.Empty)
         {
             txt.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy");
         }
         if (txtToDate.Text == String.Empty)
         {
             txt.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         }
         dtp.Value = DateTime.Parse(txt.Text);
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "SVRT11:" + ex.Message;
     }
 }
Example #24
0
 /// <summary>
 ///  Date validation and set dtp's value as textbox text
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtFromDate_TextChanged(object sender, EventArgs e)
 {
     try
     {
         if (txtFromDate.Text == string.Empty && !txtFromDate.Focused)
         {
             DateValidation obj       = new DateValidation();
             bool           isInvalid = obj.DateValidationFunction(txtFromDate);
             if (!isInvalid)
             {
                 txtFromDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
             }
             string date = txtFromDate.Text;
             dtpFromDate.Value = Convert.ToDateTime(date);
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "PIREP19:" + ex.Message;
     }
 }
Example #25
0
 /// <summary>
 /// Fills Datagirdview on 'Search' button click
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSearch_Click(object sender, EventArgs e)
 {
     try
     {
         DateValidation ObjValidation = new DateValidation();
         ObjValidation.DateValidationFunction(txtToDate);
         dtFromDate     = Convert.ToDateTime(txtFromDate.Text);
         dtToDate       = Convert.ToDateTime(txtToDate.Text);
         decVoucherType = Convert.ToDecimal(cmbVoucherType.SelectedValue);
         strVocherNo    = txtVoucherNo.Text;
         decCashOrParty = Convert.ToDecimal(cmbCashorParty.SelectedValue);
         if (cmbDeliveryNoteNo.SelectedIndex != -1)
         {
             decDeliveryNoteNo = Convert.ToDecimal(cmbDeliveryNoteNo.SelectedValue.ToString());
         }
         decSalesManId  = Convert.ToDecimal(cmbSalesMan.SelectedValue);
         strProductCode = txtProductCode.Text;
         if (Convert.ToDateTime(txtToDate.Text) < Convert.ToDateTime(txtFromDate.Text))
         {
             MessageBox.Show("todate should be greater than fromdate", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txtToDate.Text   = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
             txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy");
             DateTime dt;
             DateTime.TryParse(txtToDate.Text, out dt);
             dtpToDate.Value = dt;
             RejectionInReportFill();
         }
         else
         {
             DateTime dt;
             DateTime.TryParse(txtToDate.Text, out dt);
             dtpToDate.Value = dt;
             RejectionInReportFill();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("RIReport:15" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Date validation and fill dtp value into the todate textbox
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtToDate_Leave(object sender, EventArgs e)
        {
            try
            {
                DateValidation DateValidationObj = new DateValidation();
                DateValidationObj.DateValidationFunction(txtToDate);
                if (txtToDate.Text != string.Empty && txtFromDate.Text != string.Empty)
                {
                    if (Convert.ToDateTime(txtToDate.Text) <= Convert.ToDateTime(txtFromDate.Text))
                    {
                        txtToDate.Text   = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
                        txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy");

                        DateTime dt;
                        DateTime.TryParse(txtToDate.Text, out dt);
                        dtpToDate.Value = dt;
                    }
                    else
                    {
                        txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
                        DateTime dt;
                        DateTime.TryParse(txtToDate.Text, out dt);
                        dtpToDate.Value = dt;
                    }
                }
                else
                {
                    txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
                    DateTime dt;
                    DateTime.TryParse(txtToDate.Text, out dt);
                    dtpToDate.Value = dt;
                }
            }
            catch (Exception ex)
            {
                formMDI.infoError.ErrorString = "VPS :17" + ex.Message;
            }
        }
Example #27
0
        /// <summary>
        /// Date validation and fill dtp value into the todate textbox
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtToDate_Leave(object sender, EventArgs e)
        {
            try
            {
                DateValidation DateValidationObj = new DateValidation();
                DateValidationObj.DateValidationFunction(txtToDate);
                if (txtToDate.Text != string.Empty && txtFromDate.Text != string.Empty)
                {
                    if (Convert.ToDateTime(txtToDate.Text) <= Convert.ToDateTime(txtFromDate.Text))
                    {
                        txtToDate.Text   = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
                        txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy");

                        DateTime dt;
                        DateTime.TryParse(txtToDate.Text, out dt);
                        dtpToDate.Value = dt;
                    }
                    else
                    {
                        txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
                        DateTime dt;
                        DateTime.TryParse(txtToDate.Text, out dt);
                        dtpToDate.Value = dt;
                    }
                }
                else
                {
                    txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
                    DateTime dt;
                    DateTime.TryParse(txtToDate.Text, out dt);
                    dtpToDate.Value = dt;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("VPS :17" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// On 'Search' button click
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnRefersh_Click(object sender, EventArgs e)
 {
     try
     {
         DateValidation ObjValidation = new DateValidation();
         ObjValidation.DateValidationFunction(txtToDate);
         if (Convert.ToDateTime(txtToDate.Text) < Convert.ToDateTime(txtFromDate.Text))
         {
             MessageBox.Show("To-Date should be greater than From-Date", "Openmiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txtToDate.Text   = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
             txtFromDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
             DateTime dt;
             DateTime.TryParse(txtToDate.Text, out dt);
             dtpToDate.Value   = dt;
             dtpFromDate.Value = dt;
         }
         StockJournalRegisterGrideFill();
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "SJREG7:" + ex.Message;
     }
 }
 /// <summary>
 /// Search button click call the search function
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSearch_Click(object sender, EventArgs e)
 {
     try
     {
         DateValidation ObjValidation = new DateValidation();
         ObjValidation.DateValidationFunction(txtToDate);
         if (Convert.ToDateTime(txtToDate.Text) < Convert.ToDateTime(txtFromDate.Text))
         {
             MessageBox.Show("todate should be greater than fromdate", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txtToDate.Text   = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
             txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy");
             Search();
         }
         else
         {
             Search();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PRREP12:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #30
0
 /// <summary>
 /// Date validation and fill datagridview
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtCompanyCurrentdate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation obj = new DateValidation();
         obj.DateValidationFunction(txtCompanyCurrentdate);
         if (txtCompanyCurrentdate.Text == String.Empty)
         {
             txtCompanyCurrentdate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         }
         if (DateTime.Parse(txtCompanyCurrentdate.Text) > PublicVariables._dtCurrentDate)
         {
             txtCompanyCurrentdate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         }
         dtpCompanyCurrentDate.Value = DateTime.Parse(txtCompanyCurrentdate.Text);
         GridFill();
         HolidayIndication();
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "A25:" + ex.Message;
     }
 }
 /// <summary>
 /// changing Fromdate as per textbox changed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtFromDate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation obj = new DateValidation();
         obj.DateValidationFunction(txtFromDate);
         if (txtFromDate.Text == String.Empty)
             txtFromDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         dtpFromDate.Value = DateTime.Parse(txtFromDate.Text);
     }
     catch (Exception ex)
     {
         MessageBox.Show("SPS17" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Bank reconciliation Cell value changed event for Set the statement date
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvBankReconciliation_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex != -1 && e.ColumnIndex != -1)
                {
                    DateValidation objVal = new DateValidation();
                    TextBox txtDate = new TextBox();
                    if (!dgvBankReconciliation.Rows[e.RowIndex].Cells["dgvtxtStatementDate"].ReadOnly)
                    {
                        if (dgvBankReconciliation.Rows[e.RowIndex].Cells["dgvtxtStatementDate"].Value != null && dgvBankReconciliation.Rows[e.RowIndex].Cells["dgvtxtStatementDate"].Value.ToString() != string.Empty)
                        {

                            txtDate.Text = dgvBankReconciliation.Rows[e.RowIndex].Cells["dgvtxtStatementDate"].Value.ToString();
                            bool isDate = objVal.DateValidationFunction(txtDate);
                            if (isDate)
                            {
                                dgvBankReconciliation.Rows[e.RowIndex].Cells["dgvtxtStatementDate"].Value = txtDate.Text;
                            }
                            else
                            {
                                dgvBankReconciliation.Rows[e.RowIndex].Cells["dgvtxtStatementDate"].Value = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
                            }

                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("BR:16" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Date validation
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtVoucherDate_Leave(object sender, EventArgs e)
        {
            try
            {
                DateValidation objVal = new DateValidation();
                bool isInvalid = objVal.DateValidationFunction(txtVoucherDate);
                if (!isInvalid)
                {
                    txtVoucherDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
                }
               
                dtpVoucherDate.Value = Convert.ToDateTime(txtVoucherDate.Text);
                //-------------Re fill ---------------------------//
                if (!isEditMode)
                {

                    voucherNumberGeneration();
                }
              
            }
            catch (Exception ex)
            {
                MessageBox.Show("MSV27:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// On 'Search' button click for filter the data
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSearch_Click(object sender, EventArgs e)
        {

            try
            {
                DateValidation ObjValidation = new DateValidation();
                ObjValidation.DateValidationFunction(txtToDate);


                if (Convert.ToDateTime(txtToDate.Text) < Convert.ToDateTime(txtFromDate.Text))
                {
                    MessageBox.Show("todate should be greater than fromdate", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
                    txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy");

                    DateTime dt;
                    DateTime.TryParse(txtToDate.Text, out dt);
                    dtpToDate.Value = dt;
                    PurchaseReturnReportGridFill();
                }
                else
                {
                    DateTime dt;
                    DateTime.TryParse(txtToDate.Text, out dt);
                    dtpToDate.Value = dt;
                    PurchaseReturnReportGridFill();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PRRT:15" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

        }
 /// <summary>
 /// Date validation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtVoucherDateTo_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation objDateValidation = new DateValidation();
         objDateValidation.DateValidationFunction(txtVoucherDateTo);
         if (txtVoucherDateTo.Text == string.Empty)
         {
             txtVoucherDateTo.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("DSR16" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// On 'Search' button click fills Datagridview
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSearch_Click(object sender, EventArgs e)
 {
     try
     {
         DateValidation ObjValidation = new DateValidation();
         ObjValidation.DateValidationFunction(txtTodate);
         if (Convert.ToDateTime(txtTodate.Text) < Convert.ToDateTime(txtFromDate.Text))
         {
             MessageBox.Show("todate should be greater than fromdate", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txtTodate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
             txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy");
             GridFill();
         }
         else
         {
             GridFill();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("TB:13" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// For date validation and set the date as text box date
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtToDate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation obj = new DateValidation();
         bool isInvalid = obj.DateValidationFunction(txtToDate);
         if (!isInvalid)
         {
             txtToDate.Text = strToDateToKeep;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("NFY 17 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Save function
        /// </summary>
        public void SaveFunction()
        {
            try
            {
                DateValidation Objdatevalidation = new DateValidation();
                OtherDateValidationFunction ObjotherdateValidation = new OtherDateValidationFunction();
                Objdatevalidation.DateValidationFunction(txtVoucherDate);
                ObjotherdateValidation.DateValidationFunction(txtCheckDate, false);
                DataTable dtblMaster = new DataTable();
                SettingsBll BllSettings = new SettingsBll();
                PDCRecivebleBll BllPdcreceivable = new PDCRecivebleBll();
                PDCReceivableMasterInfo InfopdcRecivable = new PDCReceivableMasterInfo();
                PartyBalanceBll BllPartyBalance = new PartyBalanceBll();
                InfopdcRecivable.VoucherNo = strVoucherNo;
                InfopdcRecivable.InvoiceNo = txtVoucherNo.Text.Trim();
                InfopdcRecivable.Date = DateTime.Parse(txtVoucherDate.Text);
                InfopdcRecivable.LedgerId = Convert.ToDecimal(cmbAccountLedger.SelectedValue.ToString());
                InfopdcRecivable.Amount = decimal.Parse(txtAmount.Text);
                InfopdcRecivable.Narration = txtNarration.Text;
                if (txtcheckNo.Text != string.Empty)
                    InfopdcRecivable.ChequeNo = txtcheckNo.Text;
                else
                    InfopdcRecivable.ChequeNo = string.Empty;
                if (txtCheckDate.Text != string.Empty)
                    InfopdcRecivable.ChequeDate = Convert.ToDateTime(txtCheckDate.Text);
                else
                    InfopdcRecivable.ChequeDate = DateTime.Now;
                InfopdcRecivable.UserId = PublicVariables._decCurrentUserId;
                InfopdcRecivable.VoucherTypeId = decPDCReceivableVoucherTypeId;
                if (cmbBank.SelectedValue != null && cmbBank.SelectedValue.ToString() != string.Empty)
                {
                    InfopdcRecivable.BankId = Convert.ToDecimal(cmbBank.SelectedValue.ToString());
                }
                else
                    InfopdcRecivable.BankId = 0;
                InfopdcRecivable.ExtraDate = DateTime.Now;
                InfopdcRecivable.Extra1 = string.Empty;
                InfopdcRecivable.Extra2 = string.Empty;
                if (!isInEditMode)
                {
                    decimal decIdentity = BllPdcreceivable.PDCReceivableMasterAdd(InfopdcRecivable);
                    LedgerPosting();
                    PartyBalanceAddOrEdit();
                    Messages.SavedMessage();
                    if (cbxPrint.Checked)
                    {
                        if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                        {
                            PrintForDotMatrix(decIdentity);
                        }
                        else
                        {
                            Print(decIdentity);
                        }
                    }
                    ClearFunction();
                }
                else
                {

                    decimal decIdentity = decPDCReceivableEditId;
                    InfopdcRecivable.PdcReceivableMasterId = decPDCReceivableEditId;
                    BllPdcreceivable.PDCReceivableMasterEdit(InfopdcRecivable);

                    LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();
                    BllLedgerPosting.LedgerPostingDeleteByVoucherNoVoucherTypeIdAndLedgerId(strVoucherNo, decPDCReceivableVoucherTypeId, 12);
                    BllPartyBalance.PartyBalanceDeleteByVoucherTypeAndVoucherNo(decPDCReceivableVoucherTypeId, strVoucherNo);
                    PartyBalanceAddOrEdit();
                    LedgerPostingEdit(decPDCReceivableEditId);
                    Messages.UpdatedMessage();
                    if (cbxPrint.Checked)
                    {
                        if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                        {
                            PrintForDotMatrix(decIdentity);
                        }
                        else
                        {
                            Print(decIdentity);
                        }
                    }
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PR9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// text box StatementFrom leave for change date in date time picker
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtStatementFrom_Leave(object sender, EventArgs e)
        {
            try
            {
                DateValidation obj = new DateValidation();
                obj.DateValidationFunction(txtStatementFrom);
                if (txtStatementFrom.Text == string.Empty)
                {
                    txtStatementFrom.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
                }
                dtpStatementFrom.Value = Convert.ToDateTime(txtStatementFrom.Text);
            }
            catch (Exception ex)
            {

                MessageBox.Show("BR:11" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Call the totalamount,SlNo,InvalidEntry functions to do the all are the process even if change one value of the grid
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvContraVoucher_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                AccountGroupBll bllAccountGroup = new AccountGroupBll();
                if (e.RowIndex != -1 && e.ColumnIndex != -1)
                {
                    if (dgvContraVoucher.Rows[e.RowIndex].Cells["dgvcmbBankorCashAccount"].Value != null && dgvContraVoucher.Rows[e.RowIndex].Cells["dgvcmbBankorCashAccount"].Value.ToString() != "")
                    {
                        if (dgvContraVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value == null || dgvContraVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value.ToString() == "")
                        {
                            dgvContraVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(1);//PublicVariables._decCurrencyId;
                        }
                    }
                    TotalAmount();
                    SlNo();

                    if (dgvContraVoucher.Rows[e.RowIndex].Cells["dgvcmbBankorCashAccount"].Value != null)
                    {

                        decimal decLedger = Convert.ToDecimal(dgvContraVoucher.Rows[e.RowIndex].Cells["dgvcmbBankorCashAccount"].Value.ToString());
                        isBankAcocunt = bllAccountGroup.AccountGroupwithLedgerId(decLedger);
                        if (isBankAcocunt)
                        {
                            dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].ReadOnly = false;
                            dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeNo"].ReadOnly = false;
                        }
                        else
                        {
                            dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].ReadOnly = true;
                            dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeNo"].ReadOnly = true;
                            dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value = string.Empty;
                            dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeNo"].Value = string.Empty;

                        }
                    }
                    CheckColumnMissing(e);
                    if (!dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].ReadOnly)
                    {
                        DateValidation objVal = new DateValidation();
                        TextBox txtDate = new TextBox();
                        if (dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value != null)
                        {

                            txtDate.Text = dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value.ToString();
                            bool isDate = objVal.DateValidationFunction(txtDate);
                            if (isDate)
                            {
                                dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value = txtDate.Text;
                            }
                            else
                            {
                                dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
                            }

                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("CV:42" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// On 'Search' button click fills datagridview
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnRefresh_Click(object sender, EventArgs e)
 {
     try
     {
         DateValidation ObjValidation = new DateValidation();
         ObjValidation.DateValidationFunction(txtToDate);
         if (Convert.ToDateTime(txtToDate.Text) < Convert.ToDateTime(txtFromDate.Text))
         {
             MessageBox.Show("To-Date should be greater than From-Date", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txtToDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
             txtFromDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
             DateTime dt;
             DateTime.TryParse(txtToDate.Text, out dt);
             dtpToDate.Value = dt;
             dtpFromDate.Value = dt;
         }
         GridFill();
     }
     catch (Exception ex)
     {
         MessageBox.Show("DNREG10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #42
0
 /// <summary>
 /// On leave from txtBooksBegining
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtBooksBegining_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation obj = new DateValidation();
         bool isInvalid = obj.DateValidationFunction(txtBooksBegining);
         if (!isInvalid)
         {
             txtBooksBegining.Text = System.DateTime.Now.ToString("dd-MMM-yyyy");
         }
         string date = txtBooksBegining.Text;
         dtpBooksBegining.Value = Convert.ToDateTime(date);
     }
     catch (Exception ex)
     {
         MessageBox.Show("CR22:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function for initial date settings
        /// </summary>
        public void InitialDateSettings()
        {
            try
            {
                dtpAgeingDate.Value = PublicVariables._dtToDate;
                dtpAgeingDate.MinDate = PublicVariables._dtFromDate;
                dtpAgeingDate.MaxDate = PublicVariables._dtToDate;

                DateValidation objValidation = new DateValidation();
                objValidation.DateValidationFunction(txtToDate);
                if (txtToDate.Text == string.Empty)
                {
                    txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("AR10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// To set dtp value based on Textbox changed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtDate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation obj = new DateValidation();
         obj.DateValidationFunction(txtDate);
         if (txtDate.Text == string.Empty)
         {
             txtDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         }
         string strdate = txtDate.Text;
         dtpDate.Value = Convert.ToDateTime(strdate.ToString());
         CurrencyComboFill();
     }
     catch (Exception ex)
     {
         MessageBox.Show("DN:94" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// On leave from txttodate
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txttodate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation obj = new DateValidation();
         obj.DateValidationFunction(txttodate);
         if (txttodate.Text == string.Empty)
         {
             txttodate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         }
         //---for change date in Date time picker----
         string strdate = txttodate.Text;
         dtptodate.Value = Convert.ToDateTime(strdate.ToString());
     }
     catch (Exception ex)
     {
         MessageBox.Show("OR:17" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// On leave from txtToDate
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtToDate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation obj = new DateValidation();
         obj.DateValidationFunction(txtToDate);
         if (txtToDate.Text == string.Empty || txtToDate.SelectionStart == 0)
             txtToDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         dtpToDate.Value = Convert.ToDateTime(txtToDate.Text);
     }
     catch (Exception ex)
     {
         MessageBox.Show("TR:8" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to fill Datagridview after calculation
        /// </summary>
        public void GridFill()
        {
            try
            {
                if (!isFormLoad)
                {
                    string calculationMethod = string.Empty;
                    SettingsInfo InfoSettings = new SettingsInfo();
                    SettingsBll BllSettings = new SettingsBll();
                    //--------------- Selection Of Calculation Method According To Settings ------------------//
                    if (BllSettings.SettingsStatusCheck("StockValueCalculationMethod") == "FIFO")
                    {
                        calculationMethod = "FIFO";
                    }
                    else if (BllSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Average Cost")
                    {
                        calculationMethod = "Average Cost";
                    }
                    else if (BllSettings.SettingsStatusCheck("StockValueCalculationMethod") == "High Cost")
                    {
                        calculationMethod = "High Cost";
                    }
                    else if (BllSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Low Cost")
                    {
                        calculationMethod = "Low Cost";
                    }
                    else if (BllSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Last Purchase Rate")
                    {
                        calculationMethod = "Last Purchase Rate";
                    }
                    FinancialStatementBll bllFinancialStatement = new FinancialStatementBll();

                    DataTable dtbl1 = new DataTable();
                    CurrencyInfo InfoCurrency = new CurrencyInfo();
                    CurrencyBll BllCurrency = new CurrencyBll();
                    int inDecimalPlaces = InfoCurrency.NoOfDecimalPlaces;
                    decimal dcClosingStock = bllFinancialStatement.StockValueGetOnDate(Convert.ToDateTime(txtTodate.Text), calculationMethod, false, false);
                    dcClosingStock = Math.Round(dcClosingStock, inDecimalPlaces);
                    //---------------------Opening Stock-----------------------
                    decimal dcOpeninggStock = bllFinancialStatement.StockValueGetOnDate(PublicVariables._dtFromDate, calculationMethod, true, true);
                    decimal dcProfit = 0;
                    DataSet dsetProfitAndLoss = new DataSet();
                    dsetProfitAndLoss = bllFinancialStatement.ProfitAndLossAnalysisUpToaDateForBalansheet(PublicVariables._dtFromDate, DateTime.Parse(txtTodate.Text));
                    DataTable dtblProfit = new DataTable();
                    dtblProfit = dsetProfitAndLoss.Tables[0];
                    for (int i = 0; i < dsetProfitAndLoss.Tables.Count; ++i)
                    {
                        dtbl1 = dsetProfitAndLoss.Tables[i];
                        decimal dcSum = 0;
                        if (i == 0 || (i % 2) == 0)
                        {
                            if (dtbl1.Rows.Count > 0)
                            {
                                dcSum = decimal.Parse(dtbl1.Compute("Sum(Debit)", string.Empty).ToString());
                            }
                        }
                        else
                        {
                            if (dtbl1.Rows.Count > 0)
                            {
                                dcSum = decimal.Parse(dtbl1.Compute("Sum(Credit)", string.Empty).ToString());
                            }
                        }
                    }
                    DateValidation objValidation = new DateValidation();
                    objValidation.DateValidationFunction(txtTodate);
                    if (txtTodate.Text == string.Empty)
                        txtTodate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
                    Font newFont = new Font(dgvTrailBalance.Font, FontStyle.Bold);

                    DataSet DsetTrailbalance = new DataSet();
                    DataTable dtbl = new DataTable();
                    decimal dcTotalCredit = 0;
                    decimal dcTotalDebit = 0;
                    DateValidation objvalidation = new DateValidation();
                    objvalidation.DateValidationFunction(txtFromDate);
                    if (txtFromDate.Text == string.Empty)
                    {
                        txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy");
                    }
                    objvalidation.DateValidationFunction(txtTodate);
                    if (txtTodate.Text == string.Empty)
                    {
                        txtTodate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
                    }
                    DataTable dtblTrail = new DataTable();
                    DataTable dtblTrail1 = new DataTable();
                    DataTable dtblProfitAndLossAcc = new DataTable();
                    DataTable dtblProfitAndLossAcc1 = new DataTable();
                    DataSet dsTrial = new DataSet();
                    Font newfont = new Font(dgvTrailBalance.Font, FontStyle.Bold);

                    dgvTrailBalance.Rows.Clear();
                    dsTrial = bllFinancialStatement.TrialBalance(DateTime.Parse(txtFromDate.Text), DateTime.Parse(txtTodate.Text), 0);
                    dtblTrail = dsTrial.Tables[0];
                    dtblProfitAndLossAcc = dsTrial.Tables[1];
                    if (dgvTrailBalance.RowCount > 0)
                    {
                        dcTotalCredit = decimal.Parse(dtblTrail.Compute("Sum(credit)", string.Empty).ToString());
                        dcTotalDebit = decimal.Parse(dtblTrail.Compute("Sum(debit)", string.Empty).ToString());
                    }
                    for (int i = 0; i < dtblTrail.Rows.Count; ++i)
                    {
                        dgvTrailBalance.Rows.Add();
                        if (Convert.ToDecimal(dtblTrail.Rows[i]["accountGroupId"].ToString()) != 6)
                        {
                            dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtAccountGroupId"].Value = dtblTrail.Rows[i]["accountGroupId"];
                            dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["accountGroupName"].Value = dtblTrail.Rows[i]["name"];
                            dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["openingBalance"].Value = dtblTrail.Rows[i]["OpeningBalance"];
                            dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtBalance"].Value = dtblTrail.Rows[i]["Balance"];
                            dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["credit"].Value = dtblTrail.Rows[i]["credit"];
                            dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["debit"].Value = dtblTrail.Rows[i]["debit"];
                            dcTotalCredit += decimal.Parse(dtblTrail.Rows[i]["credit"].ToString());
                            dcTotalDebit += decimal.Parse(dtblTrail.Rows[i]["debit"].ToString());
                        }
                        else
                        {
                            decimal decOpBalance = dcOpeninggStock + Convert.ToDecimal(dtblTrail.Rows[i]["OpBalance"].ToString());
                            decimal decBalance = dcOpeninggStock + Convert.ToDecimal(dtblTrail.Rows[i]["Balance1"].ToString());
                            string strOpBalance = string.Empty;
                            string strBalance = string.Empty;
                            if (decOpBalance < 0)
                            {
                                strOpBalance = Math.Round(decOpBalance, PublicVariables._inNoOfDecimalPlaces).ToString() + "Cr";
                            }
                            else
                            {
                                strOpBalance = Math.Round(decOpBalance, PublicVariables._inNoOfDecimalPlaces).ToString() + "Dr";
                            }
                            if (decBalance < 0)
                            {
                                strBalance = Math.Round(decBalance, PublicVariables._inNoOfDecimalPlaces).ToString() + "Cr";
                            }
                            else
                            {
                                strBalance = Math.Round(decBalance, PublicVariables._inNoOfDecimalPlaces).ToString() + "Dr";
                            }
                            dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtAccountGroupId"].Value = dtblTrail.Rows[i]["accountGroupId"];
                            dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["accountGroupName"].Value = dtblTrail.Rows[i]["name"];
                            dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["openingBalance"].Value = strOpBalance;
                            dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtBalance"].Value = strBalance;
                            dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["credit"].Value = dtblTrail.Rows[i]["credit"];
                            dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["debit"].Value = dtblTrail.Rows[i]["debit"];
                            dcTotalCredit += decimal.Parse(dtblTrail.Rows[i]["credit"].ToString());
                            dcTotalDebit += decimal.Parse(dtblTrail.Rows[i]["debit"].ToString());
                        }
                    }
                    decimal OpeningProfit;
                    dtblProfitAndLossAcc1 = dsTrial.Tables[2];
                    if (dgvTrailBalance.RowCount > 0)
                    {
                        decimal dcTotalCredit1 = decimal.Parse(dtblTrail.Compute("Sum(credit)", string.Empty).ToString());
                        decimal dcTotalDebit1 = decimal.Parse(dtblTrail.Compute("Sum(debit)", string.Empty).ToString());
                        OpeningProfit = dcTotalCredit1 + dcTotalDebit1;
                    }
                    DataSet DsetBalanceSheet = new DataSet();
                    DsetBalanceSheet = bllFinancialStatement.BalanceSheet(PublicVariables._dtFromDate, DateTime.Parse(txtTodate.Text));
                    DataTable dtblProf = new DataTable();
                    decimal dcProfitOpening = 0;
                    dtblProf = DsetBalanceSheet.Tables[2];
                    decimal decProfitLedger = 0;
                    if (dtblProf.Rows.Count > 0)
                    {
                        decProfitLedger = decimal.Parse(dtblProf.Compute("Sum(Balance)", string.Empty).ToString());
                    }
                    DataTable dtblProfitLedgerOpening = new DataTable();
                    dtblProfitLedgerOpening = DsetBalanceSheet.Tables[3];
                    decimal decProfitLedgerOpening = 0;
                    foreach (DataRow dRow in dtblProfitLedgerOpening.Rows)
                    {
                        decProfitLedgerOpening += decimal.Parse(dRow["Balance"].ToString());
                    }
                    decimal decTotalProfitAndLoss = decProfitLedger;
                    decimal OpeningProfit1;
                    decimal openingBalance;
                    dgvTrailBalance.Rows.Add();
                    dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtSlNo"].Value = "  ";
                    dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["accountGroupName"].Value = "Profit and Loss";
                    dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtAccountGroupId"].Value = "0";
                    openingBalance = Convert.ToDecimal(dtblProfitAndLossAcc.Rows[0]["OpeningBalance"].ToString());
                    {
                        if (openingBalance > 0)
                        {
                            dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["openingBalance"].Value = openingBalance + "Dr";
                        }
                        else
                            dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["openingBalance"].Value = (-1) * openingBalance + "Cr";
                    }
                    dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtSlNo"].Value = dgvTrailBalance.Rows.Count.ToString();
                    dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.Blue;
                    dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].DefaultCellStyle.Font = new Font(dgvTrailBalance.Font, FontStyle.Regular);
                    dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["credit"].Value = dtblProfitAndLossAcc.Rows[0]["credit"].ToString();
                    dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["debit"].Value = dtblProfitAndLossAcc.Rows[0]["debit"].ToString();
                    OpeningProfit1 = (Convert.ToDecimal(dtblProfitAndLossAcc.Rows[0]["OpeningBalance"].ToString())) + Convert.ToDecimal(dtblProfitAndLossAcc.Rows[0]["debit"].ToString()) - Convert.ToDecimal(dtblProfitAndLossAcc.Rows[0]["credit"].ToString());
                    {
                        if (OpeningProfit1 > 0)
                        {
                            dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtBalance"].Value = decTotalProfitAndLoss + dcProfit + "Dr";
                        }
                        else
                            dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtBalance"].Value = (-1) * decTotalProfitAndLoss - dcProfit + "Cr";
                    };
                    dcTotalCredit = dcTotalCredit + Convert.ToDecimal(dtblProfitAndLossAcc.Rows[0]["credit"].ToString());
                    dcTotalDebit = dcTotalDebit + Convert.ToDecimal(dtblProfitAndLossAcc.Rows[0]["debit"].ToString());
                    //=================================Net profit and NetLoss transation for previousyear==============
                    decimal decprofitLossbal = 0;
                    decimal decbalance = 0;
                    decimal decProfitAndLossOfPrevious = decProfitLedgerOpening;
                    dgvTrailBalance.Rows.Add();
                    if (dcProfitOpening > 0)
                    {
                        dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["openingBalance"].Value = dcProfitOpening + "Dr";
                        decprofitLossbal = dcProfitOpening;
                    }
                    if (dcProfitOpening <= 0)
                    {
                        dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["openingBalance"].Value = (-1) * dcProfitOpening + "Cr";
                        decprofitLossbal = dcProfitOpening;
                    }
                    dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtSlNo"].Value = "  ";
                    dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["accountGroupName"].Value = "Profit and Loss Opening";
                    dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["openingBalance"].Value = "0.00Dr";
                    dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.Brown;
                    dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].DefaultCellStyle.Font = new Font(dgvTrailBalance.Font, FontStyle.Regular);
                    dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtAccountGroupId"].Value = "0";
                    if (decProfitAndLossOfPrevious > 0)
                    {
                        dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["debit"].Value = decProfitAndLossOfPrevious;
                        dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["credit"].Value = "0.00";
                        decbalance = (decProfitAndLossOfPrevious);
                    }
                    if (decProfitAndLossOfPrevious <= 0)
                    {
                        dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["credit"].Value = (-1) * (decProfitAndLossOfPrevious);
                        dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["debit"].Value = "0.00";
                        decbalance = ((decProfitAndLossOfPrevious));
                    }
                    if (decbalance >= 0)
                    {
                        dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtBalance"].Value = decbalance + decprofitLossbal + "Dr";
                    }
                    if (decbalance < 0)
                    {
                        decbalance = -(decbalance);
                        dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtBalance"].Value = decbalance + decprofitLossbal + "Cr";
                    }
                    dgvTrailBalance.Rows.Add();
                    dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtSlNo"].Value = "  ";
                    dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["accountGroupName"].Value = "Total:";
                    dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtSlNo"].Value = string.Empty;
                    dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.Red;
                    dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].DefaultCellStyle.Font = new Font(dgvTrailBalance.Font, FontStyle.Bold);
                    dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["credit"].Value = dcTotalCredit;
                    dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["debit"].Value = dcTotalDebit;
                    if (dgvTrailBalance.Columns.Count > 0)
                    {
                        dgvTrailBalance.Columns["credit"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                        dgvTrailBalance.Columns["debit"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                        dgvTrailBalance.Columns["openingBalance"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                        dgvTrailBalance.Columns["dgvtxtBalance"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                    }
                    dgvTrailBalance.ScrollBars = ScrollBars.Both;
                    dgvTrailBalance.ClearSelection();
                    if (inCurrenRowIndex > 0 && dgvTrailBalance.Rows.Count > 0 && inCurrenRowIndex < dgvTrailBalance.Rows.Count)
                    {
                        if (dgvTrailBalance.Rows[inCurrenRowIndex].Cells[inCurrentColIndex].Visible)
                        {
                            dgvTrailBalance.CurrentCell = dgvTrailBalance.Rows[inCurrenRowIndex].Cells[inCurrentColIndex];
                        }
                        else
                        {
                            dgvTrailBalance.CurrentCell = dgvTrailBalance.Rows[inCurrenRowIndex].Cells["debit"];
                        }
                        dgvTrailBalance.CurrentCell.Selected = true;
                    }
                    inCurrenRowIndex = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Tb:2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// On textbox leave event for Data validation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtFromDate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation objVal = new DateValidation();
         bool isInvalid = objVal.DateValidationFunction(txtFromDate);
         if (!isInvalid)
         {
             txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy");
         }
         dtpFrmDate.Value = Convert.ToDateTime(txtFromDate.Text);
     }
     catch (Exception ex)
     {
         MessageBox.Show("PRRT:07" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #49
0
        /// <summary>
        /// Save Function
        /// </summary>
        public void Save()
        {
            try
            {
                int inGridRowCount = dgvPaymentVoucher.RowCount;
                int inTableRowCount = dtblPartyBalance.Rows.Count;
                int inB = 0;
                PaymentMasterInfo InfoPaymentMaster = new PaymentMasterInfo();
                PaymentMasterSP SpPaymentMaster = new PaymentMasterSP();
                PaymentDetailsInfo InfoPaymentDetails = new PaymentDetailsInfo();
                PaymentDetailsSP SpPaymentDetails = new PaymentDetailsSP();
                PartyBalanceSP SpPartyBalance = new PartyBalanceSP();
                PartyBalanceInfo InfopartyBalance = new PartyBalanceInfo();
                DateValidation objVal = new DateValidation();
                TextBox txtDate1 = new TextBox();
                InfoPaymentMaster.Date = dtpDate.Value;
                InfoPaymentMaster.Extra1 = string.Empty;
                InfoPaymentMaster.Extra2 = string.Empty;
                InfoPaymentMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                InfoPaymentMaster.InvoiceNo = txtVoucherNo.Text.Trim(); ;
                InfoPaymentMaster.LedgerId = Convert.ToDecimal(cmbBankorCash.SelectedValue.ToString());
                InfoPaymentMaster.Narration = txtNarration.Text.Trim();
                InfoPaymentMaster.SuffixPrefixId = decDailySuffixPrefixId;
                decimal decTotalAmount = TotalAmountCalculation();
                InfoPaymentMaster.TotalAmount = decTotalAmount;
                InfoPaymentMaster.UserId = PublicVariables._decCurrentUserId;
                InfoPaymentMaster.VoucherNo = strVoucherNo;
                InfoPaymentMaster.VoucherTypeId = decPaymentVoucherTypeId;
                decimal decPaymentMasterId = SpPaymentMaster.PaymentMasterAdd(InfoPaymentMaster);
                if (decPaymentMasterId != 0)
                {
                    MasterLedgerPosting();
                }
                for (int inI = 0; inI < inGridRowCount - 1; inI++)
                {
                    if (dgvPaymentVoucher.Rows[inI].HeaderCell.Value.ToString() != "X")
                    {
                        InfoPaymentDetails.Amount = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                        InfoPaymentDetails.ExchangeRateId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString());
                        InfoPaymentDetails.Extra1 = string.Empty;
                        InfoPaymentDetails.Extra2 = string.Empty;
                        InfoPaymentDetails.LedgerId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString());
                        InfoPaymentDetails.PaymentMasterId = decPaymentMasterId;
                        if (dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
                        {
                            InfoPaymentDetails.LedgerId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString());
                        }
                        if (dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty)
                        {
                            InfoPaymentDetails.ChequeNo = dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString();

                            if (dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty)
                            {
                                InfoPaymentDetails.ChequeDate = Convert.ToDateTime(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value);
                            }
                            else
                            {
                                InfoPaymentDetails.ChequeDate = DateTime.Now;
                            }
                        }
                        else
                        {
                            InfoPaymentDetails.ChequeNo = string.Empty;
                            InfoPaymentDetails.ChequeDate = DateTime.Now;
                        }
                        decimal decPaymentDetailsId = SpPaymentDetails.PaymentDetailsAdd(InfoPaymentDetails);
                        if (decPaymentDetailsId != 0)
                        {
                            for (int inJ = 0; inJ < inTableRowCount; inJ++)
                            {
                                if (dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() == dtblPartyBalance.Rows[inJ]["LedgerId"].ToString())
                                {
                                    PartyBalanceAddOrEdit(inJ);
                                }
                            }
                            inB++;
                            DetailsLedgerPosting(inI, decPaymentDetailsId);
                        }
                    }
                }
                Messages.SavedMessage();
                if (cbxPrintafterSave.Checked)
                {
                    if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                    {
                        PrintForDotMatrix(decPaymentmasterId);
                    }
                    else
                    {
                        Print(decPaymentMasterId);
                    }
                }
                Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show("PV17:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// On leave from txtToDate
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtToDate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation DateValidationObj = new DateValidation();
         DateValidationObj.DateValidationFunction(txtToDate);
         if (txtToDate.Text == string.Empty)
         {
             txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("AR20:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// For date validation and set the date as text box date
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtFromDate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation obj = new DateValidation();
         bool isInvalid = obj.DateValidationFunction(txtFromDate);
         if (!isInvalid)
         {
             txtFromDate.Text = strFromDateToKeep;
         }
         else
         {
             string date = txtFromDate.Text;
             dtpFromDate.Value = Convert.ToDateTime(date);
         }
         dtpToDate.MinDate = Convert.ToDateTime(txtFromDate.Text);
         //dtpToDate.Value = dtpFromDate.Value;
         //txtToDate.Clear();
     }
     catch (Exception ex)
     {
         MessageBox.Show("NFY 16 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #52
0
        /// <summary>
        /// On cellvalueChanged of dgvCreditNote
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvJournalVoucher_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex != -1 && e.ColumnIndex != -1)
                {
                    DebitAndCreditTotal();

                    if (dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value != null && dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
                    {

                        if (dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value == null || dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value.ToString() == string.Empty)
                        {
                            dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(1); //decExchangeRateId;
                        }

                    }

                    if (dgvJournalVoucher.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbAccountLedger")
                    {
                        /*************Remove partybalance while changing the ledger ************/
                        if (inUpdatingRowIndexForPartyRemove != -1)
                        {
                            int inTableRowCount = dtblPartyBalance.Rows.Count;
                            for (int inJ = 0; inJ < inTableRowCount; inJ++)
                            {
                                if (dtblPartyBalance.Rows.Count == inJ)
                                {
                                    break;
                                }

                                if (Convert.ToDecimal(dtblPartyBalance.Rows[inJ]["ledgerId"].ToString()) == decUpdatingLedgerForPartyremove)
                                {
                                    if (dtblPartyBalance.Rows[inJ]["PartyBalanceId"].ToString() != "0")
                                    {
                                        arrlstOfDeletedPartyBalanceRow.Add(dtblPartyBalance.Rows[inJ]["PartyBalanceId"]);
                                    }
                                    dtblPartyBalance.Rows.RemoveAt(inJ);
                                    inJ--;
                                }
                            }

                            dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty;

                            //reset
                            decUpdatingLedgerForPartyremove = 0;
                            inUpdatingRowIndexForPartyRemove = -1;
                        }
                        /*************************************************************************/

                        //-----------To make amount readonly when party is selected as ledger------------------------------//
                        AccountLedgerSP spAccountLedger = new AccountLedgerSP();
                        if (spAccountLedger.AccountGroupIdCheck(dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].FormattedValue.ToString()))
                        {
                            dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty;
                            dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].ReadOnly = true;

                        }
                        else
                        {
                            dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty;
                            dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].ReadOnly = false;
                            SettingsSP spSettings = new SettingsSP();
                            if (spSettings.SettingsStatusCheck("MultiCurrency") == "Yes")
                            {
                                dgvcmbCurrency.ReadOnly = false;
                            }
                            else
                            {
                                dgvcmbCurrency.ReadOnly = true;

                            }
                        }

                        //========================================================================================//
                    }

                    if (dgvJournalVoucher.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbDrOrCr")
                    {
                        /*************Remove partybalance while changing the Dr/Cr ************/
                        if (inUpdatingRowIndexForPartyRemove != -1)
                        {
                            int inTableRowCount = dtblPartyBalance.Rows.Count;
                            for (int inJ = 0; inJ < inTableRowCount; inJ++)
                            {
                                if (dtblPartyBalance.Rows.Count == inJ)
                                {
                                    break;
                                }

                                if (Convert.ToDecimal(dtblPartyBalance.Rows[inJ]["ledgerId"].ToString()) == decUpdatingLedgerForPartyremove)
                                {
                                    if (dtblPartyBalance.Rows[inJ]["PartyBalanceId"].ToString() != "0")
                                    {
                                        arrlstOfDeletedPartyBalanceRow.Add(dtblPartyBalance.Rows[inJ]["PartyBalanceId"]);
                                    }
                                    dtblPartyBalance.Rows.RemoveAt(inJ);
                                    inJ--;
                                }
                            }
                            dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty;

                            //reset
                            decUpdatingLedgerForPartyremove = 0;
                            inUpdatingRowIndexForPartyRemove = -1;
                        }
                        /*************************************************************************/
                    }

                    //-----------------------------------Chequedate validation----------------------------------//
                    DateValidation obj = new DateValidation();
                    TextBox txtDate1 = new TextBox();
                    if (dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value != null && dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty)
                    {
                        txtDate1.Text = dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value.ToString();
                        bool isInvalid = obj.DateValidationFunction(txtDate1);
                        if (!isInvalid)
                        {
                            dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
                        }
                        else
                        {
                            dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value = txtDate1.Text;
                        }
                    }
                    //=========================================================================================//
                    //---------------------check column missing---------------------------------//

                    CheckColumnMissing(e);

                    //==========================================================================//

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("JV50:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #53
0
 /// <summary>
 /// On leave from txtDate, validates date
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtDate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation obj = new DateValidation();
         bool isInvalid = obj.DateValidationFunction(txtDate);
         if (!isInvalid)
         {
             txtDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         }
         string date = txtDate.Text;
         dtpDate.Value = Convert.ToDateTime(date);
     }
     catch (Exception ex)
     {
         MessageBox.Show("SJ:64" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Date validation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtTodate_TextChanged(object sender, EventArgs e)
 {
    
     try
     {
        
         if (txtTodate.Text == string.Empty && !txtTodate.Focused)
         {
             DateValidation obj = new DateValidation();
             bool isInvalid = obj.DateValidationFunction(txtTodate);
             if (!isInvalid)
             {
                 txtTodate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
             }
             string date = txtTodate.Text;
             dtpTodate.Value = Convert.ToDateTime(date);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("POREG10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to fill Datagridview
        /// </summary>
        public void Gridfill()
        {
            try
            {
                if (!isFormLoad)
                {
                    DateValidation objValidation = new DateValidation();
                    objValidation.DateValidationFunction(txtFromDate);
                    if (txtFromDate.Text == string.Empty)
                        txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy");
                    objValidation.DateValidationFunction(txtToDate);
                    if (txtToDate.Text == string.Empty)
                        txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
                    Font newFont = new Font(dgvProfitAndLoss.Font, FontStyle.Bold);
                    CurrencyInfo InfoCurrency = new CurrencyInfo();
                    CurrencyBll BllCurrency = new CurrencyBll();
                    InfoCurrency = BllCurrency.CurrencyView(1);
                    int inDecimalPlaces = InfoCurrency.NoOfDecimalPlaces;
                    dgvProfitAndLoss.Rows.Clear();
                    FinancialStatementBll bllFinancialStatement = new FinancialStatementBll();

                    DataTable dtblFinancial = new DataTable();
                    DataSet DsetProfitAndLoss = new DataSet();
                    SettingsInfo infoSettings = new SettingsInfo();
                    SettingsBll BllSettings = new SettingsBll();
                    //---------check  calculation method
                    if (BllSettings.SettingsStatusCheck("StockValueCalculationMethod") == "FIFO")
                    {
                        calculationMethod = "FIFO";
                    }
                    else if (BllSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Average Cost")
                    {
                        calculationMethod = "Average Cost";
                    }
                    else if (BllSettings.SettingsStatusCheck("StockValueCalculationMethod") == "High Cost")
                    {
                        calculationMethod = "High Cost";
                    }
                    else if (BllSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Low Cost")
                    {
                        calculationMethod = "Low Cost";
                    }
                    else if (BllSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Last Purchase Rate")
                    {
                        calculationMethod = "Last Purchase Rate";
                    }
                    DsetProfitAndLoss = bllFinancialStatement.ProfitAndLossAnalysis(DateTime.Parse(txtFromDate.Text), DateTime.Parse(txtToDate.Text));
                    //---- Opening Stock
                    dgvProfitAndLoss.Rows.Add();
                    decimal dcOpeningStock = bllFinancialStatement.StockValueGetOnDate(DateTime.Parse(txtFromDate.Text), DateTime.Parse(txtToDate.Text), calculationMethod, true, false);
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Opening Stock";
                    if (dcOpeningStock > 0)
                    {
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = Math.Round(dcOpeningStock, inDecimalPlaces);
                    }
                    else
                    {
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = -(Math.Round(dcOpeningStock, inDecimalPlaces));
                    }
                    //Closing Stock
                    decimal dcClosingStock = 0;
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Closing Stock";
                    dcClosingStock = bllFinancialStatement.StockValueGetOnDate(DateTime.Parse(txtToDate.Text), calculationMethod, false, false);
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = Math.Round(dcClosingStock, inDecimalPlaces);
                    /// ---Purchase Account  - Debit
                    dtblFinancial = new DataTable();
                    dtblFinancial = DsetProfitAndLoss.Tables[0];
                    dgvProfitAndLoss.Rows.Add();
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Purchase Accounts";
                    decimal dcPurchaseAccount = 0m;
                    if (dtblFinancial.Rows.Count > 0)
                    {
                        foreach (DataRow rw in dtblFinancial.Rows)
                        {
                            decimal dcBalance = decimal.Parse(rw["Debit"].ToString().ToString());
                            dcPurchaseAccount += dcBalance;
                        }
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId1"].Value = "11";
                    }
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcPurchaseAccount.ToString();
                    //---Sales Account  -Credit
                    dtblFinancial = new DataTable();
                    dtblFinancial = DsetProfitAndLoss.Tables[1];
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Sales Accounts";
                    decimal dcSalesAccount = 0m;
                    if (dtblFinancial.Rows.Count > 0)
                    {
                        foreach (DataRow rw in dtblFinancial.Rows)
                        {
                            decimal dcBalance = decimal.Parse(rw["Credit"].ToString().ToString());
                            dcSalesAccount += dcBalance;
                        }
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId2"].Value = "10";
                    }
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcSalesAccount.ToString();
                    dgvProfitAndLoss.Rows.Add();
                    dgvProfitAndLoss.Rows.Add();
                    //---Direct Expense
                    dtblFinancial = new DataTable();
                    dtblFinancial = DsetProfitAndLoss.Tables[2];
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Direct Expenses";
                    decimal dcDirectExpense = 0m;
                    if (dtblFinancial.Rows.Count > 0)
                    {
                        foreach (DataRow rw in dtblFinancial.Rows)
                        {
                            decimal dcBalance = Convert.ToDecimal(rw["Debit"].ToString());
                            dcDirectExpense += dcBalance;
                        }
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId1"].Value = "13";
                    }
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcDirectExpense.ToString();
                    //----Direct Income
                    dtblFinancial = new DataTable();
                    dtblFinancial = DsetProfitAndLoss.Tables[3];
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Direct Incomes";
                    decimal dcDirectIncoome = 0m;
                    if (dtblFinancial.Rows.Count > 0)
                    {
                        foreach (DataRow rw in dtblFinancial.Rows)
                        {
                            decimal dcBalance = Convert.ToDecimal(rw["Credit"].ToString());
                            dcDirectIncoome += dcBalance;
                        }
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId2"].Value = "12";
                    }
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcDirectIncoome.ToString();
                    dgvProfitAndLoss.Rows.Add();
                    dgvProfitAndLoss.Rows.Add();
                    dgvProfitAndLoss.Rows.Add();
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = "_______________________";
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = "_______________________";
                    dgvProfitAndLoss.Rows.Add();
                    decimal dcTotalExpense = 0;
                    decimal dcTotalIncome = 0;
                    dcTotalExpense = dcOpeningStock + dcPurchaseAccount + dcDirectExpense;
                    dcTotalIncome = dcClosingStock + dcSalesAccount + dcDirectIncoome;
                    dcTotalExpense = Math.Round(dcTotalExpense, inDecimalPlaces);
                    dcTotalIncome = Math.Round(dcTotalIncome, inDecimalPlaces);
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].DefaultCellStyle.Font = newFont;
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Total";
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Total";
                    decimal dcGrossProfit = 0;
                    decimal dcGrossLoss = 0;
                    if (dcTotalExpense > dcTotalIncome)
                    {
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcTotalExpense.ToString();
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcTotalExpense.ToString();
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtIncome"].Value = "Gross Loss b/d ";
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount2"].Value = dcTotalExpense - dcTotalIncome;
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount2"].Style.ForeColor = Color.Red;
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtIncome"].Style.ForeColor = Color.Red;
                        dgvProfitAndLoss.Rows.Add();
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Gross Loss b/d ";
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcTotalExpense - dcTotalIncome;
                        dcGrossLoss = dcTotalExpense - dcTotalIncome;
                    }
                    else
                    {
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcTotalIncome.ToString();
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcTotalIncome.ToString();
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtExpenses"].Value = "Gross Profit c/d ";
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount1"].Value = dcTotalIncome - dcTotalExpense;
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount1"].Style.ForeColor = Color.Green;
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtExpenses"].Style.ForeColor = Color.Green;
                        dgvProfitAndLoss.Rows.Add();
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Gross Profit c/d ";
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcTotalIncome - dcTotalExpense;
                        dcGrossProfit = dcTotalIncome - dcTotalExpense;
                    }
                    dgvProfitAndLoss.Rows.Add();
                    ///------Indirect Expense
                    dtblFinancial = new DataTable();
                    dtblFinancial = DsetProfitAndLoss.Tables[4];
                    dgvProfitAndLoss.Rows.Add();
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Indirect Expenses";
                    decimal dcIndirectExpense = 0;
                    if (dtblFinancial.Rows.Count > 0)
                    {
                        foreach (DataRow rw in dtblFinancial.Rows)
                        {
                            decimal dcBalance = Convert.ToDecimal(rw["Debit"].ToString());
                            dcIndirectExpense += dcBalance;
                        }
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId1"].Value = "15";
                    }
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcIndirectExpense.ToString();
                    ///---Indirect Income
                    dtblFinancial = new DataTable();
                    dtblFinancial = DsetProfitAndLoss.Tables[5];
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Indirect Incomes";
                    decimal dcIndirectIncome = 0m;
                    if (dtblFinancial.Rows.Count > 0)
                    {
                        foreach (DataRow rw in dtblFinancial.Rows)
                        {
                            decimal dcBalance = Convert.ToDecimal(rw["Credit"].ToString());
                            dcIndirectIncome += dcBalance;
                        }
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId2"].Value = "14";
                    }
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcIndirectIncome.ToString();
                    //---- Calculating Grand total
                    decimal dcGrandTotalExpense = dcGrossLoss + dcIndirectExpense;
                    decimal dcGrandTotalIncome = dcGrossProfit + dcIndirectIncome;
                    dgvProfitAndLoss.Rows.Add();
                    dgvProfitAndLoss.Rows.Add();
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = "_______________________";
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = "_______________________";
                    dgvProfitAndLoss.Rows.Add();
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Grand Total";
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Grand Total";
                    dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].DefaultCellStyle.Font = newFont;
                    if (dcGrandTotalExpense > dcGrandTotalIncome)
                    {
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcGrandTotalExpense.ToString();
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcGrandTotalExpense.ToString();
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtIncome"].Value = "Net Loss ";
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount2"].Value = dcGrandTotalExpense - dcGrandTotalIncome;
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtIncome"].Style.ForeColor = Color.Red;
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount2"].Style.ForeColor = Color.Red;
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].DefaultCellStyle.Font = newFont;
                        decgranExTotal = dcGrandTotalExpense;
                    }
                    else
                    {
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcGrandTotalIncome.ToString();
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcGrandTotalIncome.ToString();
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtExpenses"].Value = "Net Profit";
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount1"].Value = dcGrandTotalIncome - dcGrandTotalExpense;
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtExpenses"].Style.ForeColor = Color.Green;
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount1"].Style.ForeColor = Color.Green;
                        dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].DefaultCellStyle.Font = newFont;
                        decgranIncTotal = dcGrandTotalIncome;
                    }
                    if (dgvProfitAndLoss.Columns.Count > 0)
                    {
                        dgvProfitAndLoss.Columns["dgvtxtAmount1"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                        dgvProfitAndLoss.Columns["dgvtxtAmount2"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                    }
                    if (inCurrenRowIndex >= 0 && dgvProfitAndLoss.Rows.Count > 0 && inCurrenRowIndex < dgvProfitAndLoss.Rows.Count)
                    {
                        if (dgvProfitAndLoss.Rows[inCurrenRowIndex].Cells[inCurrentColunIndex].Visible)
                        {
                            dgvProfitAndLoss.CurrentCell = dgvProfitAndLoss.Rows[inCurrenRowIndex].Cells[inCurrentColunIndex];
                        }
                        else
                        {
                            dgvProfitAndLoss.CurrentCell = dgvProfitAndLoss.Rows[inCurrenRowIndex].Cells["dgvtxtExpenses"];
                        }
                        dgvProfitAndLoss.CurrentCell.Selected = true;
                    }
                    inCurrenRowIndex = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PAL :01" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #56
0
        /// <summary>
        /// Gridview cell value changed , doing basic calculations and checking invalid entries
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvPaymentVoucher_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex != -1 && e.ColumnIndex != -1)
                {
                    TotalAmount();

                    if (dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
                    {

                        if (dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value == null || dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value.ToString() == string.Empty)
                        {
                            dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(1);
                        }

                    }
                    AccountGroupSP spAccountGroup = new AccountGroupSP();
                    AccountLedgerSP SpAccountLedger = new AccountLedgerSP();
                    if (dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString().Trim() != string.Empty)
                    {
                        if (dgvPaymentVoucher.CurrentCell.ColumnIndex == dgvPaymentVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].ColumnIndex)
                        {

                            /*************Remove partybalance while changing the ledger ************/
                            if (inUpdatingRowIndexForPartyRemove != -1)
                            {
                                int inTableRowCount = dtblPartyBalance.Rows.Count;
                                for (int inJ = 0; inJ < inTableRowCount; inJ++)
                                {
                                    if (dtblPartyBalance.Rows.Count == inJ)
                                    {
                                        break;
                                    }
                                    if (Convert.ToDecimal(dtblPartyBalance.Rows[inJ]["ledgerId"].ToString()) == decUpdatingLedgerForPartyremove)
                                    {
                                        if (dtblPartyBalance.Rows[inJ]["PartyBalanceId"].ToString() != "0")
                                        {
                                            arrlstOfDeletedPartyBalanceRow.Add(dtblPartyBalance.Rows[inJ]["PartyBalanceId"]);
                                        }
                                        dtblPartyBalance.Rows.RemoveAt(inJ);
                                        inJ--;
                                    }
                                }
                                dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty;
                                decUpdatingLedgerForPartyremove = 0;
                                inUpdatingRowIndexForPartyRemove = -1;
                            }
                            /*************************************************************************/
                            decimal decLedgerId = Convert.ToDecimal(dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString());
                            bool IsBankAccount = spAccountGroup.AccountGroupwithLedgerId(decLedgerId);
                            decimal decI = Convert.ToDecimal(SpAccountLedger.AccountGroupIdCheck(dgvPaymentVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].FormattedValue.ToString()));
                            if (decI > 0)//to make amount and currency read only when party is choosen as ledger
                            {
                                dgvPaymentVoucher.CurrentRow.Cells["dgvtxtAmount"].ReadOnly = true;
                                dgvPaymentVoucher.CurrentRow.Cells["dgvtxtAmount"].Value = string.Empty;
                                dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(1);
                                dgvPaymentVoucher.CurrentRow.Cells["dgvcmbCurrency"].ReadOnly = true;
                            }
                            else
                            {
                                dgvPaymentVoucher.CurrentRow.Cells["dgvtxtAmount"].ReadOnly = false;
                                SettingsSP spSettings = new SettingsSP();
                                if (spSettings.SettingsStatusCheck("MultiCurrency") == "Yes")
                                {
                                    dgvcmbCurrency.ReadOnly = false;
                                }
                                else
                                {
                                    dgvcmbCurrency.ReadOnly = true;

                                }
                            }
                        }
                    }
                    CheckColumnMissing();
                    DateValidation objVal = new DateValidation();
                    TextBox txtDate1 = new TextBox();
                    if (dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value != null)
                    {

                        txtDate1.Text = dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value.ToString();
                        bool isDate = objVal.DateValidationFunction(txtDate1);
                        if (isDate)
                        {
                            dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value = txtDate1.Text;
                        }
                        else
                        {
                            dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PV48:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// On leave from dtpAgeingDate
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dtpAgeingDate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateValidation objValidation = new DateValidation();
         objValidation.DateValidationFunction(txtToDate);
         if (txtToDate.Text == string.Empty)
             txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
         DateTime dt;
         DateTime.TryParse(txtToDate.Text, out dt);
         dtpAgeingDate.Value = dt;
     }
     catch (Exception ex)
     {
         MessageBox.Show("AR18:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Date Validation
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtDate_Leave(object sender, EventArgs e)
        {
            try
            {
                DateValidation obj = new DateValidation();
                bool isValidate = obj.DateValidationFunction(txtDate);

                if (!isValidate)
                {
                    txtDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
                }
                //---for change date in Date time picker----//

                dtpDate.Value = Convert.ToDateTime(txtDate.Text);

                if (!isEditmode)//Re fill
                {
                    VoucherNumberGeneration();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("DSV35:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 ///// <summary>
 ///// 
 ///// </summary>
 ///// <param name="txt"></param>
 ///// <param name="dtp"></param>
 //public void dtpCloseUpEventFunction(TextBox txt, DateTimePicker dtp)
 //{
 //    try
 //    {
 //        txt.Text = dtp.Value.ToString("dd-MMM-yyyy");
 //        txt.Focus();
 //        txt.SelectionStart = 0;
 //        txt.SelectionLength = 0;
 //    }
 //    catch (Exception ex)
 //    {
 //        MessageBox.Show("SV 31 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
 //    }
 //}
 /// <summary>
 /// date validation function
 /// </summary>
 /// <param name="txt"></param>
 /// <param name="dtp"></param>
 public void DateValidation(TextBox txt, DateTimePicker dtp)
 {
     try
     {
         DateValidation obj = new DateValidation();
         obj.DateValidationFunction(txt);
         if (txt.Text == String.Empty)
         {
             txt.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         }
         dtp.Value = DateTime.Parse(txt.Text);
     }
     catch (Exception ex)
     {
         MessageBox.Show("SV 28 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Date vakidation and fills Datagridview
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtSalaryDate_Leave(object sender, EventArgs e)
        {
            DailySalaryVoucherBll BllDailySalaryVoucher = new DailySalaryVoucherBll();
            try
            {
                DateValidation obj = new DateValidation();
                obj.DateValidationFunction(txtSalaryDate);
                if (txtSalaryDate.Text == string.Empty)
                {
                    txtSalaryDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
                }
                //---for change date in Date time picker----//
                string strdate = txtSalaryDate.Text;
                dtpSalaryDate.Value = Convert.ToDateTime(strdate.ToString());

                List<DataTable> listObj = new List<DataTable>();

                listObj = BllDailySalaryVoucher.DailySalaryVoucherDetailsGridViewAll(txtSalaryDate.Text.ToString(), isEditmode, strVoucherNoforEdit);
                dgvDailySalaryVoucher.DataSource = listObj[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show("DSV30:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }