示例#1
0
        private void BtnAdd_Click(object sender, System.EventArgs e)
        {
            var frm = new Form_OrderAddEdit();

            if (frm.ShowDialog() == DialogResult.OK)
            {
            }
            LoadOrder();
        }
示例#2
0
        private void Gv_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                DataGridView senderGrid = (DataGridView)sender;
                string       orderNo    = gv.Rows[e.RowIndex].Cells[ConstColumns.ORDER_NO].Value.ToString();


                if ((senderGrid.Columns[e.ColumnIndex] is DataGridViewImageColumn || senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn) && e.RowIndex >= 0)
                {
                    switch (senderGrid.Columns[e.ColumnIndex].Name)
                    {
                    case "Edit":
                        var frm = new Form_OrderAddEdit
                        {
                            orderNo = orderNo
                        };
                        if (frm.ShowDialog() == DialogResult.OK)
                        {
                            LoadOrder();
                        }
                        break;

                    case "Print":
                        break;

                    case ConstColumns.BTN_INVOICE:
                        string invocieFlag = gv.Rows[e.RowIndex].Cells[ConstColumns.INVOICE_FLAG].Value.ToString();
                        if (invocieFlag == "1")
                        {
                            return;
                        }
                        bool pickingCompleteFlag = OrderItemController.CheckPickingComplete(orderNo);
                        if (pickingCompleteFlag == false)
                        {
                            DialogResult result = MessageBox.Show("จำนวนสินยังไม่ครบตามใบสั่งขาย ท่านยังต้องขายใช่ไหม", "Warning ", MessageBoxButtons.YesNo);
                            if (result == DialogResult.Yes)
                            {
                                var frmInv = new Form_InvoiceAddEdit
                                {
                                    orderNo = orderNo
                                };
                                if (frmInv.ShowDialog() == DialogResult.OK)
                                {
                                    LoadOrder();
                                }
                            }
                            else
                            {
                                LoadItem(orderNo);
                                return;
                            }
                        }
                        else
                        {
                            var frmInv = new Form_InvoiceAddEdit
                            {
                                orderNo = orderNo
                            };
                            if (frmInv.ShowDialog() == DialogResult.OK)
                            {
                                LoadOrder();
                            }
                        }
                        break;

                    case ConstColumns.BTN_PRODUCT_SLIP:
                        var frmSlip = new Form_ProductSlip
                        {
                            orderNo = orderNo,
                        };
                        if (frmSlip.ShowDialog() == DialogResult.OK)
                        {
                            LoadOrder();
                        }
                        break;
                    }
                }
                if (senderGrid.Columns[e.ColumnIndex] is DataGridViewLinkColumn)
                {
                    LoadItem(orderNo);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }