private void txtOTMinutes_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (e.KeyCode == Keys.Enter) { if (objBatchActivity.BatchActStatus == BatchActivity.Status.Finished) { MessageBox.Show(this, "Activity is already Finished", "Wrong Attempt", MessageBoxButtons.OK); Clear_Labour(); } else { try { Decimal OTHours = 0; Decimal OTMinutes = 0; if (txtOT.Text != "") { OTHours = Convert.ToDecimal(txtOT.Text); } if (txtOTMinutes.Text != "") { OTMinutes = Convert.ToDecimal(txtOTMinutes.Text); } BatchLabourDetails obj = new BatchLabourDetails(); obj.BatchAct = objBatchActivity; obj.Emp = objEmployee_DL.Get(cmbEmployee.SelectedValue.ToString()); obj.OTHours = Calculate.CalOTHours(OTHours, OTMinutes); obj.WorkStart = txtFrom.Text; obj.WorkStop = txtTo.Text; if (rdbOutsource.Checked == true) { int theCount = Convert.ToInt32(txtNos.Text); for (int i = 0; i < theCount; i++) { objBatchLabourDetails_DL.Add(obj); } } else { objBatchLabourDetails_DL.Add(obj); } Load_BatchLabourDetails(); Clear_Labour(); // Load_Activity_List(); } catch (Exception) { MessageBox.Show(this, "Error occured while loading Labour Details", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } }
private void textBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (e.KeyCode == Keys.Enter) { if (!DataValidation.IsTimeShift(txtFrom.Text, txtTo.Text)) { MessageBox.Show(this, "please enter valid time period", "MRP System", MessageBoxButtons.OK); } else if (!DataValidation.IsHours(txtOT.Text) || !DataValidation.IsMinutes(txtOTMinutes.Text)) { MessageBox.Show(this, "please enter valid OT Details", "MRP System", MessageBoxButtons.OK); } else { try { Decimal OTHours = 0; Decimal OTMinutes = 0; if (txtOT.Text != "") { OTHours = Convert.ToDecimal(txtOT.Text); } if (txtOTMinutes.Text != "") { OTMinutes = Convert.ToDecimal(txtOTMinutes.Text); } BatchLabourDetails obj = new BatchLabourDetails(); obj.BatchAct = objBatchActivity; obj.Emp = objEmployee_DL.Get(cmbEmployee.SelectedValue.ToString()); obj.OTHours = Calculate.CalOTHours(OTHours, OTMinutes); obj.WorkStart = txtFrom.Text; obj.WorkStop = txtTo.Text; if (rdbOutsource.Checked == true) { int theCount = Convert.ToInt32(txtNos.Text); for (int i = 0; i < theCount; i++) { objBatchLabourDetails_DL.Add_Secondary(obj); } } else { objBatchLabourDetails_DL.Add_Secondary(obj); } Load_BatchLabourDetails(); Clear_Labour(); if (dgvActivity.Rows.Count > 0) { DataGridViewCellEventArgs ee = new DataGridViewCellEventArgs(1, 0); dgvActivity_CellClick(sender, ee); } } catch (Exception) { MessageBox.Show(this, "Error occured while loading Labour Details", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } }