Пример #1
0
 /// <summary>
 /// Function to Update values in MonthlySalary Table
 /// </summary>
 /// <param name="monthlysalaryinfo"></param>
 public void MonthlySalaryEdit(MonthlySalaryInfo monthlysalaryinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("MonthlySalaryEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@monthlySalaryId", SqlDbType.Decimal);
         sprmparam.Value = monthlysalaryinfo.MonthlySalaryId;
         sprmparam       = sccmd.Parameters.Add("@salaryMonth", SqlDbType.DateTime);
         sprmparam.Value = monthlysalaryinfo.SalaryMonth;
         sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = monthlysalaryinfo.Narration;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = monthlysalaryinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = monthlysalaryinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Пример #2
0
 /// <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);
     }
 }
Пример #3
0
 /// <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);
     }
 }
Пример #4
0
        /// <summary>
        /// Function to get particular values from MonthlySalary Table based on the parameter
        /// </summary>
        /// <param name="monthlySalaryId"></param>
        /// <returns></returns>
        public MonthlySalaryInfo MonthlySalaryView(decimal monthlySalaryId)
        {
            MonthlySalaryInfo monthlysalaryinfo = new MonthlySalaryInfo();
            SqlDataReader     sdrreader         = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("MonthlySalaryView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@monthlySalaryId", SqlDbType.Decimal);
                sprmparam.Value = monthlySalaryId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    monthlysalaryinfo.MonthlySalaryId = Convert.ToDecimal(sdrreader[0].ToString());
                    monthlysalaryinfo.SalaryMonth     = Convert.ToDateTime(sdrreader[1].ToString());
                    monthlysalaryinfo.Narration       = sdrreader[2].ToString();
                    monthlysalaryinfo.ExtraDate       = Convert.ToDateTime(sdrreader[3].ToString());
                    monthlysalaryinfo.Extra1          = sdrreader[4].ToString();
                    monthlysalaryinfo.Extra2          = sdrreader[5].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(monthlysalaryinfo);
        }
Пример #5
0
        /// <summary>
        /// Function to insert values to MonthlySalary Table and return the Curresponding row's Id
        /// </summary>
        /// <param name="monthlysalaryinfo"></param>
        /// <returns></returns>
        public decimal MonthlySalaryAddWithIdentity(MonthlySalaryInfo monthlysalaryinfo)
        {
            decimal decIdentity = 0;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("MonthlySalaryAddWithIdentity", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@salaryMonth", SqlDbType.DateTime);
                sprmparam.Value = monthlysalaryinfo.SalaryMonth;
                sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam.Value = monthlysalaryinfo.Narration;
                sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value = monthlysalaryinfo.Extra1;
                sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value = monthlysalaryinfo.Extra2;
                object obj = sccmd.ExecuteScalar();
                if (obj != null)
                {
                    decIdentity = Convert.ToDecimal(obj.ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(decIdentity);
        }
Пример #6
0
        /// <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);
            }
        }