Ejemplo n.º 1
0
        /// <summary>
        /// 添加一个菜--中间表的对象
        /// </summary>
        /// <param name="rop">订单和菜的中间表的对象---</param>
        /// <returns>受影响的行数</returns>
        public int AddR_Order_Product(R_Order_Product rop)
        {
            string sql = "insert into R_Order_product(OrderId, ProId, DelFlag, SubTime, UnitCount)values( @OrderId, @ProId, @DelFlag, @SubTime, @UnitCount)";
            SqlParameter[] ps = {
                 new SqlParameter("@OrderId",rop.OrderId),
                 new SqlParameter("@ProId",rop.ProId),
                 new SqlParameter("@DelFlag",rop.DelFlag),
                 new SqlParameter("@SubTime",rop.SubTime),
                 new SqlParameter("@UnitCount",rop.UnitCount)

                               };
            return SqlHelper.ExecuteNonQuery(sql, ps);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据订单的id查询该餐桌点了多少个菜,总金额
        /// </summary>
        /// <param name="orderId">订单的id</param>
        /// <returns></returns>
        public R_Order_Product GetCountAndSumMoney(int orderId)
        {
            string sql = "select count(*),sum(UnitCount*ProPrice) from R_Order_Product inner join ProductInfo on R_Order_Product.ProId=ProductInfo.ProId where R_Order_Product.DelFlag=0 and OrderId=" + orderId;
            R_Order_Product rop = new R_Order_Product();
            using (SqlDataReader reader = SqlHelper.ExecuteReader(sql))
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        rop.Count = Convert.ToInt32(reader[0]);//数量
                        //天坑=========
                        if (DBNull.Value != reader[1]) //避免报异常
                        {
                            rop.Money = Convert.ToDecimal(reader[1]);

                        }// end if

                    }// end while
                }// end if
            }// end using
            return rop;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 添加一个菜--中间的对象
 /// </summary>
 /// <param name="rop">中间表的对象---订单和菜</param>
 /// <returns>添加成功还是失败</returns>
 public bool AddR_Order_Product(R_Order_Product rop)
 {
     return ropDal.AddR_Order_Product(rop) > 0;
 }
Ejemplo n.º 4
0
        //用户双击该控件发生
        private void dgvProduct_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            //判断是都选中了菜
            if (dgvProduct.SelectedRows.Count <= 0)
            {
                md.MsgDivShow("请先选中要添加的菜", 1);
                return;
            }
            int tCount;
            if (string.IsNullOrEmpty(txtCount.Text) || txtCount.Text == "1" || txtCount.Text == "0")
            {
                //txtCount.Text = "1";
                tCount = 1;
            }
            //判断文本框中输入的数量
            else if (!int.TryParse(txtCount.Text, out tCount))//转换不成功  说明txtCount没有值
            {

                md.MsgDivShow("请输入正确个数", 1);
                return;
            }
            //文本框的数量转换成功了
            //获取选中菜的Id====添加到中间表(订单和菜的中间表)
            //int proId=((ProductInfo)dgvProduct.SelectedRows[0].DataBoundItem).ProId;//菜的Id
            R_Order_Product rop = new R_Order_Product();//中间表对象
            rop.DelFlag = 0;
            rop.OrderId = Convert.ToInt32(labOrderId.Text);//订单的id
            // rop.ProId=proId;//菜的Id
            rop.ProId = ((ProductInfo)dgvProduct.SelectedRows[0].DataBoundItem).ProId;//菜的Id
            rop.SubTime = System.DateTime.Now;
            rop.UnitCount = tCount;
            R_Order_ProductBll ropBll = new R_Order_ProductBll();
            md.MsgDivShow(ropBll.AddR_Order_Product(rop) ? "操作成功" : "操作失败", 1);
            //刷新
            //显示点的菜
            //=============坑
            LoadR_Order_ProductByOrdrtId(Convert.ToInt32(labOrderId.Text));
        }
Ejemplo n.º 5
0
 //关系转对象
 private R_Order_Product RowToR_Order_productByRow(DataRow dr)
 {
     R_Order_Product rop = new R_Order_Product();
     rop.ROrderProId = Convert.ToInt32(dr["ROrderProId"]);
     rop.ProName = dr["ProName"].ToString();
     rop.ProPrice = Convert.ToDouble(dr["ProPrice"]);
     rop.UnitCount = Convert.ToInt32(dr["UnitCount"]);
     rop.ProUnit = dr["ProUnit"].ToString();
     rop.ProMoney = rop.ProPrice * rop.UnitCount;//金额!!!!!!!!
     rop.CName = dr["CName"].ToString();
     rop.SubTime = Convert.ToDateTime(dr["SubTime"]);
     return rop;
 }