コード例 #1
0
ファイル: RFQ_MainScreen.cs プロジェクト: kleitz/REIC-POMS
        //-----------------------------
        // CREATE RFQ BUTTON METHODS  |
        //-----------------------------
        private void btnCreateRFQ_Click(object sender, EventArgs e)
        {
            RFQ_CreateForm crfq = new RFQ_CreateForm();
            //Generating the RFQ No.
            //Search SQL for existing RFQs with "YYMM-%" (e.g. 1604-%). nthRFQ is +1 to the number of rows returned.
            string year           = DateTime.Now.ToString("yy"); //Last two digits of year (e.g. 2016 becomes 16)
            string month          = DateTime.Now.ToString("MM");
            int    rfqCount       = sql.GetRowCount("rfq_t", year, month);
            string generatedRFQNo = year + month + "-" + (rfqCount + 1).ToString("D3"); //D3 for padded zeroes and ensure there are 3 digits.

            crfq.RFQNo = generatedRFQNo;
            crfq.ShowDialog();        //Validation happens at RFQ_CreateForm.cs

            if (crfq.Cancel == false) //Meaning, will create the RFQ. If Cancel is true, nothing happens.
            {
                //---ADD the new Request for Price Quotation to the ArrayList
                rfqList.Add(new RFQ(crfq.RFQNo,
                                    crfq.RequestDate,
                                    crfq.PaymentTerms,
                                    crfq.DeliveryTerms,
                                    crfq.CustomerIDFK,
                                    crfq.SupplierIDFK,
                                    null)); //Null, since there's no PQ No. (Its value will only be set when its PQ has been created)

                //Save to rfq_t database
                RFQ newRFQ = (RFQ)rfqList[(rfqList.Count - 1)]; //Casting
                sql.InsertRFQ(newRFQ);

                for (int i = 0; i < crfq.RFQOrderLineList.Count; i++) //Go through newly created RFQs' OrderLines
                {
                    //Add to ArrayList
                    RFQ_OrderLine rol = (RFQ_OrderLine)crfq.RFQOrderLineList[i]; //Casting

                    /*rfqOrderLineList.Add(new RFQ_OrderLine(rol.RFQNo,
                     *                                     rol.PartNumber,
                     *                                     rol.Quantity)); --> No need; won't use*/
                    //Save to rfq_order_line_t database
                    sql.InsertRFQOrderLine(rol);

                    //MessageBox.Show("OrderLine added to comprehensive list: " + rol.RFQNo + ", " + rol.PartNumber + ", " + rol.Quantity);
                }

                //---DISPLAY the newly created RFQ in the Main Screen DGV
                dgvRFQ.Rows.Add(crfq.RFQNo, crfq.RequestDate, crfq.SupplierName, crfq.CustomerName);
                dgvRFQ.Sort(dgvRFQ.Columns["RFQNo"], ListSortDirection.Descending); //So that newly added row is on top

                //---OPEN THE RFQ Printout Print Preview
                RFQ_PrintScreen rfqps = new RFQ_PrintScreen();
                rfqps.RFQNo     = crfq.RFQNo; //For the Print Screen to use in its SQL statement
                rfqps.FirstTime = true;
                rfqps.ShowDialog();

                //---MESSAGEBOX FOR DEBUG PURPOSES

                /*MessageBox.Show("RFQ CREATED: " + crfq.RFQNo + ", " + crfq.RequestDate + ", " + crfq.PaymentTerms + ", " +
                 *              crfq.DeliveryTerms + ", " + "Customer " + crfq.CustomerIDFK + ", " + "Supplier " + crfq.SupplierIDFK + ", "
                 + "With " + crfq.RFQOrderLineList.Count + " Orderlines. Inserted to ArrayList index [" + (rfqList.Count - 1) + "]");
                 */
            }
        }
コード例 #2
0
ファイル: RFQ_MainScreen.cs プロジェクト: kleitz/REIC-POMS
        //---------------------------
        // VIEW RFQ BUTTON METHODS  |
        //---------------------------
        private void btnViewRFQ_Click(object sender, EventArgs e)
        {
            //---SEARCH for the other values of the selected RFQ
            for (int i = 0; i < rfqList.Count; i++) //Finding the RFQ in the ArrayList
            {
                if (rfqList[i] != null)
                {
                    RFQ r = (RFQ)rfqList[i];                                         //Casting. So I can retrieve values from this specific RFQ.

                    if (r.RFQNo == dgvRFQ.SelectedRows[0].Cells[0].Value.ToString()) //If RFQ Numbers match
                    {
                        //---SET values in forms' labels & DISPLAY the view form
                        RFQ_ViewForm rfqvf = new RFQ_ViewForm();
                        rfqvf.RFQNoToView         = r.RFQNo;
                        rfqvf.RequestDateToView   = r.RequestDate;
                        rfqvf.PaymentTermsToView  = r.PaymentTerms;
                        rfqvf.DeliveryTermsToView = r.DeliveryTerms;
                        rfqvf.CustomerNameToView  = dgvRFQ.SelectedRows[0].Cells["Customer"].Value.ToString();
                        rfqvf.SupplierNameToView  = dgvRFQ.SelectedRows[0].Cells["Supplier"].Value.ToString();

                        //Retrieve other Supplier Details
                        Supplier s = sql.SelectSupplierDetails(r.SupplierID);
                        rfqvf.SupplierPersonToView  = s.SupplierPerson;
                        rfqvf.SupplierNumberToView  = s.SupplierNumber;
                        rfqvf.SupplierEmailToView   = s.SupplierEmail;
                        rfqvf.SupplierAddressToView = s.SupplierAddress;

                        //Retrieve Order Line Details
                        //Happens in View Form: at RFQ_OrderLine_Load

                        //Open RFQ_ViewForm.cs
                        rfqvf.ShowDialog();
                    }
                }
            }
        }
コード例 #3
0
        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();
                 * }*/
            }
        }