private void btnCreatePQ_Click(object sender, EventArgs e) { if (dgvRFQSelected.Rows.Count == 0) { MessageBox.Show("Please include Request for Price Quotation.", "Incomplete Fields", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.Close(); PQ_CreateForm pf = new PQ_CreateForm(); for (int i = 0; i < dgvRFQSelected.RowCount; i++) { string rfqNo; DataGridViewRow row = dgvRFQSelected.Rows[i]; rfqNo = (row.Cells["SelectedRFQNo"].Value).ToString(); //get the RFQNo of the rfq selected RFQ r = sql.SelectRFQDetails(rfqNo); //from the RFQNo taken, get its details selectedRFQList.Add(new RFQ(r.RFQNo, r.RequestDate, r.PaymentTerms, r.DeliveryTerms, r.CustomerID, r.SupplierID, r.PQNo)); //put in an ArrayList the details taken pf.RFQNo = rfqNo; string year = DateTime.Now.ToString("yy"); string month = DateTime.Now.ToString("MM"); int pqCount = sql.GetRowCount("pq_t", year, month); string generatedPQNo = year + month + "-" + (pqCount + 1).ToString("D3"); pf.PQNo = generatedPQNo; pf.PaymentTerms = r.PaymentTerms; pf.DeliveryTerms = r.DeliveryTerms; Customer c = sql.SelectCustomerDetails(r.CustomerID); //to retrieve the details of Customer from MySqlDatabaseDriver pf.CustomerName = c.CustomerName; pf.CustomerPerson = c.CustomerPerson; pf.CustomerNumber = c.CustomerNumber; pf.CustomerEmail = c.CustomerEmail; pf.CustomerAddress = c.CustomerAddress; pf.ShowDialog(); } if (pf.Cancel == false) {//if save button were clicked, this will save the pq details in arrayList then in the database string FromDateNoTime = pf.FromDate.ToShortDateString(); string ToDateNoTime = pf.ToDate.ToShortDateString(); string PQDateNoTime = pf.PQDate.ToShortDateString(); pqList.Add(new PQ(pf.PQNo, PQDateNoTime, FromDateNoTime, ToDateNoTime, pf.PaymentTerms, pf.DeliveryTerms, pf.BillTo, pf.ShipTo, pf.InFavorOf, double.Parse(pf.TotalAmount), pf.CustomerIDFK)); PQ newPQ = (PQ)pqList[(pqList.Count - 1)]; sql.InsertPQ(newPQ); for (int j = 0; j < pf.PQOrderLineList.Count; j++) { PQ_OrderLine pol = (PQ_OrderLine)pf.PQOrderLineList[j]; sql.InsertPQOrderLine(pol); //MessageBox.Show("OrderLine added to comprehensive list: " + pol.PQNo + ", " + pol.PartNumber + ", " + pol.ReicUnitPrice + "," + pol.Quantity + "," + pol.ItemTotal); } //---OPEN THE PQ Printout Print Preview /*if (pf.InFavorOf == "Supplier") * { * PQ_PrintScreen_IFOSupplier pq = new PQ_PrintScreen_IFOSupplier(); * pq.PQNo = pf.PQNo; * pq.FirstTime = false; * pq.ShowDialog(); * } * else * { * PQ_PrintScreen pq = new PQ_PrintScreen(); * pq.PQNo = pf.PQNo; * pq.FirstTime = false; * pq.ShowDialog(); * }*/ } }