Exemplo n.º 1
0
        private void btnCreateOrder_Click(object sender, EventArgs e)
        {
            try
            {
                Order o = new Order();
                o.CustomerID   = cmbCustomer.SelectedValue.ToString();
                o.EmployeeID   = (int)cmbEmployee.SelectedValue;
                o.OrderDate    = dateOrder.Value;
                o.RequiredDate = dateRequired.Value;
                o.ShipVia      = (int)cmbShipVia.SelectedValue;
                o.Freight      = Convert.ToDecimal(txtFreight.Text);

                if (txtFreight.Text != null && dateOrder.Value > DateTime.Today && dateRequired.Value > dateOrder.Value)
                {
                    db.Orders.Add(o);
                    db.SaveChanges();

                    FormOrderHeaderDetail frm = new FormOrderHeaderDetail(o.OrderID);
                    frm.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Girilen verilerde hata var");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        public void OrderCheck()
        {
            int secilenOrderID;

            try
            {
                secilenOrderID = Convert.ToInt32(txtOrdersID.Text);
            }
            catch (Exception)
            {
                secilenOrderID = 0;
            }

            List <Order> olist = db.Orders.Where(x => x.OrderID == secilenOrderID).ToList();

            if (olist.Count == 0)
            {
                MessageBox.Show("Girilen Id'de sipariş yok.");
            }
            else
            {
                FormOrderHeaderDetail frm = new FormOrderHeaderDetail(secilenOrderID);
                frm.Show();
                this.Hide();
            }
        }