private void Addnewbttn_Click(object sender, EventArgs e) { DialogResult result = MetroFramework.MetroMessageBox.Show(this, "Are you sure want to create a new engineering change request?", "SPM Connect - Create New ECR?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (connectapi.ConnectUser.Emp_Id != 0) { string status = connectapi.CreatenewECR(connectapi.ConnectUser.Emp_Id.ToString()); if (status.Length > 1) { Showecrinvoice(status, true, connectapi.ConnectUser.Emp_Id.ToString()); } } else { // scan the employee barcode and grab the user name string scanEmployeeId = ""; ScanEmpId invoiceFor = new ScanEmpId(); if (invoiceFor.ShowDialog() == DialogResult.OK) { scanEmployeeId = invoiceFor.ValueIWant; } if (scanEmployeeId.Length > 0) { if (connectapi.EmployeeExits(scanEmployeeId)) { string status = connectapi.CreatenewECR(scanEmployeeId); if (status.Length > 1) { Showecrinvoice(status, true, scanEmployeeId); } } else { MetroFramework.MetroMessageBox.Show(this, "Employee not found. Please contact the admin", "SPM Connect - Employee Not Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MetroFramework.MetroMessageBox.Show(this, "Please try again. Employee not found.", "SPM Connect - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void Showecrinvoice(string invoice, bool newcreated, string empid) { string invoiceopen = connectapi.InvoiceOpen(invoice, CheckInModules.ECR); if (invoiceopen.Length > 0) { MetroFramework.MetroMessageBox.Show(this, "Inovice is opened for edit by " + invoiceopen + ". ", "SPM Connect - Open Invoice Failed", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { if (connectapi.ConnectUser.Emp_Id != 0) { if (connectapi.CheckinInvoice(invoice, CheckInModules.ECR)) { using (ECRDetails invoiceDetails = new ECRDetails(connectapi.ConnectUser.Name, invoice)) { invoiceDetails.ShowDialog(); this.Enabled = true; Performreload(); this.Show(); this.Activate(); this.Focus(); } } } else { // scan the employee barcode and grab the user name string scanEmployeeId = ""; if (!newcreated) { ScanEmpId invoiceFor = new ScanEmpId(); if (invoiceFor.ShowDialog() == DialogResult.OK) { scanEmployeeId = invoiceFor.ValueIWant; } } else { scanEmployeeId = empid; } if (scanEmployeeId.Length > 0) { if (connectapi.CheckinInvoice(invoice, CheckInModules.ECR)) { using (ECRDetails invoiceDetails = new ECRDetails(connectapi.GetNameByEmpId(scanEmployeeId), invoice)) { invoiceDetails.ShowDialog(); this.Enabled = true; Performreload(); this.Show(); this.Activate(); this.Focus(); } } } else { MetroFramework.MetroMessageBox.Show(this, "Please try again. Employee not found.", "SPM Connect - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }