Exemple #1
0
        public int DeleteJoinTableAll(OrderDateModel itemOrder)
        {
            int result = 0;
            try
            {
                ORDER_DATE orderDateTemp = new ORDER_DATE();
                List<ORDER_DETAIL_DATE> lstOrderDetaiDate = new List<ORDER_DETAIL_DATE>();
                List<ORDER_DETAIL_MODIFIRE_DATE> lstOrderDetailModifire = new List<ORDER_DETAIL_MODIFIRE_DATE>();

                OrderDateModel orderDateMoldeTemp = new OrderDateModel();
                orderDateMoldeTemp = GetOrderByTable(itemOrder.FloorID, 0);

                if (itemOrder.ListOrderDetail.Count > 0)
                {
                    using (var transaciton = _context.Database.BeginTransaction())
                    {
                        orderDateTemp = CopyOrder(itemOrder);
                        //_context.Entry(orderDateTemp).State = System.Data.Entity.EntityState.Modified;
                        _context.Database.ExecuteSqlCommand("delete from ORDER_DATE  where OrderID='" + itemOrder.OrderID + "'");
                        lstOrderDetaiDate = CopyOrderDetailDate(itemOrder);
                        foreach (ORDER_DETAIL_DATE item in lstOrderDetaiDate)
                        {

                            _context.Database.ExecuteSqlCommand("delete from ORDER_DETAIL_DATE where OrderDetailID='" + item.OrderDetailID + "'");

                        }

                        lstOrderDetailModifire = CopyOrderMidifireDate(itemOrder);
                        foreach (ORDER_DETAIL_MODIFIRE_DATE item in lstOrderDetailModifire)
                        {
                            //_context.Entry(item).State = System.Data.Entity.EntityState.Deleted;
                            // _context.ORDER_DETAIL_MODIFIRE_DATE.Remove(item);
                            _context.Database.ExecuteSqlCommand("delete ORDER_DETAIL_MODIFIRE_DATE where OrderModifireID='" + item.OrderModifireID + "'");
                        }
                        _context.SaveChanges();
                        transaciton.Commit();
                        result = 1;
                    }

                }
            }
            catch (Exception ex)
            {
                LogPOS.WriteLog("OrderService::::::::::::::::::::DeleteJoinTableAll::::::::::::::" + ex.Message);
            }
            return result;
        }
Exemple #2
0
        public int InsertOrder(OrderDateModel itemOrder)
        {
            int flag = 0;
            try
            {
                ORDER_DATE orderDateTemp = new ORDER_DATE();
                List<ORDER_DETAIL_DATE> lstOrderDetaiDate = new List<ORDER_DETAIL_DATE>();
                List<ORDER_DETAIL_MODIFIRE_DATE> lstOrderDetailModifire = new List<ORDER_DETAIL_MODIFIRE_DATE>();
                List<SEAT> lstSeat = new List<SEAT>();
               // ORDER_DETAIL_DATE orderDetailTemp = new ORDER_DETAIL_DATE();
                //ORDER_DETAIL_MODIFIRE_DATE orderDetailModofireDate = new ORDER_DETAIL_MODIFIRE_DATE();
                OrderDateModel orderDateMoldeTemp = new OrderDateModel();
                orderDateMoldeTemp= GetOrderByTable(itemOrder.FloorID,0);

                if (orderDateMoldeTemp.ListOrderDetail.Count > 0)
                {
                    using (var transaciton = _context.Database.BeginTransaction())
                    {
                        orderDateTemp = CopyOrder(itemOrder);
                        //_context.Entry(orderDateTemp).State = System.Data.Entity.EntityState.Modified;
                        _context.Database.ExecuteSqlCommand("update ORDER_DATE set TotalAmount='" + orderDateTemp.TotalAmount + "',Seat='"+ itemOrder.Seat+"' where OrderID='"+ orderDateTemp.OrderID+"'");

                        lstSeat = CopySeat(orderDateMoldeTemp);
                        foreach (SEAT item in lstSeat)
                        {
                            _context.Database.ExecuteSqlCommand("delete from SEAT where ID='" + item.ID + "'");
                        }
                        lstSeat = CopySeat(itemOrder);

                        foreach (SEAT item in lstSeat)
                        {
                            item.OrderNumber = itemOrder.OrderNumber;
                            _context.Entry(item).State = System.Data.Entity.EntityState.Added;
                            _context.SaveChanges();
                        }
                        lstOrderDetaiDate = CopyOrderDetailDate(orderDateMoldeTemp);
                        foreach (ORDER_DETAIL_DATE item in lstOrderDetaiDate)
                        {

                            _context.Database.ExecuteSqlCommand("delete from ORDER_DETAIL_DATE where OrderDetailID='" + item.OrderDetailID + "'");

                        }
                        lstOrderDetaiDate = CopyOrderDetailDate(itemOrder);
                        foreach (ORDER_DETAIL_DATE item in lstOrderDetaiDate)
                        {
                            // _context.Entry(item).State = System.Data.Entity.EntityState.Added;;

                            _context.Database.ExecuteSqlCommand("insert into ORDER_DETAIL_DATE(OrderID,OrderNumber,ProductID,KeyItem,Status,Price,Qty,Total,Seat,DynId,PrintType)values" +
                                "('" + item.OrderID + "', '"+ item.OrderNumber+"', '" + item.ProductID + "','" + item.KeyItem + "','" + item.Status + "','" + item.Price + "','" + item.Qty + "','" + item.Total + "','" + item.Seat + "','"+item.DynId+"','"+ item.PrintType+"')");

                        }
                        lstOrderDetailModifire = CopyOrderMidifireDate(orderDateMoldeTemp);
                        foreach (ORDER_DETAIL_MODIFIRE_DATE item in lstOrderDetailModifire)
                        {
                            //_context.Entry(item).State = System.Data.Entity.EntityState.Deleted;
                            // _context.ORDER_DETAIL_MODIFIRE_DATE.Remove(item);
                            _context.Database.ExecuteSqlCommand("delete ORDER_DETAIL_MODIFIRE_DATE where OrderModifireID='" + item.OrderModifireID + "'");
                        }
                        lstOrderDetailModifire = CopyOrderMidifireDate(itemOrder);
                        foreach (ORDER_DETAIL_MODIFIRE_DATE item in lstOrderDetailModifire)
                        {
                            // _context.Entry(item).State = System.Data.Entity.EntityState.Added;
                            _context.Database.ExecuteSqlCommand("insert into ORDER_DETAIL_MODIFIRE_DATE (OrderDetailID,OrderID,OrderNumber,ProductID,KeyModi,ModifireID,Status,Price,Qty,Total,Seat,DynID)values" +
                                "('" + item.OrderDetailID + "','" + item.OrderID + "','" + item.OrderNumber + "', '" + item.ProductID + "','" + item.KeyModi + "','" + item.ModifireID + "','" + item.Status + "','" + item.Price + "','" + item.Qty + "','" + item.Total + "','" + item.Seat + "','" + item.DynId + "')");

                        }
                        transaciton.Commit();
                        flag = 1;
                    }

                }
                else
                {
                    using (var Tranx = _context.Database.BeginTransaction())
                    {
                        orderDateTemp = CopyOrder(itemOrder);
                        _context.Entry(orderDateTemp).State = System.Data.Entity.EntityState.Added;
                        _context.SaveChanges();
                        int i = orderDateTemp.OrderID;
                        string OrderNum = i + "" + DateTime.Now.Date.Year + "" + DateTime.Now.Date.Month + "" + DateTime.Now.Date.Day;
                        _context.Database.ExecuteSqlCommand("update ORDER_DATE set OrderNumber='" + OrderNum + "' where OrderID='"+ i+"'");
                        lstSeat = CopySeat(itemOrder);
                        foreach (SEAT item in lstSeat)
                        {
                            item.OrderNumber = Convert.ToInt32(OrderNum);
                            _context.Entry(item).State = System.Data.Entity.EntityState.Added;
                        }
                        lstOrderDetaiDate = CopyOrderDetailDate(itemOrder);
                        foreach (ORDER_DETAIL_DATE item in lstOrderDetaiDate)
                        {
                            item.OrderID = i;
                            item.OrderNumber = Convert.ToInt32(OrderNum);
                            _context.Entry(item).State = System.Data.Entity.EntityState.Added;

                        }

                        lstOrderDetailModifire = CopyOrderMidifireDate(itemOrder);
                        foreach (ORDER_DETAIL_MODIFIRE_DATE item in lstOrderDetailModifire)
                        {
                            item.OrderID = i;
                            item.OrderNumber = Convert.ToInt32(OrderNum);
                            _context.Entry(item).State = System.Data.Entity.EntityState.Added;

                        }
                        _context.SaveChanges();
                        flag = 1;
                        Tranx.Commit();
                    }
                }
            }
            catch (Exception ex)
            {

                LogPOS.WriteLog("InsertOrder::::::::::::::::::::::::::::::::::" + ex.Message);
            }
            return flag;
        }
Exemple #3
0
        public int JoinTable(List<OrderJoinTableModel> OrderJoin)
        {
            int result = 0;
            //update ORDER_DATE set TotalAmount
            try
            {
                int TableNew = OrderJoin[0].TableIDNew;
                double toal=0;
                int OrderIDNew;
                using (var tranJoinTable = _context.Database.BeginTransaction())
                {
                    for (int i = 0; i < OrderJoin.Count; i++)
                    {
                        toal = toal + OrderJoin[i].SubTotalTable;
                    }
                    OrderDateModel OrderCheck = GetOrderByTable(TableNew.ToString(), 0);
                    if (OrderCheck.ListOrderDetail.Count > 0)
                    {
                        _context.Database.ExecuteSqlCommand("update ORDER_DATE SET TotalAmount=TotalAmount+'" + toal + "'WHERE OrderID='"+ OrderCheck.OrderID+"'AND OrderNumber='"+ OrderCheck.OrderNumber+"'");
                        for (int i = 0; i < OrderJoin.Count; i++)
                        {

                            _context.Database.ExecuteSqlCommand("delete  ORDER_DATE where OrderID='" + OrderJoin[i].OrderID + "'");

                            _context.Database.ExecuteSqlCommand("update  ORDER_DETAIL_DATE set OrderID='" + OrderCheck.OrderID + "',Seat=0,OrderNumber='"+ OrderCheck.OrderNumber+"' where OrderID='" + OrderJoin[i].OrderID + "'");
                            _context.Database.ExecuteSqlCommand("update  ORDER_DETAIL_MODIFIRE_DATE set OrderID='" + OrderCheck.OrderID + "',Seat=0,OrderNumber='" + OrderCheck.OrderNumber + "'  where OrderID='" + OrderJoin[i].OrderID + "'");

                        }
                        tranJoinTable.Commit();
                        result = 1;
                    }
                    else
                    {

                        ORDER_DATE OrderJoinNew = new ORDER_DATE();
                        OrderJoinNew.FloorID = TableNew.ToString();
                        OrderJoinNew.Seat = 0;
                        OrderJoinNew.TotalAmount = toal;
                        OrderJoinNew.CreateBy = 0;
                        OrderJoinNew.CreateDate = DateTime.Now;
                        OrderJoinNew.UpdateBy = 0;
                        OrderJoinNew.UpdateDate = DateTime.Now;
                        //OrderJoinNew.OrderNumber = order
                        OrderJoinNew.ClientID = 0;
                        _context.Entry(OrderJoinNew).State = System.Data.Entity.EntityState.Added;
                        _context.SaveChanges();
                        OrderIDNew = OrderJoinNew.OrderID;
                        for (int j = 0; j < OrderJoin.Count; j++)
                        {
                            _context.Database.ExecuteSqlCommand("update  ORDER_DETAIL_DATE set OrderID='" + OrderIDNew + "',Seat=0 where OrderID='" + OrderJoin[j].OrderID + "'");
                        }
                        for (int j = 0; j < OrderJoin.Count; j++)
                        {
                            _context.Database.ExecuteSqlCommand("update  ORDER_DETAIL_MODIFIRE_DATE set OrderID='" + OrderIDNew + "',Seat=0 where OrderID='" + OrderJoin[j].OrderID + "'");
                        }
                        for (int i = 0; i < OrderJoin.Count; i++)
                        {

                            _context.Database.ExecuteSqlCommand("delete  ORDER_DATE where OrderID='" + OrderJoin[i].OrderID + "'");
                        }

                        tranJoinTable.Commit();
                        result = 1;
                    }

                }
            }
            catch (Exception ex)
            {
                LogPOS.WriteLog("OrderService::::::::::::::::::::JoinTable::::::::::::::" + ex.Message);
            }
            return result;
        }
Exemple #4
0
 private ORDER_DATE CopyOrder(OrderDateModel itemOrder)
 {
     ORDER_DATE orderDate = new ORDER_DATE();
     orderDate.FloorID = itemOrder.FloorID.ToString();
     orderDate.OrderNumber = itemOrder.OrderNumber;
     orderDate.OrderID = itemOrder.OrderID;
     orderDate.TotalAmount = itemOrder.TotalAmount ?? 0;
     orderDate.Status = itemOrder.Status;
     orderDate.ClientID = itemOrder.ClientID ?? 0;
     orderDate.CreateBy = itemOrder.CreateBy ?? 0;
     orderDate.CreateDate = DateTime.Now;
     orderDate.UpdateBy = itemOrder.UpdateBy ?? 0;
     orderDate.UpdateDate = DateTime.Now;
     orderDate.Note = itemOrder.Note ?? "";
     orderDate.Seat = itemOrder.Seat;
     orderDate.ShiftID = itemOrder.ShiftID;
     orderDate.Note = itemOrder.Note;
     orderDate.PrinterNote = itemOrder.PrinterNote;
     return orderDate;
 }