Exemple #1
0
        /// <summary>
        /// 加载信息
        /// </summary>
        /// <param name="sale_id">销售单号</param>
        public void LoadInfo(string sale_id)
        {
            this.IsNowBeiCan = true;
            GetSaleTemp01 getSaletemp01 = new GetSaleTemp01();

            getSaletemp01.GetBeiCan(sale_id);

            List <OrderDinner> ListOrderDinner = new List <OrderDinner>();
            OrderDinner        orderDinner;
            int    recordNumber = getSaletemp01.RecordNumber;
            string pos_dip      = "";
            bool   ex;

            for (int i = 0; i < recordNumber; i++)
            {
                orderDinner          = new OrderDinner();
                orderDinner.ProdName = getSaletemp01.Pos_disp(i);
                pos_dip = orderDinner.ProdName;

                ex = false;//判断该元素是否已存在ListOrderDinner中true为存在false为不存在
                orderDinner.Number = 0;
                if (getSaletemp01.Comb_Type(i).Equals("1"))
                {
                }
                else
                {
                    foreach (OrderDinner a in ListOrderDinner)
                    {
                        if (a.ProdName.Equals(pos_dip))
                        {
                            ex = true;
                            break;
                        }
                    }
                    if (ex)
                    {
                    }
                    else
                    {
                        for (int j = i; j < getSaletemp01.RecordNumber; j++)
                        {
                            if (getSaletemp01.Pos_disp(j).Equals(pos_dip))
                            {
                                orderDinner.Number += (int)getSaletemp01.ProdNumber(j);
                            }
                        }
                        ListOrderDinner.Add(orderDinner);
                    }
                }
            }
            this.dgvBeican.DataSource = null;
            this.dgvBeican.DataSource = ListOrderDinner;
        }
        /// <summary>
        /// 给点单控件加载信息
        /// </summary>
        /// <param name="orderMenu">点单控件对象</param>
        private void OrderMenu_GetInfo(OrderMenu orderMenu)
        {
            //OrderDinner的集合
            List <OrderDinner> listOrderDinner = new List <OrderDinner>();

            GetSaleTemp01 getSale01 = new GetSaleTemp01();

            //选择的商品的总价格
            Info.totalPrice = 0;

            DataSet dataSet = getSale01.GetOrderInfo(Info.sale_id);


            //根据记录个数创建index_groupId数组
            orderMenu.Init_Index_Group_Array(dataSet);
            OrderDinner orderDinner;

            if (dataSet.Tables[0].Rows.Count > 0)
            {
                int xuhao = 1;
                for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
                {
                    string a = getSale01.Price_type(i);
                    //单餐
                    if (getSale01.Comb_type(i).Equals("0"))
                    {
                        orderDinner          = new OrderDinner();
                        orderDinner.ProdName = getSale01.Pos_disp(i);
                        orderDinner.Number   = getSale01.ProdNumber(i);
                        orderDinner.Discount = Convert.ToDecimal(dataSet.Tables[0].Rows[i]["ITEM_DISC"]);
                        orderDinner.Price    = getSale01.ProdPrice(i);
                        Info.totalPrice     += orderDinner.Price * orderDinner.Number + Convert.ToDecimal(dataSet.Tables[0].Rows[i]["ITEM_DISC"]);
                        orderDinner.Xu       = xuhao++;

                        orderDinner.Discount = decimal.Round(orderDinner.Discount, 1);
                        orderDinner.Total    = getSale01.Act_price(i) * orderDinner.Number;
                        //保留一位小数
                        orderDinner.Price = decimal.Round(orderDinner.Price, 1);
                        orderDinner.Total = decimal.Round(orderDinner.Total, 1);

                        listOrderDinner.Add(orderDinner);
                        if (orderDinner.Number == 1)
                        {
                            PoleDisplayer.Port = Info.cusShowPort;
                            PoleDisplayer.Clear();
                        }
                    }
                }

                this.operPara1.WriteIniInfo("totalPrice", Info.totalPrice.ToString());
                orderMenu.TotalPrice = (Info.totalPrice).ToString();
                //使价格最小精确到角
                orderMenu.TotalPrice = decimal.Round(Convert.ToDecimal(orderMenu.TotalPrice), 1) + "元";
                orderMenu.DgvOrderMenu.DataSource = null;
                orderMenu.DgvOrderMenu.DataSource = listOrderDinner;
            }
            else
            {
                orderMenu.TotalPrice = "0.0元";
                orderMenu.DgvOrderMenu.DataSource = null;
            }
            if (this.orderMenu.DgvOrderMenu.Rows.Count == 0)
            {
                Info.isDistinct  = false;
                Info.isAllowance = false;
            }
        }