public void UpdateOrder() { string ConString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\Customer_Purchase_Order_System\DataBase\stretchline.mdf;Integrated Security=True;Connect Timeout=30"; string InsertQuery = "UPDATE tbl_salesOrder SET contact='" + Contact + "', email='" + Email + "', tel='" + Tel + "', fax='" + Fax + "', deliver_location='" + Deliver_Location + "', delivary_type='" + Delivary_Type + "', delivery_date='" + Delivary_Date + "', bill_address='" + Bill_Address + "', item_code='" + Item_Code + "', color_shade='" + Color_Shade + "', quantity=" + Quantity + ", unit_price=" + Unit_Price + ", total_price=" + Total_Price + ", currency='" + Currency + "', payment_term='" + Payment_Term + "', inco_term='" + Inco_Term + "', end_buyer='" + End_Buyer + "', order_date='" + Order_Date + "', entry_date='" + Entry_Date + "', review_date='" + Review_Date + "', cus_name='" + Cus_name + "', cus_email='" + Cus_mail + "', cus_add='" + Cus_add + "', confirmation='confirmed' WHERE po_no=" + Po_no + ""; var con = new SqlConnection(ConString); var cmd = new SqlCommand(InsertQuery, con); try { con.Open(); cmd.ExecuteNonQuery(); Notifier cusNtf = new Notifier(Po_no.ToString()); cusNtf.SendMailCustomer(); Notifier yarnNtf = new Notifier(Po_no.ToString()); yarnNtf.SendMailYarnLab(); } catch (Exception) { MessageBox.Show("Connection_Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { con.Close(); } }
public void SaveOrder() { if (!Check()) { string ConString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\Customer_Purchase_Order_System\DataBase\stretchline.mdf;Integrated Security=True;Connect Timeout=30"; string InsertQuery = "INSERT INTO tbl_salesOrder(po_no, contact, email, tel, fax, deliver_location, delivary_type, delivery_date, bill_address, item_code, color_shade, quantity, unit_price, total_price, currency, payment_term, inco_term, end_buyer, order_date, entry_date, cus_name, cus_email, cus_add, confirmation) VALUES (" + Po_no + ", '" + Contact + "', '" + Email + "', '" + Tel + "', '" + Fax + "', '" + Deliver_Location + "', '" + Delivary_Type + "', '" + Delivary_Date + "', '" + Bill_Address + "', '" + Item_Code + "', '" + Color_Shade + "', " + Quantity + ", " + Unit_Price + ", " + Total_Price + ", '" + Currency + "', '" + Payment_Term + "', '" + Inco_Term + "', '" + End_Buyer + "', '" + Order_Date + "', '" + Entry_Date + "', '" + Cus_name + "', '" + Cus_mail + "', '" + Cus_add + "', 'NA')"; var con = new SqlConnection(ConString); var cmd = new SqlCommand(InsertQuery, con); try { con.Open(); cmd.ExecuteNonQuery(); Notifier ntf = new Notifier(Po_no.ToString()); ntf.SendMailSupervisor(); } catch (Exception) { MessageBox.Show("Connection_Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { con.Close(); } } else { MessageBox.Show("You have already saved this order", "Look Out!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }