Beispiel #1
0
 /// <summary>
 /// On 'Print' button click for print
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnPrint_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvMonthlySalary.Rows.Count > 0)
         {
             DataSet   ds          = new DataSet();
             CompanySP spCompany   = new CompanySP();
             DataTable dtblCompany = spCompany.CompanyViewDataTable(1);
             ds.Tables.Add(dtblCompany);
             MonthlySalarySP spMonthlySalary   = new MonthlySalarySP();
             DataTable       dtblMonthlySalary = spMonthlySalary.MonthlySalryViewAllForMonthlySalaryReports(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), cmbDesignation.Text, cmbEmployeeCode.Text, Convert.ToDateTime(dtpSalaryMonth.Value.ToString()));
             ds.Tables.Add(dtblMonthlySalary);
             frmReport frmReportObj = new frmReport();
             frmReportObj.MdiParent = formMDI.MDIObj;
             frmReportObj.MonthlySalaryReportPrinting(ds);
         }
         else
         {
             Messages.InformationMessage("No data found");
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "MSR:9" + ex.Message;
     }
 }
 /// <summary>
 /// On 'Delete' button click
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, this.Name, btnDelete.Text))
         {
             MonthlySalarySP spMonthlySalary = new MonthlySalarySP();
             if (spMonthlySalary.MonthlySalarySettingsMonthlySalaryIdSearchUsingSalaryMonth(Convert.ToDateTime(dtpSalaryMonth.Text)) > 0)
             {
                 Delete();
             }
             else
             {
                 btnDelete.Enabled = false;
             }
         }
         else
         {
             Messages.NoPrivillageMessage();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("MSS14" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// On 'Delete' button click
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, this.Name, btnDelete.Text))
         {
             MonthlySalarySP spMonthlySalary = new MonthlySalarySP();
             if (spMonthlySalary.MonthlySalarySettingsMonthlySalaryIdSearchUsingSalaryMonth(Convert.ToDateTime(dtpSalaryMonth.Text)) > 0)
             {
                 Delete();
             }
             else
             {
                 btnDelete.Enabled = false;
             }
         }
         else
         {
             Messages.NoPrivillageMessage();
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "MSS14:" + ex.Message;
     }
 }
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         DataTable                dtblMonthlySalaryDetails     = new DataTable();
         MonthlySalarySP          spMonthlySalary              = new MonthlySalarySP();
         MonthlySalaryInfo        infoMonthlySalary            = new MonthlySalaryInfo();
         MonthlySalaryDetailsSP   spMonthlySalaryDetails       = new MonthlySalaryDetailsSP();
         MonthlySalaryDetailsInfo infoMonthlySalaryDetailsInfo = new MonthlySalaryDetailsInfo();
         dtblMonthlySalaryDetails           = spMonthlySalary.MonthlySalarySettingsEmployeeViewAll(Convert.ToDateTime(dtpSalaryMonth.Text));
         dgvMonthySalarySettings.DataSource = dtblMonthlySalaryDetails;
         int    inRowCount   = dgvMonthySalarySettings.RowCount;
         string strNarration = string.Empty;
         for (int i = 0; i < inRowCount; i++)
         {
             if (dgvMonthySalarySettings.Rows[i].Cells["dgvtxtnarration"].Value.ToString() != string.Empty)
             {
                 strNarration = dgvMonthySalarySettings.Rows[i].Cells["dgvtxtnarration"].Value.ToString();
             }
         }
         for (int i = 0; i < inRowCount; i++)
         {
             //select default package for employee
             if (dgvMonthySalarySettings.Rows[i].Cells["dgvtxtdefaultPackageId"].Value != null && dgvMonthySalarySettings.Rows[i].Cells["dgvtxtdefaultPackageId"].Value.ToString() != "")
             {
                 dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].Value = dgvMonthySalarySettings.Rows[i].Cells["dgvtxtdefaultPackageId"].Value;
             }
         }
         txtNarration.Text = strNarration;
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "MSS4:" + ex.Message;
     }
 }
Beispiel #5
0
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         MonthlySalarySP spMonthlySalary = new MonthlySalarySP();
         DataTable       dtbl            = spMonthlySalary.MonthlySalryViewAllForMonthlySalaryReports(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), cmbDesignation.Text, cmbEmployeeCode.Text, Convert.ToDateTime(dtpSalaryMonth.Value.ToString()));
         dgvMonthlySalary.DataSource = dtbl;
         txtTotalAmount.Text         = TotalAmount().ToString();
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "MSR:1" + ex.Message;
     }
 }
