Ejemplo n.º 1
0
        // Calls the Employee.RequestStatus method.
        private void DataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int orderIdx   = this.OrderListView.Columns["Order Id"].Index;
            int invoiceIdx = this.OrderListView.Columns["Invoice"].Index;

            // Ignore clicks that are not on button cells.
            if (e.RowIndex > -1 && e.RowIndex < this.OrderListView.RowCount - 1)
            {
                String orderId = (String)this.OrderListView[orderIdx, e.RowIndex].Value.ToString();
                if (e.ColumnIndex == this.OrderListView.Columns["Edit"].Index)
                {
                    // Retrieve the task ID.
                    CreateOrder cs = new CreateOrder(orderId, this);
                    cs.Show();
                }
                else if (e.ColumnIndex == this.OrderListView.Columns["Delete"].Index)
                {
                    try
                    {
                        var x = MessageBox.Show("Do you want to delete? ", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (DialogResult.Yes == x)
                        {
                            String sqlQuery = "DELETE FROM dbo.cart WHERE order_id= " + orderId;
                            db.RunQuery(sqlQuery).Close();
                            sqlQuery = "DELETE FROM dbo.order_list WHERE order_id= " + orderId;
                            db.RunQuery(sqlQuery).Close();
                            MessageBox.Show("Data Deleted successfully", "Deleted", MessageBoxButtons.OK, MessageBoxIcon.None);
                            // need to close this form after click 'OK' button
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    OrderLoad(true, true);
                }
                else if (e.ColumnIndex == this.OrderListView.Columns["Invoice"].Index)
                {
                    // Retrieve the task ID.
                    String       totalTxt = (String)this.OrderListView[invoiceIdx, e.RowIndex].Value.ToString();
                    printPreview preview  = new printPreview(orderId, totalTxt);
                    preview.Show();
                }
            }
        }
Ejemplo n.º 2
0
        private void PrintBtn_Click(object sender, EventArgs e)
        {
            var x = DialogResult.No;

            if (isModified)
            {
                x = MessageBox.Show("Unsaved data will not show on invoice, Do you want to SAVE order?", "Open Invoice", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
            }
            if (DialogResult.Cancel == x)
            {
                return;
            }
            else if (DialogResult.Yes == x)
            {
                saveData(false);
            }
            printPreview preview = new printPreview(this.orderId, this.TotalTxt.Text);

            preview.Show();
        }