private void btnProcess_Click(object sender, EventArgs e) { string err = DataValidate(); if (!string.IsNullOrEmpty(err)) { MessageBox.Show(err, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!string.IsNullOrEmpty(txtEmpUnqID.Text.Trim())) { if (string.IsNullOrEmpty(txtEmpName.Text.Trim())) { MessageBox.Show("Please Enter Valid Employee", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (!GRights.Contains("AUDV")) { MessageBox.Show("You are not fully authorised..", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string sql = string.Empty; string question = string.Empty; DialogResult drq; string sWrkGrp = txtWrkGrpCode.Text.Trim().ToString(); string sEmpUnqID = txtEmpUnqID.Text.Trim().ToString(); if (string.IsNullOrEmpty(txtEmpUnqID.Text.Trim())) { question = "Are You Sure to Process HalfDay Rules Check For : " + sWrkGrp + Environment.NewLine + "Processed Data will be deleted between '" + txtFromDt.DateTime.ToString("yyyy-MM-dd") + "' And '" + txtToDate.DateTime.ToString("yyyy-MM-dd") + "' "; sql = "Select CompCode,WrkGrp,EmpUnqID,OTFlg,WeekOff from mastemp where CompCode = '01' and Wrkgrp = '" + sWrkGrp + "' And Active = 1 Order By EmpUnqID"; } else { question = "Are You Sure to to Process HalfDay Rules Check For : " + txtEmpUnqID.Text.Trim().ToString() + Environment.NewLine + "Processed Data will be deleted between '" + txtFromDt.DateTime.ToString("yyyy-MM-dd") + "' And '" + txtToDate.DateTime.ToString("yyyy-MM-dd") + "' "; sql = "Select CompCode,WrkGrp,EmpUnqID,OTFlg,WeekOff From MastEmp Where CompCode ='" + txtCompCode.Text.Trim() + "' " + " and WrkGrp = '" + sWrkGrp + "' " + " and EmpUnqID ='" + sEmpUnqID + "' "; } drq = MessageBox.Show(question, "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (drq == DialogResult.No) { MessageBox.Show("Process Canceled..", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } btnProcess.Enabled = false; txtWrkGrpCode.Enabled = false; txtEmpUnqID.Enabled = false; txtFromDt.Enabled = false; txtToDate.Enabled = false; DateTime tFromDt = txtFromDt.DateTime; DateTime tToDt = txtToDate.DateTime; Cursor.Current = Cursors.WaitCursor; DataSet ds = Utils.Helper.GetData(sql, Utils.Helper.constr); pBar.Properties.Maximum = ds.Tables[0].Rows.Count + 1; clsProcess pro = new clsProcess(); foreach (DataRow drs in ds.Tables[0].Rows) { //update progressbar pBar.PerformStep(); pBar.Update(); string tEmpUnqID = drs["EmpUnqID"].ToString(); string tWrkGrp = drs["WrkGrp"].ToString(); txtError.Text = "Processing Emp :" + sEmpUnqID + Environment.NewLine; string status = string.Empty; pro.HalfDay_Rules_Process(tWrkGrp, tEmpUnqID, tFromDt, tToDt, out status); if (!string.IsNullOrEmpty(status)) { txtError.Text += status + Environment.NewLine; } } //foreach loop drs MessageBox.Show("Process Completed...", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); Cursor.Current = Cursors.Default; ResetCtrl(); SetRights(); }