private void btnRecieved_Click(object sender, EventArgs e)
        {
            switch (MessageBox.Show(this, "Confirming to update the Purchase Order Status to 'RECIEVED'. This change is final.", "Confirming", MessageBoxButtons.YesNo))
            {
            case DialogResult.No:
                break;

            default:

                if (purchaseOrderBL.SetRecieved(purchaseOrderInfo.Purchaseorderid))
                {
                    getDataFromDatabase();
                    updateStocks();
                    frmPurchaseOrders.loadData(frmPurchaseOrders.txtSearch.Text);
                    MessageBox.Show("Success.");
                }
                else
                {
                    MessageBox.Show("Failed.");
                }
                break;
            }
        }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (dgv.Rows.Count == 0)
            {
                MessageBox.Show("No supplies selected.");
            }
            else
            {
                if (validations())
                {
                    getDataFromForm();

                    long purchaseOrderID;
                    if ((purchaseOrderID = purchaseOrderBL.Insert(purchaseOrderInfo)) > 0)
                    {
                        bool stat = true;

                        foreach (DataGridViewRow row in dgv.Rows)
                        {
                            purchaseOrderDetailInfo.Purchaseorderid              = Convert.ToInt32(purchaseOrderID);
                            purchaseOrderDetailInfo.Supplyid                     = Convert.ToInt32(row.Cells[0].Value);
                            purchaseOrderDetailInfo.Purchaseorderdetailquantity  = Convert.ToInt32(row.Cells[4].Value);
                            purchaseOrderDetailInfo.Purchaseorderdetailunitprice = Convert.ToInt32(row.Cells[3].Value);
                            if (purchaseOrderDetailBL.Insert(purchaseOrderDetailInfo) == 0)
                            {
                                stat = false;
                            }
                        }

                        if (stat)
                        {
                            MessageBox.Show("Success.");
                            clearControls();
                            this.Close();
                            frmPurchaseOrders.loadData(frmPurchaseOrders.txtSearch.Text);
                        }
                        else
                        {
                            MessageBox.Show("Failed.");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Failed.");
                    }
                }
            }
        }