예제 #1
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            if (dataOrderView.Rows.Count == 0)
            {
                DialogResult dialog = MessageBox.Show("لا يوجد بيانات للطباعة", "لا يوجد بيانات", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (dataOrderView.Rows.Count != 0)
            {
                //Adding to Database
                var x = order.OrderItems;
                order.OrderItems = null;
                if (DelevryradioButton.Checked == true)
                {
                    order.DateTime  = DateTime.Now;
                    order.Ordertype = "DELIVRY";
                    c.Orders.Add(order);
                    c.SaveChanges();
                }
                if (OrderradioButton.Checked == true)
                {
                    order.DateTime  = DateTime.Now;// AddeddateTimePicker.Value;//
                    order.Ordertype = "ORDER";
                    c.Orders.Add(order);
                    c.SaveChanges();
                }
                if (takeawayradioButton.Checked == true)
                {
                    order.DateTime  = DateTime.Now;
                    order.Ordertype = "TAKEAWAY";
                    c.Orders.Add(order);
                    c.SaveChanges();
                }



                #region add to DB from OrderItems list
                foreach (var item in x)
                {
                    c.OrderItems.Add(new OrderItems()
                    {
                        OrderID         = order.OrderID,
                        ItemID          = item.ItemID,
                        Quantity        = item.Quantity,
                        Size            = item.Size,
                        TPrice_for_Item = item.TPrice_for_Item,
                        Price_Item      = item.Price_Item,
                        DateTime        = DateTime.Now //AddeddateTimePicker.Value
                    });
                }
                #endregion

                c.SaveChanges();
                order = new GetOrder();
                RefreshdataOrderView();
            }
        }
예제 #2
0
        public void addclclosed(int savedclientsuccs)
        {
            try
            {
                if (savedclientsuccs == 1)
                {
                    allmony = 0;
                    var x = order.OrderItems;
                    order.OrderItems = null;
                    var laterorder = c.LaterPayedOrder.FirstOrDefault(o => o.OrderID == latercurntsvedorderid);
                    laterorder.Ordertype = "ORDERD";
                    c.SaveChanges();
                    foreach (DataGridViewRow dr in dataOrderView.Rows)
                    {
                        c.LaterPaiedOrderItem.Add(new LaterPaiedOrderItem()
                        {
                            OrderID         = latercurntsvedorderid,
                            ItemName        = dr.Cells["orderItemsName"].Value.ToString(),
                            Quantity        = Convert.ToInt32(dr.Cells["quantety"].Value),
                            Size            = dr.Cells["Size"].Value.ToString(),
                            TPrice_for_Item = Convert.ToDecimal(dr.Cells["Price_Item"].Value),
                            Price_Item      = Convert.ToDecimal(dr.Cells["TotalPrice_for_Item"].Value),
                        });
                    }
                    //foreach (var item in x)
                    //{
                    //    c.LaterPaiedOrderItem.Add(new LaterPaiedOrderItem()
                    //    {
                    //        OrderID = order.OrderID,
                    //        ItemID = item.ItemID,
                    //        Quantity = item.Quantity,
                    //        Size = item.Size,
                    //        TPrice_for_Item = item.TPrice_for_Item,
                    //        Price_Item = item.Price_Item,
                    //        //DateTime = DateTime.Now  //AddeddateTimePicker.Value
                    //    });
                    //}

                    c.SaveChanges();

                    LaterPaiedorder = new LaterPayedOrder();

                    order = new GetOrder();
                    RefreshdataOrderView();
                    clearinfo();

                    dataOrderView.DataSource = null;
                    disableinfo();
                }
            }
            catch { }
        }
예제 #3
0
        private void laterPaied_Click(object sender, EventArgs e)
        {
            if (dataOrderView.Rows.Count == 0)
            {
                DialogResult dialog = MessageBox.Show("لا يوجد بيانات للاضافة", "لا يوجد بيانات", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var unnessaryitem = c.LaterPayedOrder.Where(o => o.Ordertype.Contains("NotOrderdYet")).ToList();

            foreach (var item in unnessaryitem)
            {
                c.LaterPayedOrder.Remove(item);
            }
            var dattime = DateTime.Now;

            x = LaterPaiedorder.LaterPaiedOrderItem;
            LaterPaiedorder.LaterPaiedOrderItem = null;
            LaterPaiedorder.DateTime            = dattime;
            LaterPaiedorder.Ordertype           = "NotOrderdYet";
            c.LaterPayedOrder.Add(LaterPaiedorder);
            c.SaveChanges();

            latercurntsvedorderid = LaterPaiedorder.OrderID;

            if (curentuserid > 0)
            {
                using (var addclientfrm = new Late_paymentOrderMony())
                {
                    addclientfrm.clientID = curentuserid;
                    addclientfrm.OrdeId   = latercurntsvedorderid;
                    if (dataOrderView.Rows.Count > 0)
                    {
                        foreach (DataGridViewRow dr in dataOrderView.Rows)
                        {
                            allmony += Convert.ToDouble(dr.Cells["TotalPrice_for_Item"].Value);
                        }

                        addclientfrm.AllmonyPaied = allmony;
                    }
                    var result = addclientfrm.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        savedclientsuccs = addclientfrm.donevalue;
                        addclclosed(savedclientsuccs);
                    }
                }
            }
            else
            {
                using (var addclientfrm = new Late_paymentOrderMony())
                {
                    if (dataOrderView.Rows.Count > 0)
                    {
                        addclientfrm.OrdeId = latercurntsvedorderid;
                        foreach (DataGridViewRow dr in dataOrderView.Rows)
                        {
                            allmony += Convert.ToDouble(dr.Cells["TotalPrice_for_Item"].Value);
                        }

                        addclientfrm.AllmonyPaied = allmony;
                    }
                    var result = addclientfrm.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        savedclientsuccs = addclientfrm.donevalue;
                        addclclosed(savedclientsuccs);
                    }
                }
            }
            //---------------
            order.OrderItems = null;
            order            = new GetOrder();
            RefreshdataOrderView();
            OrderradioButton.Checked   = true;
            DelevryradioButton.Checked = false;
            //-------
        }