/// <summary>
 /// Function to fill Employee combobox
 /// </summary>
 public void FillEmployee()
 {
     try
     {
         List<DataTable> listObj = new List<DataTable>();
         EmployeeCreationBll BllEmployeeCreation = new EmployeeCreationBll();
         listObj = BllEmployeeCreation.EmployeeViewForPaySlip();
         DataRow dr = listObj[0].NewRow();
         dr[1] = "--Select--";
         listObj[0].Rows.InsertAt(dr, 0);
         cmbEmployee.DataSource = listObj[0];
         cmbEmployee.ValueMember = "employeeId";
         cmbEmployee.DisplayMember = "employeeName";
     }
     catch (Exception ex)
     {
         MessageBox.Show("PS 1: " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function for save
        /// </summary>
        public void SaveFunction()
        {
            try
            {
                EmployeeInfo infoEmployee = new EmployeeInfo();
                EmployeeCreationBll BllEmployeeCreation = new EmployeeCreationBll();
                infoEmployee.EmployeeCode = txtEmployeeCode.Text.Trim();
                infoEmployee.EmployeeName = txtEmployeeName.Text.Trim();
                infoEmployee.DesignationId = Convert.ToDecimal(cmbDesignation.SelectedValue.ToString());
                infoEmployee.Dob = Convert.ToDateTime(dtpDob.Text.ToString());
                infoEmployee.MaritalStatus = (cmbMaritalStatus.Text.ToString()).TrimEnd();
                if (cmbGender.Text != string.Empty)
                {
                    infoEmployee.Gender = (cmbGender.SelectedItem.ToString()).TrimEnd();
                }
                else
                {
                    infoEmployee.Gender = cmbGender.Text.ToString();
                }
                infoEmployee.Qualification = txtQualification.Text.Trim();
                infoEmployee.Address = txtAddress.Text.Trim();
                infoEmployee.PhoneNumber = txtPhoneNumber.Text.Trim();
                infoEmployee.MobileNumber = txtMobileNumber.Text.Trim();
                infoEmployee.Email = txtEmail.Text.Trim();
                infoEmployee.JoiningDate = Convert.ToDateTime(txtJoiningDate.Text.ToString());
                infoEmployee.TerminationDate = Convert.ToDateTime(txtTerminationDate.Text.ToString());
                if (cbxActive.Checked)
                {
                    infoEmployee.IsActive = true;
                }
                else
                {
                    infoEmployee.IsActive = false;
                }
                infoEmployee.Narration = txtNarration.Text.Trim();
                infoEmployee.BloodGroup = (cmbBloodGroup.Text.ToString()).TrimEnd();
                infoEmployee.PassportNo = txtPassportNumber.Text.Trim();
                infoEmployee.PassportExpiryDate = Convert.ToDateTime(dtpPassportExpiryDate.Text.ToString());
                infoEmployee.VisaNumber = txtVisaNumber.Text.Trim();
                infoEmployee.VisaExpiryDate = Convert.ToDateTime(dtpVisaExpiryDate.Text.ToString());
                infoEmployee.LabourCardNumber = txtlabourCardNumber.Text.Trim();
                infoEmployee.LabourCardExpiryDate = Convert.ToDateTime(dtpLabourCardExpiryDate.Text.ToString());
                infoEmployee.SalaryType = (cmbSalaryType.SelectedItem.ToString()).TrimEnd();
                if (cmbSalaryType.SelectedItem.ToString() == "Daily wage")
                {
                    if (txtDailyWage.Text.Trim() != string.Empty)
                    {
                        infoEmployee.DailyWage = Convert.ToDecimal(txtDailyWage.Text.ToString());
                    }

                }
                else
                {
                    if (cmbDefaultPackage.Text != string.Empty)
                    {
                        infoEmployee.DefaultPackageId = Convert.ToDecimal(cmbDefaultPackage.SelectedValue.ToString());
                    }
                }
                infoEmployee.BankName = txtBankName.Text.Trim();
                infoEmployee.BankAccountNumber = txtBankAccountNumber.Text.Trim();
                infoEmployee.BranchName = txtBranch.Text.Trim();
                infoEmployee.BranchCode = txtBranchCode.Text.Trim();
                infoEmployee.PanNumber = txtPanNumber.Text.Trim();
                infoEmployee.PfNumber = txtPfNumber.Text.Trim();
                infoEmployee.EsiNumber = txtEsiNumber.Text.Trim();
                infoEmployee.ExtraDate = DateTime.Now;
                infoEmployee.Extra1 = string.Empty;
                infoEmployee.Extra2 = string.Empty;
                if (BllEmployeeCreation.EmployeeCodeCheckExistance(txtEmployeeCode.Text.Trim(), 0) == false)
                {
                    decEmployeeId = BllEmployeeCreation.EmployeeAddWithReturnIdentity(infoEmployee);
                    Messages.SavedMessage();
                    ClearFunction();
                    decIdForOtherForms = decEmployeeId;
                    if (frmSalesInvoiceObj != null)
                    {
                        if (decIdForOtherForms != 0)
                        {
                            this.Close();
                        }
                    }

                }
                else
                {
                    Messages.InformationMessage("Employee code already exist");
                    txtEmployeeCode.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("EC1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function for Delete
 /// </summary>
 public void Delete()
 {
     try
     {
         EmployeeCreationBll BllEmployeeCreation = new EmployeeCreationBll();
         if (BllEmployeeCreation.EmployeeCheckReferences(Convert.ToDecimal(lblEmployeeId.Text.ToString())) == -1)
         {
             Messages.ReferenceExistsMessage();
         }
         else
         {
             Messages.DeletedMessage();
             this.Close();
         }
         if (frmEmployeeRegisterObj != null)
         {
             frmEmployeeRegisterObj.Show();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("EC10" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         EmployeeCreationBll BllEmployeeCreation = new EmployeeCreationBll();
         List<DataTable> listObj = BllEmployeeCreation.EmployeeViewAllEmployeeReport(cmbDesigantion.Text, cmbEmployee.Text, cmbStatus.Text);
         dgvEmployee.DataSource = listObj[0];
     }
     catch (Exception ex)
     {
         MessageBox.Show("ER3 " + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function for Edit
        /// </summary>
        public void EditFunction()
        {
            try
            {
                MonthlySalaryVoucherBll BllMonthlySalary = new MonthlySalaryVoucherBll();
                MonthlySalaryInfo infoMonthlySalary = new MonthlySalaryInfo();
                MonthlySalaryVoucherBll BllMonthlySalaryDetails = new MonthlySalaryVoucherBll();
                MonthlySalaryDetailsInfo infoMonthlySalaryDetails = new MonthlySalaryDetailsInfo();
                EmployeeCreationBll BllEmployeeCreation = new EmployeeCreationBll();
                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;
                BllMonthlySalary.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;
                                BllEmployeeCreation.EmployeePackageEdit(infoMonthlySalaryDetails.EmployeeId, infoMonthlySalaryDetails.SalaryPackageId);
                                BllMonthlySalaryDetails.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());
                                        BllMonthlySalaryDetails.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;
                                BllMonthlySalaryDetails.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>
 /// On doubleClicking on the grid, It Fill the controlls to edit or delete
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvSalesman_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.RowIndex != -1)
         {
             if (Convert.ToDecimal(dgvSalesman.CurrentRow.Cells["dgvtxtemployeeId"].Value) != 1)
             {
                 EmployeeCreationBll BllEmployeeCreation = new EmployeeCreationBll();
                 EmployeeInfo infoEmployee = new EmployeeInfo();
                 strSalesmanId = dgvSalesman.CurrentRow.Cells["dgvtxtemployeeId"].Value.ToString();
                 FillControls();
                 btnSave.Text = "Update";
                 btnDelete.Enabled = true;
                 txtSalesmanCode.Focus();
             }
             else
             {
                 Messages.InformationMessage("Default employee cannot update or delete");
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("S25" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill Salesman combobox
 /// </summary>
 public void SalesmanComboFill()
 {
     try
     {
         List<DataTable> listSalesmen = new List<DataTable>();
         EmployeeCreationBll BllEmployeeCreation = new EmployeeCreationBll();
         listSalesmen = BllEmployeeCreation.EmployeeViewSalesman();
         DataRow dr = listSalesmen[0].NewRow();
         dr["employeeId"] = 0;
         dr["employeeName"] = "All";
         listSalesmen[0].Rows.InsertAt(dr, 0);
         cmbSalesman.DataSource = listSalesmen[0];
         cmbSalesman.DisplayMember = "employeeName";
         cmbSalesman.ValueMember = "employeeId";
         cmbSalesman.SelectedValue = 0;
     }
     catch (Exception ex)
     {
         MessageBox.Show("SVRT 8 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill Employee combobox
 /// </summary>
 private void EmployeeComboFill()
 {
     try
     {
         EmployeeCreationBll BllEmployeeCreation = new EmployeeCreationBll();
         List<DataTable> listEmployee = new List<DataTable>();
         listEmployee = BllEmployeeCreation.EmployeeViewAll();
         DataRow dr = listEmployee[0].NewRow();
         dr["employeeCode"] = "All";
         listEmployee[0].Rows.InsertAt(dr, 0);
         cmbEmployee.DataSource = listEmployee[0];
         cmbEmployee.DisplayMember = "employeeCode";
         cmbEmployee.ValueMember = "employeeId";
     }
     catch (Exception ex)
     {
         MessageBox.Show("DAR:2" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill the controlls for edit or delete
 /// </summary>
 public void FillControls()
 {
     try
     {
         EmployeeCreationBll BllEmployeeCreation = new EmployeeCreationBll();
         EmployeeInfo infoEmployee = new EmployeeInfo();
         infoEmployee = BllEmployeeCreation.SalesmanViewSpecificFeilds(Convert.ToDecimal(strSalesmanId.ToString()));
         txtSalesmanCode.Text = infoEmployee.EmployeeCode;
         txtName.Text = infoEmployee.EmployeeName;
         txtEmail.Text = infoEmployee.Email;
         txtPhone.Text = infoEmployee.PhoneNumber;
         txtMobile.Text = infoEmployee.MobileNumber;
         txtAddress.Text = infoEmployee.Address;
         txtNarration.Text = infoEmployee.Narration;
         if (infoEmployee.IsActive)
         {
             cbxActive.Checked = true;
         }
         else
         {
             cbxActive.Checked = false;
         }
         decSalesManId = infoEmployee.EmployeeId;
     }
     catch (Exception ex)
     {
         MessageBox.Show("S3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to edit a salesman
 /// </summary>
 public void EditFunction()
 {
     try
     {
         EmployeeInfo InfoEmployee = new EmployeeInfo();
         EmployeeCreationBll BllEmployeeCreation = new EmployeeCreationBll();
         InfoEmployee.EmployeeId = decSalesManId;
         InfoEmployee.EmployeeCode = txtSalesmanCode.Text.Trim();
         InfoEmployee.EmployeeName = txtName.Text.Trim();
         InfoEmployee.Email = txtEmail.Text.Trim();
         InfoEmployee.PhoneNumber = txtPhone.Text.Trim();
         InfoEmployee.MobileNumber = txtMobile.Text.Trim();
         InfoEmployee.Address = txtAddress.Text.Trim();
         InfoEmployee.Narration = txtNarration.Text.Trim();
         if (cbxActive.Checked)
         {
             InfoEmployee.IsActive = true;
         }
         else
         {
             InfoEmployee.IsActive = false;
         }
         if (BllEmployeeCreation.EmployeeCodeCheckExistance(txtSalesmanCode.Text.Trim().ToString(), decSalesManId) == false)
         {
             BllEmployeeCreation.SalesmanEdit(InfoEmployee);
             Messages.UpdatedMessage();
             ClearSearch();
             Clear();
             Gridfill();
         }
         else
         {
             Messages.InformationMessage("Salesman code already exist");
             txtSalesmanCode.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("S6" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to delete a salesman
 /// </summary>
 public void DeleteFunction()
 {
     try
     {
         EmployeeCreationBll BllEmployeeCreation = new EmployeeCreationBll();
         if (BllEmployeeCreation.SalesmanCheckReferenceAndDelete(decSalesManId) == -1)
         {
             Messages.ReferenceExistsMessage();
         }
         else
         {
             BllEmployeeCreation.EmployeeDeleteCheck(decSalesManId);
             Messages.DeletedMessage();
             ClearSearch();
             Clear();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("S8" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         string strEmployeeStatus = string.Empty;
         if (rbtnAll.Checked)
         {
             strEmployeeStatus = "All";
         }
         else if (rbtnActive.Checked)
         {
             strEmployeeStatus = "Active";
         }
         else if (rbtnInActive.Checked)
         {
             strEmployeeStatus = "InActive";
         }
         if (strEmployeeStatus != string.Empty && cmbDesigantion.SelectedIndex > -1)
         {
             CreateGrid();
             AttendanceBll BllAttendanceMaster = new AttendanceBll();
             EmployeeCreationBll BllEmployeeCreation = new EmployeeCreationBll();
             List<DataTable> listEmployee = new List<DataTable>();
             listEmployee = BllEmployeeCreation.EmployeeViewByDesignationAndStatus(cmbDesigantion.Text, strEmployeeStatus);
             if (listEmployee[0].Rows.Count > 0)
             {
                 for (int i = 0; i < listEmployee[0].Rows.Count; i++)
                 {
                     dgvMonthlyAttendance.Rows.Add();
                     dgvMonthlyAttendance.Rows[i].Cells["employeeId"].Value = listEmployee[0].Rows[i]["employeeId"].ToString();
                     dgvMonthlyAttendance.Rows[i].Cells["SlNo"].Value = i + 1;
                     dgvMonthlyAttendance.Rows[i].Cells["employeeName"].Value = listEmployee[0].Rows[i]["employeeName"].ToString();
                     dgvMonthlyAttendance.Rows[i].Cells["employeeCode"].Value = listEmployee[0].Rows[i]["employeeCode"].ToString();
                     List<DataTable> listStatus = BllAttendanceMaster.MonthlyAttendanceReportFill(dtpMonth.Value, Convert.ToDecimal(listEmployee[0].Rows[i]["employeeId"].ToString()));
                    if (listStatus[0].Rows.Count > 0)
                     {
                         for (int j = 0; j < listStatus[0].Rows.Count; j++)
                         {
                             dgvMonthlyAttendance.Rows[i].Cells[DateTime.Parse(listStatus[0].Rows[j]["date"].ToString()).Day.ToString()].Value = listStatus[0].Rows[j]["status"].ToString();
                         }
                     }
                     FindTotal(i);
                 }
             }
             CheckedChange();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("MAR2 " + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill EmployeeCode Combobox
 /// </summary>
 public void EmployeeCodeComboFill()
 {
     try
     {
         EmployeeCreationBll BllEmployeeCreation = new EmployeeCreationBll();
         List<DataTable> listEmployeeCode = new List<DataTable>();
         listEmployeeCode = BllEmployeeCreation.EmployeeViewAll();
         cmbEmployeeCode.DataSource = listEmployeeCode[0];
         cmbEmployeeCode.ValueMember = "employeeId";
         cmbEmployeeCode.DisplayMember = "employeeCode";
     }
     catch (Exception ex)
     {
         MessageBox.Show("BD1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void Gridfill()
 {
     try
     {
         List<DataTable> listObj = new List<DataTable>();
         EmployeeInfo infoEmployee = new EmployeeInfo();
         EmployeeCreationBll BllEmployeeCreation = new EmployeeCreationBll();
         infoEmployee.EmployeeCode = txtEmployeeCode.Text.Trim();
         infoEmployee.EmployeeName = txtEmployeeName.Text.Trim();
         infoEmployee.DesignationId = decimal.Parse(cmbDesignation.SelectedValue.ToString());
         infoEmployee.SalaryType = cmbsalaryType.SelectedItem.ToString();
         infoEmployee.BankAccountNumber = txtBankAccountNumber.Text.Trim();
         infoEmployee.PassportNo = txtPassportNumber.Text.Trim();
         infoEmployee.LabourCardNumber = txtLabourCardNumber.Text.Trim();
         infoEmployee.VisaNumber = txtVisaNumber.Text.Trim();
         listObj= BllEmployeeCreation.EmployeeSearch(infoEmployee);
         dgvEmployee.DataSource = listObj[0];
     }
     catch (Exception ex)
     {
         MessageBox.Show("ER1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to fill controls when cell double click in frmEmployeeRegister for updation
        /// </summary>
        /// <param name="decEmployeeId"></param>
        /// <param name="frm"></param>
        public void CallFromEmployeeRegister(decimal decEmployeeId, frmEmployeeRegister frm)
        {
            try
            {
                base.Show();
                frmEmployeeRegisterObj = frm;
                EmployeeInfo infoEmployee = new EmployeeInfo();
                EmployeeCreationBll BllEmployeeCreation = new EmployeeCreationBll();
                infoEmployee = BllEmployeeCreation.EmployeeView(decEmployeeId);
                lblEmployeeId.Text = infoEmployee.EmployeeId.ToString();
                txtEmployeeCode.Text = infoEmployee.EmployeeCode.ToString();
                strEmployeeCode = infoEmployee.EmployeeCode.ToString();
                txtEmployeeName.Text = infoEmployee.EmployeeName.ToString();
                cmbDesignation.SelectedValue = infoEmployee.DesignationId;
                dtpDob.Text = infoEmployee.Dob.ToString("dd-MMM-yyyy");
                cmbMaritalStatus.SelectedItem = infoEmployee.MaritalStatus.ToString();
                cmbGender.SelectedItem = infoEmployee.Gender.ToString();
                txtQualification.Text = infoEmployee.Qualification;
                cmbBloodGroup.SelectedItem = infoEmployee.BloodGroup.ToString();
                txtAddress.Text = infoEmployee.Address;
                txtBankAccountNumber.Text = infoEmployee.BankAccountNumber;
                txtBankName.Text = infoEmployee.BankName;
                txtBranch.Text = infoEmployee.BranchName;
                txtEmail.Text = infoEmployee.Email;
                txtEsiNumber.Text = infoEmployee.EsiNumber;
                txtlabourCardNumber.Text = infoEmployee.LabourCardNumber;
                txtBranchCode.Text = infoEmployee.BranchCode;
                txtMobileNumber.Text = infoEmployee.MobileNumber;
                txtNarration.Text = infoEmployee.Narration;
                txtPanNumber.Text = infoEmployee.PanNumber;
                txtPassportNumber.Text = infoEmployee.PassportNo;
                txtPfNumber.Text = infoEmployee.PfNumber;
                txtPhoneNumber.Text = infoEmployee.PhoneNumber;
                txtVisaNumber.Text = infoEmployee.VisaNumber;
                cmbSalaryType.SelectedItem = infoEmployee.SalaryType;
                if (cmbSalaryType.SelectedItem.ToString() == "Daily wage")
                {
                    txtDailyWage.Text = infoEmployee.DailyWage.ToString();
                }
                else
                {
                    cmbDefaultPackage.SelectedValue = int.Parse(infoEmployee.DefaultPackageId.ToString());
                }
                txtJoiningDate.Text = infoEmployee.JoiningDate.ToString("dd-MMM-yyyy");
                dtpLabourCardExpiryDate.Value = infoEmployee.LabourCardExpiryDate;
                dtpPassportExpiryDate.Value = infoEmployee.PassportExpiryDate;
                txtTerminationDate.Text = infoEmployee.TerminationDate.ToString("dd-MMM-yyyy");
                dtpVisaExpiryDate.Value = infoEmployee.VisaExpiryDate;
                txtEmployeeCode.Focus();
                if (infoEmployee.IsActive)
                {
                    cbxActive.Checked = true;
                }
                else
                {
                    cbxActive.Checked = false;
                }
                btnSave.Text = "Update";
                btnDelete.Enabled = true;
                txtEmployeeCode.Select();

            }
            catch (Exception ex)
            {
                MessageBox.Show("EC12" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to fill grid according to search keys
 /// </summary>
 public void Gridfill()
 {
     try
     {
         List<DataTable> listEmployeeSearch = new List<DataTable>();
         EmployeeCreationBll BllEmployeeCreation = new EmployeeCreationBll();
         string strIsActive = "All";
         if (cmbIsActive.Text == "Yes")
         {
             strIsActive = "True";
         }
         else if (cmbIsActive.Text == "No")
         {
             strIsActive = "False";
         }
         else
         {
             cmbIsActive.SelectedIndex = 0;
         }
         listEmployeeSearch = BllEmployeeCreation.SalesmanSearch(txtCode.Text, txtNameSearch.Text, txtPhoneSearch.Text, txtMobileSearch.Text, strIsActive);
         dgvSalesman.DataSource = listEmployeeSearch[0];
         if (strIsActive == "True")
         {
             cmbIsActive.Text = "Yes";
         }
         else if (strIsActive == "False")
         {
             cmbIsActive.Text = "No";
         }
         else
         {
             cmbIsActive.SelectedIndex = 0;
         }
         int inRowCount = dgvSalesman.RowCount;
         for (int i = 0; i <= inRowCount - 1; i++)
         {
             if (dgvSalesman.Rows[i].Cells["dgvtxtactive"].Value.ToString() == "1")
             {
                 dgvSalesman.Rows[i].Cells["dgvtxtactive"].Value = "Yes";
             }
             if (dgvSalesman.Rows[i].Cells["dgvtxtactive"].Value.ToString() == "0")
             {
                 dgvSalesman.Rows[i].Cells["dgvtxtactive"].Value = "No";
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("S1" + 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 (dgvDailySalary.RowCount > 0)
         {
             DataSet ds = new DataSet();
             //CompanySP spCompany = new CompanySP();
             CompanyCreationBll bllCompanyCreation = new CompanyCreationBll();
             EmployeeCreationBll BllEmployeeCreation = new EmployeeCreationBll();
             List<DataTable> listEmployee = BllEmployeeCreation.EmployeeViewAllForDailySalaryReport(cmbEmployeeCode.Text, cmbDesignation.Text, Convert.ToDateTime(dtpFromDate.Text.ToString()), Convert.ToDateTime(dtpToDate.Text.ToString()), cmbStatus.Text);
             List<DataTable> listObjCompany = bllCompanyCreation.CompanyViewDataTable(1);
             ds.Tables.Add(listObjCompany[0]);
             ds.Tables.Add(listEmployee[0]);
             frmReport frmReportObj = new frmReport();
             frmReportObj.MdiParent = formMDI.MDIObj;
             frmReportObj.DailySalaryReport(ds);
         }
         else
         {
             Messages.InformationMessage("No data found");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("DSR9 " + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to save a salesman
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         EmployeeInfo InfoEmployee = new EmployeeInfo();
         EmployeeCreationBll BllEmployeeCreation = new EmployeeCreationBll();
         InfoEmployee.EmployeeCode = txtSalesmanCode.Text.Trim();
         InfoEmployee.DesignationId = Convert.ToDecimal(BllEmployeeCreation.SalesmanGetDesignationId());
         InfoEmployee.EmployeeName = txtName.Text.Trim();
         InfoEmployee.Email = txtEmail.Text.Trim();
         InfoEmployee.PhoneNumber = txtPhone.Text.Trim();
         InfoEmployee.MobileNumber = txtMobile.Text.Trim();
         InfoEmployee.Address = txtAddress.Text.Trim();
         InfoEmployee.Narration = txtNarration.Text.Trim();
         InfoEmployee.Dob = DateTime.Now;
         InfoEmployee.MaritalStatus = "Single";
         InfoEmployee.Gender = "Male";
         InfoEmployee.Qualification = string.Empty;
         InfoEmployee.BloodGroup = string.Empty;
         InfoEmployee.JoiningDate = PublicVariables._dtCurrentDate;
         InfoEmployee.TerminationDate = DateTime.Now;
         if (cbxActive.Checked)
         {
             InfoEmployee.IsActive = true;
         }
         else
         {
             InfoEmployee.IsActive = false;
         }
         InfoEmployee.SalaryType = "Monthly";
         InfoEmployee.DefaultPackageId = 1;
         InfoEmployee.BankName = string.Empty;
         InfoEmployee.BankAccountNumber = string.Empty;
         InfoEmployee.BranchName = string.Empty;
         InfoEmployee.BranchCode = string.Empty;
         InfoEmployee.PanNumber = string.Empty;
         InfoEmployee.PfNumber = string.Empty;
         InfoEmployee.EsiNumber = string.Empty;
         InfoEmployee.PassportNo = string.Empty;
         InfoEmployee.PassportExpiryDate = DateTime.Now;
         InfoEmployee.VisaNumber = string.Empty;
         InfoEmployee.VisaExpiryDate = DateTime.Now;
         InfoEmployee.LabourCardNumber = string.Empty;
         InfoEmployee.LabourCardExpiryDate = DateTime.Now;
         InfoEmployee.Extra1 = string.Empty;
         InfoEmployee.Extra2 = string.Empty;
         if (BllEmployeeCreation.EmployeeCodeCheckExistance(txtSalesmanCode.Text.Trim().ToString(), 0) == false)
         {
             decSalesManId = BllEmployeeCreation.EmployeeAddWithReturnIdentity(InfoEmployee);
             Messages.SavedMessage();
             Clear();
             Gridfill();
             if (frmRejectionInObj != null)
             {
                 this.Close();
             }
             if (frmSalesQuotationObj != null)
             {
                 this.Close();
             }
         }
         else
         {
             Messages.InformationMessage("Salesman code already exist");
             txtSalesmanCode.Focus();
         }
         if (frmSalesReturnObj != null)
         {
             this.Close();
         }
         if (frmSalesOrderObj != null)
         {
             this.Close();
         }
         if (frmSalesInvoiceObj != null)
         {
             this.Close();
         }
         if (frmPOSObj != null)
         {
             this.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("S5" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill the salesman combobox
 /// </summary>
 public void SalesmanComboFill()
 {
     try
     {
         List<DataTable> listObj = new List<DataTable>();
         EmployeeCreationBll BllEmployeeCreation = new EmployeeCreationBll();
         TransactionsGeneralFillBll TransactiongeneralFillObj = new TransactionsGeneralFillBll();
         listObj = TransactiongeneralFillObj.SalesmanViewAllForComboFill(cmbSalesman, false);
         cmbSalesman.DataSource = listObj[0];
         cmbSalesman.DisplayMember = "employeeName";
         cmbSalesman.ValueMember = "employeeId";
         cmbSalesman.SelectedValue = -1;
     }
     catch (Exception ex)
     {
         MessageBox.Show("SV 06 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// On 'Print' button click to take print
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnPrint_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvEmployeeAddressBook.Rows.Count > 0)
         {
             DataSet ds = new DataSet();
             //CompanySP spCompany = new CompanySP();
             CompanyCreationBll bllCompanyCreation = new CompanyCreationBll();
             List<DataTable> listObjCompany = bllCompanyCreation.CompanyViewDataTable(1);
             ds.Tables.Add(listObjCompany[0]);
             EmployeeCreationBll BllEmployeeCreation = new EmployeeCreationBll();
             List<DataTable> listEmployee = BllEmployeeCreation.EmployeeViewAllForEmployeeAddressBook(cmbEmployeeCode.Text, txtMobile.Text, txtPhone.Text, txtEmail.Text);
             ds.Tables.Add(listEmployee[0]);
             frmReport frmReportObj = new frmReport();
             frmReportObj.MdiParent = formMDI.MDIObj;
             frmReportObj.EmployeeAddressBookPrinting(ds);
         }
         else
         {
             Messages.InformationMessage("No data found");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("EMP8 " + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }