public static void AddOrder(string clientid, string productName, Dictionary <string, int> compNameQuantity, string months, string importance, int personnelID) { //////////////////////////////////////////////////////////////////////////////// string contractNr = Contract.AddContract(productName, months, importance); string sixDigitNr = Contract.SixDigitNumber(); string CompleteContract = contractNr + sixDigitNr; bool errors = false; bool isempty = compNameQuantity.Count == 0; Object thisLock = new Object(); /////////////////////////////////////////////////////////////////////////////// bool clientIDFound = ClientProducts.CheckClientProducts(clientid); if (clientIDFound == true) { return; } if (clientid == null) { MessageBox.Show("Please search for a client!", "Empty Client", MessageBoxButtons.OK, MessageBoxIcon.Information); errors = true; } else { if (isempty) { MessageBox.Show("No components have been selected!", "Components", MessageBoxButtons.OK, MessageBoxIcon.Information); errors = true; } } lock (thisLock) { if (errors == false) { Data.AddOrder(clientid, productName, compNameQuantity, CompleteContract, personnelID); MessageBox.Show("The order has been added!", "Order", MessageBoxButtons.OK, MessageBoxIcon.Information); } } //if (clientid != null) //{ // Data.AddOrder(clientid, productName, compNameQuantity, CompleteContract); // MessageBox.Show("Order has been added!"); //} //else //{ // MessageBox.Show("Please search for a client!"); //} }
public static bool CheckClientProducts1(string clientid) { List <ClientProducts> clientProducts = ClientProducts.GetCP(); foreach (ClientProducts item in clientProducts) { if (item.ClientID == clientid) { return(true); } } return(false); }
//this method checks to see if a client already has a product to their name public static DataTable compInvDetails(string clientid) { bool clientIDFound = ClientProducts.CheckClientProducts1(clientid); if (clientIDFound == false) { return(null); } DataTable dt = Data.GetCompInvoiceDetails(clientid); return(dt); }
public static bool CheckClientProducts(string clientid) { List <ClientProducts> clientProducts = ClientProducts.GetCP(); foreach (ClientProducts item in clientProducts) { if (item.ClientID == clientid) { MessageBox.Show("Client already has a contract. Only one contract is allowed per client.", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(true); } } return(false); }