Beispiel #6
0
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         MonthlySalarySP spMonthlySalary = new MonthlySalarySP();
         DataTable       dtbl            = spMonthlySalary.MonthlySalryViewAllForMonthlySalaryReports(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), cmbDesignation.Text, cmbEmployeeCode.Text, Convert.ToDateTime(dtpSalaryMonth.Value.ToString()));
         dgvMonthlySalary.DataSource = dtbl;
         txtTotalAmount.Text         = TotalAmount().ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show("MSR:1" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         MonthlySalarySP spMonthlySalary = new MonthlySalarySP();
         DataTable dtbl = spMonthlySalary.MonthlySalryViewAllForMonthlySalaryReports(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), cmbDesignation.Text, cmbEmployeeCode.Text, Convert.ToDateTime(dtpSalaryMonth.Value.ToString()));
         dgvMonthlySalary.DataSource = dtbl;
         txtTotalAmount.Text = TotalAmount().ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show("MSR:1" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function for Delete
 /// </summary>
 public void DeleteFunction()
 {
     try
     {
         MonthlySalaryDetailsSP spMonthlySalaryDetails = new MonthlySalaryDetailsSP();
         MonthlySalarySP        spMonthlySalary        = new MonthlySalarySP();
         string strMonth = dtpSalaryMonth.Text;
         spMonthlySalary.MonthlySalaryDeleteAll(spMonthlySalary.MonthlySalarySettingsMonthlySalaryIdSearchUsingSalaryMonth(Convert.ToDateTime(dtpSalaryMonth.Text)));
         Messages.DeletedMessage();
         SalaryPackageComboFill();
         GridFill();
         UpdateDataGridViewRowColors();
         DeleteButtonEnableDisableChoose();
         dtpSalaryMonth.Focus();
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "MSS5:" + ex.Message;
     }
 }
 /// <summary>
 /// Function for Delete
 /// </summary>
 public void DeleteFunction()
 {
     try
     {
         MonthlySalaryDetailsSP spMonthlySalaryDetails = new MonthlySalaryDetailsSP();
         MonthlySalarySP        spMonthlySalary        = new MonthlySalarySP();
         string strMonth = dtpSalaryMonth.Text;
         spMonthlySalary.MonthlySalaryDeleteAll(spMonthlySalary.MonthlySalarySettingsMonthlySalaryIdSearchUsingSalaryMonth(Convert.ToDateTime(dtpSalaryMonth.Text)));
         Messages.DeletedMessage();
         SalaryPackageComboFill();
         GridFill();
         UpdateDataGridViewRowColors();
         DeleteButtonEnableDisableChoose();
         dtpSalaryMonth.Focus();
     }
     catch (Exception ex)
     {
         MessageBox.Show("MSS5" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function for Save
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         MonthlySalarySP          spMonthlySalary          = new MonthlySalarySP();
         MonthlySalaryInfo        infoMonthlySalary        = new MonthlySalaryInfo();
         MonthlySalaryDetailsSP   spMonthlySalaryDetails   = new MonthlySalaryDetailsSP();
         MonthlySalaryDetailsInfo infoMonthlySalaryDetails = new MonthlySalaryDetailsInfo();
         infoMonthlySalary.SalaryMonth            = Convert.ToDateTime(dtpSalaryMonth.Text);
         infoMonthlySalary.Narration              = txtNarration.Text.Trim();
         infoMonthlySalary.Extra1                 = string.Empty;
         infoMonthlySalary.Extra2                 = string.Empty;
         decMasterIdForEdit                       = spMonthlySalary.MonthlySalaryAddWithIdentity(infoMonthlySalary);
         infoMonthlySalaryDetails.MonthlySalaryId = decMasterIdForEdit;
         int RowCount = dgvMonthySalarySettings.RowCount;
         for (int i = 0; i < RowCount; i++)
         {
             if (dgvMonthySalarySettings.Rows[i].Cells["dgvtxtEmployeeId"].Value != null && dgvMonthySalarySettings.Rows[i].Cells["dgvtxtEmployeeId"].Value.ToString() != string.Empty)
             {
                 infoMonthlySalaryDetails.EmployeeId = Convert.ToDecimal(dgvMonthySalarySettings.Rows[i].Cells["dgvtxtEmployeeId"].Value.ToString());
                 if (dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].Value != null && dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].Value.ToString() != "0")
                 {
                     infoMonthlySalaryDetails.SalaryPackageId = Convert.ToDecimal(dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].Value.ToString());
                     infoMonthlySalaryDetails.Extra1          = string.Empty;
                     infoMonthlySalaryDetails.Extra2          = string.Empty;
                     infoMonthlySalaryDetails.MonthlySalaryId = decMasterIdForEdit;
                     spMonthlySalaryDetails.MonthlySalaryDetailsAddWithMonthlySalaryId(infoMonthlySalaryDetails);
                 }
             }
         }
         Messages.SavedMessage();
         GridFill();
         dtpSalaryMonth.Focus();
         btnDelete.Enabled = true;
         DeleteButtonEnableDisableChoose();
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "MSS7:" + ex.Message;
     }
 }
 /// <summary>
 /// Function to Enable/Disable delete button
 /// </summary>
 public void DeleteButtonEnableDisableChoose()
 {
     try
     {
         MonthlySalarySP spMonthlySalary = new MonthlySalarySP();
         if (spMonthlySalary.MonthlySalarySettingsMonthlySalaryIdSearchUsingSalaryMonth(Convert.ToDateTime(dtpSalaryMonth.Text)) > 0)
         {
             btnDelete.Enabled = true;
             btnSave.Text      = "Update";
         }
         else
         {
             btnDelete.Enabled = false;
             btnSave.Text      = "Save";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("MSS3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to Enable/Disable delete button
 /// </summary>
 public void DeleteButtonEnableDisableChoose()
 {
     try
     {
         MonthlySalarySP spMonthlySalary = new MonthlySalarySP();
         if (spMonthlySalary.MonthlySalarySettingsMonthlySalaryIdSearchUsingSalaryMonth(Convert.ToDateTime(dtpSalaryMonth.Text)) > 0)
         {
             btnDelete.Enabled = true;
             btnSave.Text      = "Update";
         }
         else
         {
             btnDelete.Enabled = false;
             btnSave.Text      = "Save";
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "MSS3:" + ex.Message;
     }
 }
        /// <summary>
        /// Function to delete
        /// </summary>
        public void DeleteFunction()
        {
            try
            {
                MonthlySalarySP spMonthlySalary = new MonthlySalarySP();
                if (!spMonthlySalary.CheckSalaryStatusForAdvancePayment(Convert.ToDecimal(cmbEmployee.SelectedValue.ToString()), dtpSalaryMonth.Value))
                {
                    AdvancePaymentInfo infoAdvancepayment = new AdvancePaymentInfo();
                    AdvancePaymentSP spAdvancePayment = new AdvancePaymentSP();
                    LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
                    spAdvancePayment.AdvancePaymentDelete(Convert.ToDecimal(decAdvancePaymentEditId.ToString()));
                    spLedgerPosting.LedgerPostDelete(txtAdvanceVoucherNo.Text.Trim(), decAdvancePaymentEditId);
                    Messages.DeletedMessage();
                    txtAdvanceVoucherNo.Focus();
                    Clear();
                    this.Close();
                }
                else
                {
                    Messages.ReferenceExistsMessage();
                    dtpSalaryMonth.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("AP14:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

        }
 /// <summary>
 /// Function for Delete
 /// </summary>
 public void DeleteFunction()
 {
     try
     {
         MonthlySalaryDetailsSP spMonthlySalaryDetails = new MonthlySalaryDetailsSP();
         MonthlySalarySP spMonthlySalary = new MonthlySalarySP();
         string strMonth = dtpSalaryMonth.Text;
         spMonthlySalary.MonthlySalaryDeleteAll(spMonthlySalary.MonthlySalarySettingsMonthlySalaryIdSearchUsingSalaryMonth(Convert.ToDateTime(dtpSalaryMonth.Text)));
         Messages.DeletedMessage();
         SalaryPackageComboFill();
         GridFill();
         UpdateDataGridViewRowColors();
         DeleteButtonEnableDisableChoose();
         dtpSalaryMonth.Focus();
     }
     catch (Exception ex)
     {
         MessageBox.Show("MSS5" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to fill Datagridview
        /// </summary>
        public void GridFill()
        {
            try
            {
                DataTable dtblMonthlySalaryDetails = new DataTable();
                MonthlySalarySP spMonthlySalary = new MonthlySalarySP();
                MonthlySalaryInfo infoMonthlySalary = new MonthlySalaryInfo();
                MonthlySalaryDetailsSP spMonthlySalaryDetails = new MonthlySalaryDetailsSP();
                MonthlySalaryDetailsInfo infoMonthlySalaryDetailsInfo = new MonthlySalaryDetailsInfo();
                dtblMonthlySalaryDetails = spMonthlySalary.MonthlySalarySettingsEmployeeViewAll(Convert.ToDateTime(dtpSalaryMonth.Text));
                dgvMonthySalarySettings.DataSource = dtblMonthlySalaryDetails;
                int inRowCount = dgvMonthySalarySettings.RowCount;
                string strNarration = string.Empty;
                for (int i = 0; i < inRowCount; i++)
                {
                    if (dgvMonthySalarySettings.Rows[i].Cells["dgvtxtnarration"].Value.ToString() != string.Empty)
                    {
                        strNarration = dgvMonthySalarySettings.Rows[i].Cells["dgvtxtnarration"].Value.ToString();

                    }
                }
                for (int i = 0; i < inRowCount; i++)
                {
                    //select default package for employee
                    if (dgvMonthySalarySettings.Rows[i].Cells["dgvtxtdefaultPackageId"].Value != null && dgvMonthySalarySettings.Rows[i].Cells["dgvtxtdefaultPackageId"].Value.ToString() != "")
                    {
                        dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].Value = dgvMonthySalarySettings.Rows[i].Cells["dgvtxtdefaultPackageId"].Value;
                    }
                }
                txtNarration.Text = strNarration;

            }
            catch (Exception ex)
            {
                MessageBox.Show("MSS4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function for Edit
        /// </summary>
        public void EditFunction()
        {
            try
            {
                MonthlySalarySP          spMonthlySalary          = new MonthlySalarySP();
                MonthlySalaryInfo        infoMonthlySalary        = new MonthlySalaryInfo();
                MonthlySalaryDetailsSP   spMonthlySalaryDetails   = new MonthlySalaryDetailsSP();
                MonthlySalaryDetailsInfo infoMonthlySalaryDetails = new MonthlySalaryDetailsInfo();
                EmployeeSP spEmployee = new EmployeeSP();
                infoMonthlySalary.SalaryMonth = Convert.ToDateTime(dtpSalaryMonth.Text);
                infoMonthlySalary.Narration   = txtNarration.Text.Trim();
                infoMonthlySalary.Extra1      = string.Empty;
                infoMonthlySalary.Extra2      = string.Empty;
                int RowCount = dgvMonthySalarySettings.RowCount;
                for (int i = 0; i <= RowCount - 1; i++)
                {
                    if (dgvMonthySalarySettings.Rows[i].Cells["dgvtxtMonthlySalaryId"].Value.ToString() != string.Empty)
                    {
                        decMasterIdForEdit = Convert.ToDecimal(dgvMonthySalarySettings.Rows[i].Cells["dgvtxtMonthlySalaryId"].Value.ToString());
                    }
                }
                infoMonthlySalary.MonthlySalaryId = decMasterIdForEdit;
                spMonthlySalary.MonthlySalarySettingsEdit(infoMonthlySalary);
                infoMonthlySalaryDetails.MonthlySalaryId = decMasterIdForEdit;
                for (int i = 0; i <= RowCount - 1; i++)
                {
                    if (dgvMonthySalarySettings.Rows[i].Cells["dgvtxtMonthlySalaryDetailsId"].Value.ToString() != string.Empty)
                    {
                        string st = dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].FormattedValue.ToString();
                        if (dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].FormattedValue.ToString() != "--Select--")
                        {
                            if (dgvMonthySalarySettings.Rows[i].Cells["dgvtxtEmployeeId"].Value != null && dgvMonthySalarySettings.Rows[i].Cells["dgvtxtEmployeeId"].Value.ToString() != string.Empty)
                            {
                                infoMonthlySalaryDetails.EmployeeId = Convert.ToDecimal(dgvMonthySalarySettings.Rows[i].Cells["dgvtxtEmployeeId"].Value.ToString());
                            }
                            if (dgvMonthySalarySettings.Rows[i].Cells["dgvtxtMonthlySalaryDetailsId"].Value != null && dgvMonthySalarySettings.Rows[i].Cells["dgvtxtMonthlySalaryDetailsId"].Value.ToString() != string.Empty)
                            {
                                infoMonthlySalaryDetails.MonthlySalaryDetailsId = Convert.ToDecimal(dgvMonthySalarySettings.Rows[i].Cells["dgvtxtMonthlySalaryDetailsId"].Value.ToString());
                            }
                            if (dgvMonthySalarySettings.Rows[i].Cells["dgvtxtMonthlySalaryId"].Value != null && dgvMonthySalarySettings.Rows[i].Cells["dgvtxtMonthlySalaryId"].Value.ToString() != "0")
                            {
                                infoMonthlySalaryDetails.MonthlySalaryId = Convert.ToDecimal(dgvMonthySalarySettings.Rows[i].Cells["dgvtxtMonthlySalaryId"].Value.ToString());
                            }
                            if (dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].Value != null && dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].Value.ToString() != "0")
                            {
                                infoMonthlySalaryDetails.SalaryPackageId = Convert.ToDecimal(dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].Value.ToString());
                                infoMonthlySalaryDetails.Extra1          = string.Empty;
                                infoMonthlySalaryDetails.Extra2          = string.Empty;
                                spEmployee.EmployeePackageEdit(infoMonthlySalaryDetails.EmployeeId, infoMonthlySalaryDetails.SalaryPackageId);
                                spMonthlySalaryDetails.MonthlySalaryDetailsEditUsingMasterIdAndDetailsId(infoMonthlySalaryDetails);
                            }
                        }
                        else
                        {
                            decimal decMonthlySalaryDetailsId = 0;
                            for (int j = 0; j < RowCount; j++)
                            {
                                if (dgvMonthySalarySettings.Rows[j].Cells["dgvtxtMonthlySalaryDetailsId"].Value != null && dgvMonthySalarySettings.Rows[j].Cells["dgvtxtMonthlySalaryDetailsId"].Value.ToString() != string.Empty)
                                {
                                    if (dgvMonthySalarySettings.Rows[j].Cells["dgvcmbPackage"].FormattedValue.ToString() == "--Select--")
                                    {
                                        decMonthlySalaryDetailsId = Convert.ToDecimal(dgvMonthySalarySettings.Rows[j].Cells["dgvtxtMonthlySalaryDetailsId"].Value.ToString());
                                        spMonthlySalaryDetails.MonthlySalarySettingsDetailsIdDelete(decMonthlySalaryDetailsId);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (dgvMonthySalarySettings.Rows[i].Cells["dgvtxtEmployeeId"].Value != null && dgvMonthySalarySettings.Rows[i].Cells["dgvtxtEmployeeId"].Value.ToString() != string.Empty)
                        {
                            infoMonthlySalaryDetails.EmployeeId = Convert.ToDecimal(dgvMonthySalarySettings.Rows[i].Cells["dgvtxtEmployeeId"].Value.ToString());

                            if (dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].Value != null && dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].Value.ToString() != "0")
                            {
                                infoMonthlySalaryDetails.SalaryPackageId = Convert.ToDecimal(dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].Value.ToString());
                                infoMonthlySalaryDetails.Extra1          = string.Empty;
                                infoMonthlySalaryDetails.Extra2          = string.Empty;
                                infoMonthlySalaryDetails.MonthlySalaryId = decMasterIdForEdit;
                                spMonthlySalaryDetails.MonthlySalaryDetailsAddWithMonthlySalaryId(infoMonthlySalaryDetails);
                            }
                        }
                    }
                }
                Messages.UpdatedMessage();
                GridFill();
                dtpSalaryMonth.Focus();
                btnDelete.Enabled = true;
                DeleteButtonEnableDisableChoose();
            }
            catch (Exception ex)
            {
                formMDI.infoError.ErrorString = "MSS8:" + ex.Message;
            }
        }
 /// <summary>
 /// On 'Print' button click for print
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnPrint_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvMonthlySalary.Rows.Count > 0)
         {
             DataSet ds = new DataSet();
             CompanySP spCompany = new CompanySP();
             DataTable dtblCompany = spCompany.CompanyViewDataTable(1);
             ds.Tables.Add(dtblCompany);
             MonthlySalarySP spMonthlySalary = new MonthlySalarySP();
             DataTable dtblMonthlySalary = spMonthlySalary.MonthlySalryViewAllForMonthlySalaryReports(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), cmbDesignation.Text, cmbEmployeeCode.Text, Convert.ToDateTime(dtpSalaryMonth.Value.ToString()));
             ds.Tables.Add(dtblMonthlySalary);
             frmReport frmReportObj = new frmReport();
             frmReportObj.MdiParent = formMDI.MDIObj;
             frmReportObj.MonthlySalaryReportPrinting(ds);
         }
         else
         {
             Messages.InformationMessage("No data found");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("MSR:9" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        public void SaveFunction()
        {
            try
            {
                AdvancePaymentSP spAdvancepayment = new AdvancePaymentSP();
                AdvancePaymentInfo infoAdvancepayment = new AdvancePaymentInfo();
                LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
                MonthlySalarySP spMonthlySalary = new MonthlySalarySP();
                if (CheckAdvanceAmount())
                {
                    if (!spMonthlySalary.CheckSalaryAlreadyPaidOrNotForAdvancePayment(Convert.ToDecimal(cmbEmployee.SelectedValue.ToString()), dtpSalaryMonth.Value))
                    {
                        if (!spAdvancepayment.CheckSalaryAlreadyPaidOrNot(Convert.ToDecimal(cmbEmployee.SelectedValue.ToString()), dtpSalaryMonth.Value))
                        {
                            if (isAutomatic == true)
                            {
                                infoAdvancepayment.VoucherNo = strVoucherNo;
                            }
                            else
                            {
                                infoAdvancepayment.VoucherNo = txtAdvanceVoucherNo.Text.Trim();
                            }
                            infoAdvancepayment.EmployeeId = Convert.ToDecimal(cmbEmployee.SelectedValue.ToString());
                            infoAdvancepayment.SalaryMonth = Convert.ToDateTime(dtpSalaryMonth.Text.ToString());
                            infoAdvancepayment.Chequenumber = txtCheckNo.Text.ToString();
                            infoAdvancepayment.Date = Convert.ToDateTime(txtDate.Text.ToString());
                            infoAdvancepayment.Amount = Convert.ToDecimal(txtAmount.Text.ToString());
                            if (isAutomatic)
                            {
                                infoAdvancepayment.InvoiceNo = strInvoiceNo;
                            }
                            else
                            {
                                infoAdvancepayment.InvoiceNo = txtAdvanceVoucherNo.Text.Trim();
                            }
                            infoAdvancepayment.LedgerId = Convert.ToDecimal(cmbCashOrBank.SelectedValue.ToString());
                            infoAdvancepayment.ChequeDate = Convert.ToDateTime(txtChequeDate.Text.ToString());
                            infoAdvancepayment.Narration = txtNarration.Text.Trim();
                            infoAdvancepayment.ExtraDate = Convert.ToDateTime(DateTime.Now.ToString());
                            infoAdvancepayment.Extra1 = string.Empty;
                            infoAdvancepayment.Extra2 = string.Empty;
                            infoAdvancepayment.VoucherTypeId = decPaymentVoucherTypeId;
                            infoAdvancepayment.SuffixPrefixId = decPaymentSuffixPrefixId;
                            infoAdvancepayment.FinancialYearId = PublicVariables._decCurrentFinancialYearId;

                            if (btnAdvancePaymentSave.Text == "Save")
                            {
                                if (decAdvancePaymentsId != -1)
                                {
                                    DataTable dtbl = new DataTable();
                                    dtbl = spAdvancepayment.AdvancePaymentAddWithIdentity(infoAdvancepayment, isAutomatic);
                                    foreach (DataRow dr in dtbl.Rows)
                                    {
                                        decAdvancePaymentId = Convert.ToDecimal(dr.ItemArray[0].ToString());
                                        strUpdatedVoucherNumber = dr.ItemArray[1].ToString();
                                        strUpdatedInvoiceNumber = dr.ItemArray[2].ToString();
                                    }
                                    if (!isAutomatic)
                                    {
                                        strVoucherNo = txtAdvanceVoucherNo.Text.Trim();
                                    }
                                    if (isAutomatic)
                                    {
                                        if (Convert.ToDecimal(strUpdatedVoucherNumber) != Convert.ToDecimal(strVoucherNo))
                                        {
                                            Messages.InformationMessage("Voucher number changed from  " + strInvoiceNo + "  to  " + strUpdatedInvoiceNumber);
                                            strVoucherNo = strUpdatedVoucherNumber.ToString();
                                            strInvoiceNo = strUpdatedInvoiceNumber;
                                        }
                                    }
                                    txtAdvanceVoucherNo.Focus();
                                }
                                LedgerPosting(Convert.ToDecimal(cmbCashOrBank.SelectedValue.ToString()), decAdvancePaymentId);
                                Messages.SavedMessage();
                                Clear();
                            }
                        }
                        else
                        {
                            Messages.InformationMessage(" Advance already paid for this month");
                            dtpSalaryMonth.Focus();
                        }
                    }
                    else
                    {
                        Messages.InformationMessage("Cant pay advance for this month,Salary already paid");
                        dtpSalaryMonth.Focus();
                    }
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("AP1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to Enable/Disable delete button
 /// </summary>
 public void DeleteButtonEnableDisableChoose()
 {
     try
     {
         MonthlySalarySP spMonthlySalary = new MonthlySalarySP();
         if (spMonthlySalary.MonthlySalarySettingsMonthlySalaryIdSearchUsingSalaryMonth(Convert.ToDateTime(dtpSalaryMonth.Text)) > 0)
         {
             btnDelete.Enabled = true;
             btnSave.Text = "Update";
         }
         else
         {
             btnDelete.Enabled = false;
             btnSave.Text = "Save";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("MSS3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// On 'Delete' button click
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, this.Name, btnDelete.Text))
         {
             MonthlySalarySP spMonthlySalary = new MonthlySalarySP();
             if (spMonthlySalary.MonthlySalarySettingsMonthlySalaryIdSearchUsingSalaryMonth(Convert.ToDateTime(dtpSalaryMonth.Text)) > 0)
             {
                 Delete();
             }
             else
             {
                 btnDelete.Enabled = false;
             }
         }
         else
         {
             Messages.NoPrivillageMessage();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("MSS14" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function for Edit
        /// </summary>
        public void EditFunction()
        {
            try
            {
                MonthlySalarySP spMonthlySalary = new MonthlySalarySP();
                MonthlySalaryInfo infoMonthlySalary = new MonthlySalaryInfo();
                MonthlySalaryDetailsSP spMonthlySalaryDetails = new MonthlySalaryDetailsSP();
                MonthlySalaryDetailsInfo infoMonthlySalaryDetails = new MonthlySalaryDetailsInfo();
                EmployeeSP spEmployee = new EmployeeSP();
                infoMonthlySalary.SalaryMonth = Convert.ToDateTime(dtpSalaryMonth.Text);
                infoMonthlySalary.Narration = txtNarration.Text.Trim();
                infoMonthlySalary.Extra1 = string.Empty;
                infoMonthlySalary.Extra2 = string.Empty;
                int RowCount = dgvMonthySalarySettings.RowCount;
                for (int i = 0; i <= RowCount - 1; i++)
                {
                    if (dgvMonthySalarySettings.Rows[i].Cells["dgvtxtMonthlySalaryId"].Value.ToString() != string.Empty)
                    {
                        decMasterIdForEdit = Convert.ToDecimal(dgvMonthySalarySettings.Rows[i].Cells["dgvtxtMonthlySalaryId"].Value.ToString());
                    }
                }
                infoMonthlySalary.MonthlySalaryId = decMasterIdForEdit;
                spMonthlySalary.MonthlySalarySettingsEdit(infoMonthlySalary);
                infoMonthlySalaryDetails.MonthlySalaryId = decMasterIdForEdit;
                for (int i = 0; i <= RowCount - 1; i++)
                {
                    if (dgvMonthySalarySettings.Rows[i].Cells["dgvtxtMonthlySalaryDetailsId"].Value.ToString() != string.Empty)
                    {
                        string st = dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].FormattedValue.ToString();
                        if (dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].FormattedValue.ToString() != "--Select--")
                        {
                            if (dgvMonthySalarySettings.Rows[i].Cells["dgvtxtEmployeeId"].Value != null && dgvMonthySalarySettings.Rows[i].Cells["dgvtxtEmployeeId"].Value.ToString() != string.Empty)
                            {
                                infoMonthlySalaryDetails.EmployeeId = Convert.ToDecimal(dgvMonthySalarySettings.Rows[i].Cells["dgvtxtEmployeeId"].Value.ToString());
                            }
                            if (dgvMonthySalarySettings.Rows[i].Cells["dgvtxtMonthlySalaryDetailsId"].Value != null && dgvMonthySalarySettings.Rows[i].Cells["dgvtxtMonthlySalaryDetailsId"].Value.ToString() != string.Empty)
                            {
                                infoMonthlySalaryDetails.MonthlySalaryDetailsId = Convert.ToDecimal(dgvMonthySalarySettings.Rows[i].Cells["dgvtxtMonthlySalaryDetailsId"].Value.ToString());
                            }
                            if (dgvMonthySalarySettings.Rows[i].Cells["dgvtxtMonthlySalaryId"].Value != null && dgvMonthySalarySettings.Rows[i].Cells["dgvtxtMonthlySalaryId"].Value.ToString() != "0")
                            {
                                infoMonthlySalaryDetails.MonthlySalaryId = Convert.ToDecimal(dgvMonthySalarySettings.Rows[i].Cells["dgvtxtMonthlySalaryId"].Value.ToString());
                            }
                            if (dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].Value != null && dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].Value.ToString() != "0")
                            {
                                infoMonthlySalaryDetails.SalaryPackageId = Convert.ToDecimal(dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].Value.ToString());
                                infoMonthlySalaryDetails.Extra1 = string.Empty;
                                infoMonthlySalaryDetails.Extra2 = string.Empty;
                                spEmployee.EmployeePackageEdit(infoMonthlySalaryDetails.EmployeeId, infoMonthlySalaryDetails.SalaryPackageId);
                                spMonthlySalaryDetails.MonthlySalaryDetailsEditUsingMasterIdAndDetailsId(infoMonthlySalaryDetails);
                            }
                        }
                        else
                        {
                            decimal decMonthlySalaryDetailsId = 0;
                            for (int j = 0; j < RowCount; j++)
                            {
                                if (dgvMonthySalarySettings.Rows[j].Cells["dgvtxtMonthlySalaryDetailsId"].Value != null && dgvMonthySalarySettings.Rows[j].Cells["dgvtxtMonthlySalaryDetailsId"].Value.ToString() != string.Empty)
                                {
                                    if (dgvMonthySalarySettings.Rows[j].Cells["dgvcmbPackage"].FormattedValue.ToString() == "--Select--")
                                    {
                                        decMonthlySalaryDetailsId = Convert.ToDecimal(dgvMonthySalarySettings.Rows[j].Cells["dgvtxtMonthlySalaryDetailsId"].Value.ToString());
                                        spMonthlySalaryDetails.MonthlySalarySettingsDetailsIdDelete(decMonthlySalaryDetailsId);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (dgvMonthySalarySettings.Rows[i].Cells["dgvtxtEmployeeId"].Value != null && dgvMonthySalarySettings.Rows[i].Cells["dgvtxtEmployeeId"].Value.ToString() != string.Empty)
                        {
                            infoMonthlySalaryDetails.EmployeeId = Convert.ToDecimal(dgvMonthySalarySettings.Rows[i].Cells["dgvtxtEmployeeId"].Value.ToString());

                            if (dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].Value != null && dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].Value.ToString() != "0")
                            {
                                infoMonthlySalaryDetails.SalaryPackageId = Convert.ToDecimal(dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].Value.ToString());
                                infoMonthlySalaryDetails.Extra1 = string.Empty;
                                infoMonthlySalaryDetails.Extra2 = string.Empty;
                                infoMonthlySalaryDetails.MonthlySalaryId = decMasterIdForEdit;
                                spMonthlySalaryDetails.MonthlySalaryDetailsAddWithMonthlySalaryId(infoMonthlySalaryDetails);
                            }
                        }
                    }
                }
                Messages.UpdatedMessage();
                GridFill();
                dtpSalaryMonth.Focus();
                btnDelete.Enabled = true;
                DeleteButtonEnableDisableChoose();
            }
            catch (Exception ex)
            {
                MessageBox.Show("MSS8" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function for Save
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         MonthlySalarySP spMonthlySalary = new MonthlySalarySP();
         MonthlySalaryInfo infoMonthlySalary = new MonthlySalaryInfo();
         MonthlySalaryDetailsSP spMonthlySalaryDetails = new MonthlySalaryDetailsSP();
         MonthlySalaryDetailsInfo infoMonthlySalaryDetails = new MonthlySalaryDetailsInfo();
         infoMonthlySalary.SalaryMonth = Convert.ToDateTime(dtpSalaryMonth.Text);
         infoMonthlySalary.Narration = txtNarration.Text.Trim();
         infoMonthlySalary.Extra1 = string.Empty;
         infoMonthlySalary.Extra2 = string.Empty;
         decMasterIdForEdit = spMonthlySalary.MonthlySalaryAddWithIdentity(infoMonthlySalary);
         infoMonthlySalaryDetails.MonthlySalaryId = decMasterIdForEdit;
         int RowCount = dgvMonthySalarySettings.RowCount;
         for (int i = 0; i < RowCount; i++)
         {
             if (dgvMonthySalarySettings.Rows[i].Cells["dgvtxtEmployeeId"].Value != null && dgvMonthySalarySettings.Rows[i].Cells["dgvtxtEmployeeId"].Value.ToString() != string.Empty)
             {
                 infoMonthlySalaryDetails.EmployeeId = Convert.ToDecimal(dgvMonthySalarySettings.Rows[i].Cells["dgvtxtEmployeeId"].Value.ToString());
                 if (dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].Value != null && dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].Value.ToString() != "0")
                 {
                     infoMonthlySalaryDetails.SalaryPackageId = Convert.ToDecimal(dgvMonthySalarySettings.Rows[i].Cells["dgvcmbPackage"].Value.ToString());
                     infoMonthlySalaryDetails.Extra1 = string.Empty;
                     infoMonthlySalaryDetails.Extra2 = string.Empty;
                     infoMonthlySalaryDetails.MonthlySalaryId = decMasterIdForEdit;
                     spMonthlySalaryDetails.MonthlySalaryDetailsAddWithMonthlySalaryId(infoMonthlySalaryDetails);
                 }
             }
         }
         Messages.SavedMessage();
         GridFill();
         dtpSalaryMonth.Focus();
         btnDelete.Enabled = true;
         DeleteButtonEnableDisableChoose();
     }
     catch (Exception ex)
     {
         MessageBox.Show("MSS7" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to edit
        /// </summary>
        public void EditFunction()
        {
            try
            {
                MonthlySalarySP spMonthlySalary = new MonthlySalarySP();
                if (!spMonthlySalary.CheckSalaryStatusForAdvancePayment(Convert.ToDecimal(cmbEmployee.SelectedValue.ToString()), dtpSalaryMonth.Value))
                {


                    AdvancePaymentSP spAdvancepayment = new AdvancePaymentSP();
                    AdvancePaymentInfo infoAdvancepayment = new AdvancePaymentInfo();
                    LedgerPostingSP spLedgerPosting = new LedgerPostingSP();

                    if (spAdvancepayment.CheckSalaryAlreadyPaidOrNot(Convert.ToDecimal(cmbEmployee.SelectedValue.ToString()), dtpSalaryMonth.Value))
                    {
                        txtAmount.ReadOnly = true;
                    }


                    infoAdvancepayment.AdvancePaymentId = (Convert.ToDecimal(decAdvancePaymentEditId.ToString()));
                    infoAdvancepayment.EmployeeId = Convert.ToDecimal(cmbEmployee.SelectedValue.ToString());
                    infoAdvancepayment.SalaryMonth = Convert.ToDateTime(dtpSalaryMonth.Text.ToString());
                    infoAdvancepayment.Chequenumber = txtCheckNo.Text.ToString();
                    infoAdvancepayment.Date = Convert.ToDateTime(txtDate.Text.ToString());
                    infoAdvancepayment.Amount = Convert.ToDecimal(txtAmount.Text.ToString());
                    if (CheckAdvanceAmount())
                    {
                        if (isAutomatic)
                        {
                            infoAdvancepayment.VoucherNo = strVoucherNo;
                        }
                        else
                        {
                            infoAdvancepayment.VoucherNo = txtAdvanceVoucherNo.Text.Trim();
                        }
                        if (isAutomatic)
                        {
                            infoAdvancepayment.InvoiceNo = strInvoiceNo;
                        }
                        else
                        {
                            infoAdvancepayment.InvoiceNo = txtAdvanceVoucherNo.Text.Trim();
                        }
                        infoAdvancepayment.LedgerId = Convert.ToDecimal(cmbCashOrBank.SelectedValue.ToString());
                        infoAdvancepayment.ChequeDate = Convert.ToDateTime(txtChequeDate.Text.ToString());
                        infoAdvancepayment.Narration = txtNarration.Text.Trim();
                        infoAdvancepayment.ExtraDate = Convert.ToDateTime(DateTime.Now.ToString());
                        infoAdvancepayment.Extra1 = string.Empty;
                        infoAdvancepayment.Extra2 = string.Empty;
                        infoAdvancepayment.VoucherTypeId = decPaymentVoucherTypeId;
                        infoAdvancepayment.SuffixPrefixId = decPaymentSuffixPrefixId;
                        infoAdvancepayment.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                        spAdvancepayment.AdvancePaymentEdit(infoAdvancepayment);
                        LedgerUpdate();
                        Messages.UpdatedMessage();
                        txtAdvanceVoucherNo.Focus();
                        this.Close();
                    }
                }
                else
                {
                    Messages.ReferenceExistsMessageForUpdate();
                    dtpSalaryMonth.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("AP3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }