コード例 #1
0
ファイル: frmDisOrder.cs プロジェクト: hamid42643/UnderGuard
        private void btnSendToSupplier_Click(object sender, EventArgs e)
        {
            try
            {
                //get selected row id and send it to the supplier form
                object  id          = dataGridView1.CurrentRow.Cells["ORDER_id"].Value;
                DataRow selectedRow = dtOrders.Rows.Find(id);

                //if orderid is in the sorder table
                ClassLibrary.SupplierOrder sorder = new ClassLibrary.SupplierOrder();
                sorder.OrderId = Convert.ToInt32(id);
                DataTable dt = sorder.GetSorderByOrderId().Tables[0];

                //if customer order hasnt been sent to suppliers before
                if (dt.Rows.Count == 0)
                {
                    frmDisSupplierOrder f = new frmDisSupplierOrder(this, selectedRow);
                    f.MdiParent     = this.MdiParent;
                    f.StartPosition = FormStartPosition.CenterScreen;
                    f.Show();
                }
                else
                {
                    DialogResult dlgResult = MessageBox.Show
                                                 ("the order has already been sent to the suppliers!",
                                                 "Continue?", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex) { }
        }
コード例 #2
0
ファイル: frmDisSOrder.cs プロジェクト: hamid42643/UnderGuard
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                ClassLibrary.SupplierOrder sorder = new ClassLibrary.SupplierOrder();

                object  id          = dataGridView1.CurrentRow.Cells["SORDER_id"].Value;
                DataRow selectedRow = dtSOrder.Rows.Find(id);

                DialogResult dlgResult = MessageBox.Show
                                             ("Are you sure you want to delete \nselected order with id of " + id,
                                             "Continue?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (dlgResult == DialogResult.Yes)
                {
                    sorder.Id = Convert.ToInt32(id);
                    sorder.Delete();
                    DisplayAllSOrders();
                }
            }
            catch (Exception ex)
            {
                DialogResult dlgResult = MessageBox.Show
                                             ("Cant delete the record!",
                                             "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #3
0
ファイル: frmDisSOrder.cs プロジェクト: hamid42643/UnderGuard
        public void DisplayAllSOrders()
        {
            ClassLibrary.SupplierOrder sorder = new ClassLibrary.SupplierOrder();
            dtSOrder = sorder.GetAll().Tables[0];

            dataGridView1.DataSource = dtSOrder;

            //set the parts id column as primary key so you can search the table later
            dtSOrder.PrimaryKey = new DataColumn[] { dtSOrder.Columns["SORDER_id"] };
            dataGridView1.Columns["SORDER_totalprice"].DefaultCellStyle.Format = "c";

            dataGridView1.Columns["ORDER_id"].HeaderText          = "Customer Order";
            dataGridView1.Columns["SORDER_id"].HeaderText         = "ID";
            dataGridView1.Columns["SORDER_date"].HeaderText       = "Date";
            dataGridView1.Columns["SORDER_totalprice"].HeaderText = "Total Parts Price";
            dataGridView1.Columns["SORDER_status"].HeaderText     = "Status";
            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
        }
コード例 #4
0
        //----------------------------------------------------------------------------------------------
        private void frmAddOrderCustomer_Load(object sender, EventArgs e)
        {
            //make order list
            ord = new BindingList <OrderDetails>();

            //add customers to the combobox
            ClassLibrary.Customer customer = new ClassLibrary.Customer();
            dsCustomer = customer.GetAll();
            dtCustomer = dsCustomer.Tables[0];
            cmbCustomers.DataSource    = dtCustomer;
            cmbCustomers.DisplayMember = "CUSTOMER_name";
            cmbCustomers.ValueMember   = "CUSTOMER_id";

            //add products to the combobox
            ClassLibrary.Product product = new ClassLibrary.Product();
            dsProduct = product.GetAll();
            dtProduct = dsProduct.Tables[0];
            cmbProducts.DataSource    = dtProduct;
            cmbProducts.DisplayMember = "PRODUCT_name";

            //ADDING MODE
            if (drOrder == null)
            {
                dateTimePicker1.Enabled = false;
            }
            //EDITING MODE
            else
            {
                //if orderid is in the sorder table
                ClassLibrary.SupplierOrder sorder = new ClassLibrary.SupplierOrder();
                sorder.OrderId = Convert.ToInt32(drOrder.ItemArray[0]);
                DataTable dt = sorder.GetSorderByOrderId().Tables[0];

                //disables forms items
                if (dt.Rows.Count != 0)
                {
                    MakeOrderUnEditable();
                    saveDeliveryDate        = true;
                    dateTimePicker1.Enabled = true;
                }

                //select the customer combobox
                string custId = drOrder.ItemArray[1].ToString();
                try
                {
                    cmbCustomers.SelectedIndex = cmbCustomers.FindStringExact(custId);
                }
                catch (Exception ex)
                {
                }
                //display date
                dateTimePicker1.Text = drOrder.ItemArray[5].ToString();

                //display total price
                totalPrice     = Convert.ToDecimal(drOrder.ItemArray[3]);
                txtPrice.Text  = String.Format("{0:c}", totalPrice);
                txtStatus.Text = drOrder.ItemArray[4].ToString();

                //display orderdetails
                ClassLibrary.CustomerOrderDetails orderdetails = new ClassLibrary.CustomerOrderDetails();
                orderdetails.OrderId = Convert.ToInt32(drOrder.ItemArray[0]);

                DataTable thisTable = orderdetails.GetOrderDetailsByOrderId().Tables[0];

                try
                {
                    foreach (DataRow row in thisTable.Rows)
                    {
                        string price = String.Format("{0:c}", Convert.ToDecimal(row.ItemArray[3]));
                        //add to generic list
                        ord.Add(new OrderDetails
                        {
                            ProductID   = Convert.ToInt32(row.ItemArray[0]),
                            ProductName = row.ItemArray[1].ToString(),
                            Quantity    = Convert.ToInt32(row.ItemArray[2]),
                            Price       = price,
                        });
                    }
                    dataGridView1.DataSource = ord;
                }
                catch (Exception ex)
                {
                }
            }
        }