/// <summary>
 /// Function to Update values in DailyAttendanceMaster Table
 /// </summary>
 /// <param name="dailyattendancemasterinfo"></param>
 public void DailyAttendanceMasterEdit(DailyAttendanceMasterInfo dailyattendancemasterinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("DailyAttendanceMasterEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@dailyAttendanceMasterId", SqlDbType.Decimal);
         sprmparam.Value = dailyattendancemasterinfo.DailyAttendanceMasterId;
         sprmparam       = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = dailyattendancemasterinfo.Date;
         sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = dailyattendancemasterinfo.Narration;
         sprmparam       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = dailyattendancemasterinfo.ExtraDate;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = dailyattendancemasterinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = dailyattendancemasterinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         Messages.ErrorMessage(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Example #2
0
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         DailyAttendanceDetailsInfo infoDailyAttendanceDetails = new DailyAttendanceDetailsInfo();
         DailyAttendanceDetailsSP   spDailyAttendanceDetails   = new DailyAttendanceDetailsSP();
         DailyAttendanceMasterInfo  infoDailyAttendanceMaster  = new DailyAttendanceMasterInfo();
         DailyAttendanceMasterSP    spDailyAttendanceMaster    = new DailyAttendanceMasterSP();
         string strDate = txtCompanyCurrentdate.Text;
         if (spDailyAttendanceMaster.DailyAttendanceMasterMasterIdSearch(strDate))
         {
             DataTable dtblAttendance = new DataTable();
             infoDailyAttendanceMaster.Date = Convert.ToDateTime(txtCompanyCurrentdate.Text.ToString());
             dtblAttendance           = spDailyAttendanceDetails.DailyAttendanceDetailsSearchGridFill(txtCompanyCurrentdate.Text.ToString());
             dgvAttendance.DataSource = dtblAttendance;
             btnDelete.Enabled        = true;
             btnSave.Text             = "Update";
             int    inRowCount         = dgvAttendance.RowCount;
             string strMasterNarration = string.Empty;
             for (int i = 0; i < inRowCount; i++)
             {
                 if (dgvAttendance.Rows[i].Cells["MasterNarration"].Value.ToString() != "")
                 {
                     strMasterNarration = dgvAttendance.Rows[i].Cells["MasterNarration"].Value.ToString();
                 }
             }
             txtNarrationInMaster.Text = strMasterNarration;
         }
         else
         {
             DataTable dtblAttendance = new DataTable();
             dtblAttendance           = spDailyAttendanceDetails.DailyAttendanceDetailsSearchGridFill(txtCompanyCurrentdate.Text.ToString());
             dgvAttendance.DataSource = dtblAttendance;
             btnDelete.Enabled        = false;
             btnSave.Text             = "Save";
             int    inRowCount         = dgvAttendance.RowCount;
             string strMasterNarration = string.Empty;
             for (int i = 0; i < inRowCount; i++)
             {
                 if (dgvAttendance.Rows[i].Cells["MasterNarration"].Value.ToString() != null)
                 {
                     strMasterNarration = dgvAttendance.Rows[i].Cells["MasterNarration"].Value.ToString();
                 }
             }
             txtNarrationInMaster.Text = strMasterNarration;
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "A1:" + ex.Message;
     }
 }
        /// <summary>
        /// Function to add Daily Attendance Add To its Master table
        /// </summary>
        /// <param name="dailyattendancemasterinfo"></param>
        /// <returns></returns>
        public decimal DailyAttendanceAddToMaster(DailyAttendanceMasterInfo dailyattendancemasterinfo)
        {
            decimal incount = 0;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("DailyAttendanceAddToMaster", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
                sprmparam.Value = dailyattendancemasterinfo.Date;
                sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam.Value = dailyattendancemasterinfo.Narration;
                sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value = dailyattendancemasterinfo.Extra1;
                sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value = dailyattendancemasterinfo.Extra2;
                Object obj = sccmd.ExecuteScalar();
                if (obj != null)
                {
                    incount = decimal.Parse(obj.ToString());
                }
                {
                }
            }
            catch (Exception ex)
            {
                Messages.ErrorMessage(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(incount);
        }
        /// <summary>
        /// Function to get particular values from DailyAttendanceMaster Table based on the parameter
        /// </summary>
        /// <param name="dailyAttendanceMasterId"></param>
        /// <returns></returns>
        public DailyAttendanceMasterInfo DailyAttendanceMasterView(decimal dailyAttendanceMasterId)
        {
            DailyAttendanceMasterInfo dailyattendancemasterinfo = new DailyAttendanceMasterInfo();
            SqlDataReader             sdrreader = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("DailyAttendanceMasterView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@dailyAttendanceMasterId", SqlDbType.Decimal);
                sprmparam.Value = dailyAttendanceMasterId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    dailyattendancemasterinfo.DailyAttendanceMasterId = decimal.Parse(sdrreader[0].ToString());
                    dailyattendancemasterinfo.Date      = DateTime.Parse(sdrreader[1].ToString());
                    dailyattendancemasterinfo.Narration = sdrreader[2].ToString();
                    dailyattendancemasterinfo.ExtraDate = DateTime.Parse(sdrreader[3].ToString());
                    dailyattendancemasterinfo.Extra1    = sdrreader[4].ToString();
                    dailyattendancemasterinfo.Extra2    = sdrreader[5].ToString();
                }
            }
            catch (Exception ex)
            {
                Messages.ErrorMessage(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(dailyattendancemasterinfo);
        }
Example #5
0
        //Function to edit
        public void EditFunction()
        {
            try
            {
                decimal decResult = HolidaySettings();
                if (decResult != 1)
                {
                    DailyAttendanceDetailsInfo infoDailyAttendanceDetails = new DailyAttendanceDetailsInfo();
                    DailyAttendanceDetailsSP   spDailyAttendanceDetails   = new DailyAttendanceDetailsSP();
                    DailyAttendanceMasterInfo  infoDailyAttendanceMaster  = new DailyAttendanceMasterInfo();
                    DailyAttendanceMasterSP    spDailyAttendanceMaster    = new DailyAttendanceMasterSP();
                    infoDailyAttendanceMaster.Date      = DateTime.Parse(txtCompanyCurrentdate.Text.ToString());
                    infoDailyAttendanceMaster.Narration = txtNarrationInMaster.Text.Trim();
                    infoDailyAttendanceMaster.Extra1    = string.Empty;
                    infoDailyAttendanceMaster.Extra2    = string.Empty;
                    int inrowcount = dgvAttendance.RowCount;
                    for (int i = 0; i <= inrowcount - 1; i++)
                    {
                        if (dgvAttendance.Rows[i].Cells["dgvtxtdailyAttendanceMasterId"].Value.ToString() != "")
                        {
                            decMasterIdForEdit = Convert.ToDecimal(dgvAttendance.Rows[i].Cells["dgvtxtdailyAttendanceMasterId"].Value.ToString());   //storing Dailymasterid
                        }
                    }
                    infoDailyAttendanceMaster.DailyAttendanceMasterId = decMasterIdForEdit;
                    spDailyAttendanceMaster.DailyAttendanceEditMaster(infoDailyAttendanceMaster);
                    infoDailyAttendanceDetails.DailyAttendanceMasterId = decMasterIdForEdit;
                    for (int i = 0; i <= inrowcount - 1; i++)
                    {
                        if (dgvAttendance.Rows[i].Cells["dgvtxtDailyAttendanceDetailsId"].Value.ToString() != "")
                        {
                            // for updation of saved employees
                            if (dgvAttendance.Rows[i].Cells["dgvtxtColumnEmployeeId"].Value != null && dgvAttendance.Rows[i].Cells["dgvtxtColumnEmployeeId"].Value.ToString() != "")
                            {
                                infoDailyAttendanceDetails.EmployeeId = Convert.ToDecimal(dgvAttendance.Rows[i].Cells["dgvtxtColumnEmployeeId"].Value.ToString());
                            }
                            if (dgvAttendance.Rows[i].Cells["dgvtxtDailyAttendanceDetailsId"].Value != null && dgvAttendance.Rows[i].Cells["dgvtxtDailyAttendanceDetailsId"].Value.ToString() != "")
                            {
                                infoDailyAttendanceDetails.DailyAttendanceDetailsId = Convert.ToDecimal(dgvAttendance.Rows[i].Cells["dgvtxtDailyAttendanceDetailsId"].Value.ToString());
                            }
                            if (dgvAttendance.Rows[i].Cells["dgvtxtdailyAttendanceMasterId"].Value != null && dgvAttendance.Rows[i].Cells["dgvtxtdailyAttendanceMasterId"].Value.ToString() != "")
                            {
                                infoDailyAttendanceDetails.DailyAttendanceMasterId = Convert.ToDecimal(dgvAttendance.Rows[i].Cells["dgvtxtdailyAttendanceMasterId"].Value.ToString());
                            }
                            if (dgvAttendance.Rows[i].Cells["dgvcmbcolumnStatus"].Value != null &&
                                dgvAttendance.Rows[i].Cells["dgvcmbcolumnStatus"].Value.ToString() != "")
                            {
                                infoDailyAttendanceDetails.Status = dgvAttendance.Rows[i].Cells["dgvcmbcolumnStatus"].Value.ToString();
                            }
                            else
                            {
                                infoDailyAttendanceDetails.Status = "Present";
                            }
                            if (dgvAttendance.Rows[i].Cells["dgvtxtColumnnarration"].Value != null &&
                                dgvAttendance.Rows[i].Cells["dgvtxtColumnnarration"].Value.ToString() != "")
                            {
                                infoDailyAttendanceDetails.Narration = dgvAttendance.Rows[i].Cells["dgvtxtColumnnarration"].Value.ToString();
                            }
                            else
                            {
                                infoDailyAttendanceDetails.Narration = "";
                            }
                            infoDailyAttendanceDetails.Extra1 = string.Empty;
                            infoDailyAttendanceDetails.Extra2 = string.Empty;
                            spDailyAttendanceDetails.DailyAttendanceDetailsEditUsingMasterId(infoDailyAttendanceDetails);
                        }
                        else
                        {
                            // for new employees to add
                            if (dgvAttendance.Rows[i].Cells["dgvtxtColumnEmployeeId"].Value != null && dgvAttendance.Rows[i].Cells["dgvtxtColumnEmployeeId"].Value.ToString() != "")
                            {
                                infoDailyAttendanceDetails.EmployeeId = Convert.ToDecimal(dgvAttendance.Rows[i].Cells["dgvtxtColumnEmployeeId"].Value.ToString());
                            }
                            if (dgvAttendance.Rows[i].Cells["dgvcmbcolumnStatus"].Value != null &&
                                dgvAttendance.Rows[i].Cells["dgvcmbcolumnStatus"].Value.ToString() != "")
                            {
                                infoDailyAttendanceDetails.Status = dgvAttendance.Rows[i].Cells["dgvcmbcolumnStatus"].Value.ToString();
                            }
                            else
                            {
                                infoDailyAttendanceDetails.Status = "Present";
                            }
                            if (dgvAttendance.Rows[i].Cells["dgvtxtColumnnarration"].Value != null &&
                                dgvAttendance.Rows[i].Cells["dgvtxtColumnnarration"].Value.ToString() != "")
                            {
                                infoDailyAttendanceDetails.Narration = dgvAttendance.Rows[i].Cells["dgvtxtColumnnarration"].Value.ToString();
                            }
                            else
                            {
                                infoDailyAttendanceDetails.Narration = "";
                            }
                            infoDailyAttendanceDetails.Extra1 = string.Empty;
                            infoDailyAttendanceDetails.Extra2 = string.Empty;
                            infoDailyAttendanceDetails.DailyAttendanceMasterId = decMasterIdForEdit;
                            spDailyAttendanceDetails.DailyAttendanceDetailsAddUsingMasterId(infoDailyAttendanceDetails);
                        }
                    } //   updation of old employees & addition of new employees closes here
                    Messages.UpdatedMessage();
                    Clear();
                }
                else
                {
                    Messages.InformationMessage("Selected date is holiday");
                }
            }

            catch (Exception ex)
            {
                formMDI.infoError.ErrorString = "A3:" + ex.Message;
            }
        }
Example #6
0
        /// <summary>
        /// Function to save
        /// </summary>
        public void SaveFunction()
        {
            try
            {
                decimal decResult = HolidaySettings();
                if (decResult != 1)
                {
                    DailyAttendanceDetailsInfo infoDailyAttendanceDetails = new DailyAttendanceDetailsInfo();
                    DailyAttendanceDetailsSP   spDailyAttendanceDetails   = new DailyAttendanceDetailsSP();
                    DailyAttendanceMasterInfo  infoDailyAttendanceMaster  = new DailyAttendanceMasterInfo();
                    DailyAttendanceMasterSP    spDailyAttendanceMaster    = new DailyAttendanceMasterSP();
                    infoDailyAttendanceMaster.Date      = Convert.ToDateTime(txtCompanyCurrentdate.Text.ToString());
                    infoDailyAttendanceMaster.Narration = txtNarrationInMaster.Text.Trim();
                    infoDailyAttendanceMaster.Extra1    = string.Empty;
                    infoDailyAttendanceMaster.Extra2    = string.Empty;
                    int inrowcount = dgvAttendance.RowCount;
                    decMasterIdForEdit = spDailyAttendanceMaster.DailyAttendanceAddToMaster(infoDailyAttendanceMaster);  // calling @@identity
                    infoDailyAttendanceDetails.DailyAttendanceMasterId = decMasterIdForEdit;
                    for (int i = 0; i <= inrowcount - 1; i++)
                    {
                        if (dgvAttendance.Rows[i].Cells["dgvtxtColumnEmployeeId"].Value != null && dgvAttendance.Rows[i].Cells["dgvtxtColumnEmployeeId"].Value.ToString() != "")
                        {
                            infoDailyAttendanceDetails.EmployeeId = Convert.ToDecimal(dgvAttendance.Rows[i].Cells["dgvtxtColumnEmployeeId"].Value.ToString());
                        }
                        if (dgvAttendance.Rows[i].Cells["dgvcmbcolumnStatus"].Value != null &&
                            dgvAttendance.Rows[i].Cells["dgvcmbcolumnStatus"].Value.ToString() != "")
                        {
                            infoDailyAttendanceDetails.Status = dgvAttendance.Rows[i].Cells["dgvcmbcolumnStatus"].Value.ToString();
                        }
                        else
                        {
                            infoDailyAttendanceDetails.Status = "Present";
                        }
                        if (dgvAttendance.Rows[i].Cells["dgvtxtColumnnarration"].Value != null &&
                            dgvAttendance.Rows[i].Cells["dgvtxtColumnnarration"].Value.ToString() != "")
                        {
                            infoDailyAttendanceDetails.Narration = dgvAttendance.Rows[i].Cells["dgvtxtColumnnarration"].Value.ToString();
                        }
                        else
                        {
                            infoDailyAttendanceDetails.Narration = "";
                        }
                        infoDailyAttendanceDetails.Extra1 = string.Empty;
                        infoDailyAttendanceDetails.Extra2 = string.Empty;
                        infoDailyAttendanceDetails.DailyAttendanceMasterId = decMasterIdForEdit;
                        spDailyAttendanceDetails.DailyAttendanceDetailsAddUsingMasterId(infoDailyAttendanceDetails);
                    }
                    Messages.SavedMessage();
                    Clear();
                }
                else
                {
                    Messages.InformationMessage("Selected date is holiday");
                }
            }

            catch (Exception ex)
            {
                formMDI.infoError.ErrorString = "A2:" + ex.Message;
            }
        }