/// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         SalaryPackageDetailsSP spSalaryPackageDetails = new SalaryPackageDetailsSP();
         DataTable dtbl = spSalaryPackageDetails.SalaryPackageDetailsForSalaryPackageDetailsReport(cmbSalaryPackage.Text);
         dgvSalaryPackageDetails.DataSource = dtbl;
         decCountAdditon = 0;
         decCountDeduction = 0;
         decTotalAmount = 0;
         foreach (DataGridViewRow dgvRaw in dgvSalaryPackageDetails.Rows)
         {
             if (dgvRaw.Cells["dgvtxttype"].Value.ToString() == "Addition")
             {
                 decimal decAmt = Convert.ToDecimal(dgvRaw.Cells["txtAmount"].Value.ToString());
                 decCountAdditon = decCountAdditon + decAmt;
             }
             else
             {
                 decimal decAmt = Convert.ToDecimal(dgvRaw.Cells["txtAmount"].Value.ToString());
                 decCountDeduction = decCountDeduction + decAmt;
             }
             if (dgvRaw.Cells["txtAmount"].Value != null && dgvRaw.Cells["txtAmount"].Value.ToString() != "")
             {
                 decimal decAmt = Convert.ToDecimal(dgvRaw.Cells["txtAmount"].Value.ToString());
                 decTotalAmount = decTotalAmount + decAmt;
             }
         }
         txttotalReduction.Text = Math.Round(decCountDeduction, PublicVariables._inNoOfDecimalPlaces).ToString();
         txttotalAddition.Text = Math.Round(decCountAdditon, PublicVariables._inNoOfDecimalPlaces).ToString(); //Convert.ToString(decCountAdditon);
         txtTotal.Text = Math.Round(decTotalAmount, PublicVariables._inNoOfDecimalPlaces).ToString(); //Convert.ToString(decTotalAmount);
     }
     catch (Exception ex)
     {
         MessageBox.Show("SPDR:1" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         SalaryPackageDetailsSP spSalaryPackageDetails = new SalaryPackageDetailsSP();
         DataTable dtbl = spSalaryPackageDetails.SalaryPackageDetailsForSalaryPackageDetailsReport(cmbSalaryPackage.Text);
         dgvSalaryPackageDetails.DataSource = dtbl;
         decCountAdditon   = 0;
         decCountDeduction = 0;
         decTotalAmount    = 0;
         foreach (DataGridViewRow dgvRaw in dgvSalaryPackageDetails.Rows)
         {
             if (dgvRaw.Cells["dgvtxttype"].Value.ToString() == "Addition")
             {
                 decimal decAmt = Convert.ToDecimal(dgvRaw.Cells["txtAmount"].Value.ToString());
                 decCountAdditon = decCountAdditon + decAmt;
             }
             else
             {
                 decimal decAmt = Convert.ToDecimal(dgvRaw.Cells["txtAmount"].Value.ToString());
                 decCountDeduction = decCountDeduction + decAmt;
             }
             if (dgvRaw.Cells["txtAmount"].Value != null && dgvRaw.Cells["txtAmount"].Value.ToString() != "")
             {
                 decimal decAmt = Convert.ToDecimal(dgvRaw.Cells["txtAmount"].Value.ToString());
                 decTotalAmount = decTotalAmount + decAmt;
             }
         }
         txttotalReduction.Text = Math.Round(decCountDeduction, PublicVariables._inNoOfDecimalPlaces).ToString();
         txttotalAddition.Text  = Math.Round(decCountAdditon, PublicVariables._inNoOfDecimalPlaces).ToString(); //Convert.ToString(decCountAdditon);
         txtTotal.Text          = Math.Round(decTotalAmount, PublicVariables._inNoOfDecimalPlaces).ToString();  //Convert.ToString(decTotalAmount);
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "SPDR:1" + ex.Message;
     }
 }
 /// <summary>
 /// On 'Print' button click to Print
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnPrint_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvSalaryPackageDetails.RowCount > 0)
         {
             DataTable dtblOther   = new DataTable();
             frmReport frmreport   = new frmReport();
             DataSet   ds          = new DataSet();
             CompanySP spCompany   = new CompanySP();
             DataTable dtblCompany = spCompany.CompanyViewDataTable(1);
             SalaryPackageDetailsSP spSalaryPackageDetails = new SalaryPackageDetailsSP();
             DataTable dtbl = spSalaryPackageDetails.SalaryPackageDetailsForSalaryPackageDetailsReport(cmbSalaryPackage.Text);
             ds.Tables.Add(dtblCompany);
             ds.Tables.Add(dtbl);
             ds.Tables.Add(dtblOther);
             DataColumn dc = new DataColumn("Addition", typeof(decimal));
             dtblOther.Columns.Add(dc);
             dc = new DataColumn("Deduction", typeof(decimal));
             dtblOther.Columns.Add(dc);
             DataRow dr = dtblOther.NewRow();
             dr[0] = decCountAdditon;
             dr[1] = decCountDeduction;
             dtblOther.Rows.InsertAt(dr, 0);
             frmreport.MdiParent = formMDI.MDIObj;
             frmreport.SalaryPackageDetailsReport(ds);
         }
         else
         {
             Messages.InformationMessage("No data found");
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "SPDR:7" + ex.Message;
     }
 }
        /// <summary>
        /// Fills the PayHead type and calculates the salary amount on cellvalue changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvSalaryPackage_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            SalaryPackageDetailsSP SPSalaryPackageDetails = new SalaryPackageDetailsSP();
            try
            {
                if (e.RowIndex != -1 && e.ColumnIndex != -1)
                {
                    if (e.ColumnIndex == dgvSalaryPackage.Columns["dgvcmbPayHead"].Index)
                    {
                        if (dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvcmbPayHead"].Value != null && dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvcmbPayHead"].Value.ToString() != string.Empty)
                        {
                            string strPayHeadType = SPSalaryPackageDetails.PayHeadTypeView(Convert.ToDecimal(dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvcmbPayHead"].Value.ToString()));
                            if (strPayHeadType != string.Empty)
                            {
                                dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvtxtType"].Value = strPayHeadType;
                            }
                        }
                    }
                    bool isStatus = true;
                    if (dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvtxtSlNo"].Value != null && dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvtxtSlNo"].Value.ToString() != string.Empty)
                    {
                        if (dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvcmbPayHead"].Value != null && dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvcmbPayHead"].Value.ToString() != string.Empty)
                        {
                            if (dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value != null && dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value.ToString() != string.Empty)
                            {
                                isStatus = true;
                            }
                            else
                            {
                                isStatus = false;
                            }
                        }
                        else
                        {
                            isStatus = false;
                        }
                    }
                    else
                    {
                        isStatus = false;
                    }

                    if (isStatus)
                    {

                        dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvtxtStatus"].Value = "Complete";
                    }
                    else
                    {
                        dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvtxtStatus"].Value = string.Empty;
                    }
                    decimal decGrandTotal = 0;
                    if (dgvSalaryPackage.RowCount > 1)
                    {
                        if (dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value != null)
                        {
                            foreach (DataGridViewRow drRow in dgvSalaryPackage.Rows)
                            {
                                if (!dgvSalaryPackage.CurrentRow.IsNewRow)
                                {
                                    if (!drRow.IsNewRow)
                                    {
                                        if (drRow.Cells["dgvtxtAmount"].Value != null && drRow.Cells["dgvtxtType"].Value != null)
                                        {

                                            if (drRow.Cells["dgvtxtType"].Value.ToString() != "Deduction")
                                            {
                                                decGrandTotal += Convert.ToDecimal(drRow.Cells["dgvtxtAmount"].Value.ToString());
                                                lblSalaryAmount.Text = decGrandTotal.ToString();
                                            }
                                            else
                                            {
                                                decGrandTotal -= Convert.ToDecimal(drRow.Cells["dgvtxtAmount"].Value.ToString());
                                                lblSalaryAmount.Text = decGrandTotal.ToString();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("SPC14" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// On 'Print' button click to Print
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnPrint_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvSalaryPackageDetails.RowCount > 0)
         {
             DataTable dtblOther = new DataTable();
             frmReport frmreport = new frmReport();
             DataSet ds = new DataSet();
             CompanySP spCompany = new CompanySP();
             DataTable dtblCompany = spCompany.CompanyViewDataTable(1);
             SalaryPackageDetailsSP spSalaryPackageDetails = new SalaryPackageDetailsSP();
             DataTable dtbl = spSalaryPackageDetails.SalaryPackageDetailsForSalaryPackageDetailsReport(cmbSalaryPackage.Text);
             ds.Tables.Add(dtblCompany);
             ds.Tables.Add(dtbl);
             ds.Tables.Add(dtblOther);
             DataColumn dc = new DataColumn("Addition", typeof(decimal));
             dtblOther.Columns.Add(dc);
             dc = new DataColumn("Deduction", typeof(decimal));
             dtblOther.Columns.Add(dc);
             DataRow dr = dtblOther.NewRow();
             dr[0] = decCountAdditon;
             dr[1] = decCountDeduction;
             dtblOther.Rows.InsertAt(dr, 0);
             frmreport.MdiParent = formMDI.MDIObj;
             frmreport.SalaryPackageDetailsReport(ds);
         }
         else
         {
             Messages.InformationMessage("No data found");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SPDR:7" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Fills the PayHead type and calculates the salary amount on cellvalue changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvSalaryPackage_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            SalaryPackageDetailsSP SPSalaryPackageDetails = new SalaryPackageDetailsSP();

            try
            {
                if (e.RowIndex != -1 && e.ColumnIndex != -1)
                {
                    if (e.ColumnIndex == dgvSalaryPackage.Columns["dgvcmbPayHead"].Index)
                    {
                        if (dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvcmbPayHead"].Value != null && dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvcmbPayHead"].Value.ToString() != string.Empty)
                        {
                            string strPayHeadType = SPSalaryPackageDetails.PayHeadTypeView(Convert.ToDecimal(dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvcmbPayHead"].Value.ToString()));
                            if (strPayHeadType != string.Empty)
                            {
                                dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvtxtType"].Value = strPayHeadType;
                            }
                        }
                    }
                    bool isStatus = true;
                    if (dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvtxtSlNo"].Value != null && dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvtxtSlNo"].Value.ToString() != string.Empty)
                    {
                        if (dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvcmbPayHead"].Value != null && dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvcmbPayHead"].Value.ToString() != string.Empty)
                        {
                            if (dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value != null && dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value.ToString() != string.Empty)
                            {
                                isStatus = true;
                            }
                            else
                            {
                                isStatus = false;
                            }
                        }
                        else
                        {
                            isStatus = false;
                        }
                    }
                    else
                    {
                        isStatus = false;
                    }

                    if (isStatus)
                    {
                        dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvtxtStatus"].Value = "Complete";
                    }
                    else
                    {
                        dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvtxtStatus"].Value = string.Empty;
                    }
                    decimal decGrandTotal = 0;
                    if (dgvSalaryPackage.RowCount > 1)
                    {
                        if (dgvSalaryPackage.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value != null)
                        {
                            foreach (DataGridViewRow drRow in dgvSalaryPackage.Rows)
                            {
                                if (!dgvSalaryPackage.CurrentRow.IsNewRow)
                                {
                                    if (!drRow.IsNewRow)
                                    {
                                        if (drRow.Cells["dgvtxtAmount"].Value != null && drRow.Cells["dgvtxtType"].Value != null)
                                        {
                                            if (drRow.Cells["dgvtxtType"].Value.ToString() != "Deduction")
                                            {
                                                decGrandTotal       += Convert.ToDecimal(drRow.Cells["dgvtxtAmount"].Value.ToString());
                                                lblSalaryAmount.Text = decGrandTotal.ToString();
                                            }
                                            else
                                            {
                                                decGrandTotal       -= Convert.ToDecimal(drRow.Cells["dgvtxtAmount"].Value.ToString());
                                                lblSalaryAmount.Text = decGrandTotal.ToString();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                formMDI.infoError.ErrorString = "SPC15:" + ex.Message;
            }
        }