Example #1
0
        /// <summary>
        /// 获取订餐记录明细
        /// </summary>
        /// <returns></returns>
        public static List <consume> GetDinnerbookDetails(string ID)
        {
            List <consume>        consumeList = new List <consume>();
            List <MySqlParameter> parameter   = new List <MySqlParameter>();
            StringBuilder         sql         = new StringBuilder(" select consumetable.ID,consumetable.StaffNo,staffs.StaffName,consumetable.ConsumeMoney,consumetable.ConsumeDatetime,consumetable.Remark ");

            sql.Append(" from consumetable inner join staffs on consumetable.StaffNo = staffs.StaffNo ");
            sql.Append(" where consumetable.State = 0 and staffs.State=0 and consumetable.BookID = @bookid ");
            parameter.Add(new MySqlParameter
            {
                ParameterName = "@bookid",
                MySqlDbType   = MySqlDbType.Int32,
                Value         = ID
            });

            MySqlDataReader dr = MySQLHelper.ExecuteReader(CommandType.Text, sql.ToString(), parameter.ToArray());

            while (dr.Read())
            {
                consume newconsume = new consume();

                newconsume.ID              = Convert.ToInt32(dr["ID"]);
                newconsume.StaffNo         = Convert.ToString(dr["StaffNo"]);
                newconsume.StaffName       = Convert.ToString(dr["StaffName"]);
                newconsume.ConsumeMoney    = Convert.ToDecimal(dr["ConsumeMoney"]);
                newconsume.ConsumeDatetime = Convert.ToDateTime(dr["ConsumeDatetime"]);
                newconsume.Remark          = Convert.ToString(dr["Remark"]);

                consumeList.Add(newconsume);
            }
            dr.Close();
            return(consumeList);
        }
        public ActionResult XiaoFeiAdd(consume info)
        {
            //查询出总经费
            MoneyManager aa  = new MoneyManager();
            money        mys = aa.GetByPK(1);

            if (info.consume_money <= mys.overmoney)
            {
                ConsumeManager a  = new ConsumeManager();
                var            qq = a.Add(info);
                if (qq)
                {
                    if (mys.overmoney == null)
                    {
                        mys.overmoney = 0;
                    }
                    if (mys.openmoney == null)
                    {
                        mys.openmoney = 0;
                    }
                    //修改总经费
                    money my = new money();
                    if (my.overmoney == null)
                    {
                        my.overmoney = 0;
                    }
                    if (my.openmoney == null)
                    {
                        my.openmoney = 0;
                    }
                    my.sunId     = 1;
                    my.overmoney = (mys.overmoney - info.consume_money);
                    my.openmoney = (mys.openmoney + info.consume_money);
                    MoneyManager aq  = new MoneyManager();
                    var          boo = aq.Update(my);
                    if (boo)
                    {
                        return(Redirect("~/ZhengLiang/FinanceHT/XiaoFeiAdd"));
                    }

                    else
                    {
                        return(Redirect("~/ZhengLiang/FinanceHT/XiaoFeiAdd"));
                    }
                }
                else
                {
                    return(Content("<script>alert('添加失败')</script>"));
                }
            }
            else
            {
                return(Content("<script>alert('余额不足');window.location = '/ZhengLiang/FinanceHT/XiaoFeiAdd';</script>"));
            }
        }
Example #3
0
        /// <summary>
        /// 吃完不新鲜食物
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult MessageEatAll(int id)
        {
            user_table user = checkUser();
            food       fo   = db.food.SingleOrDefault(f => f.id == id);

            fo.status = 2; //吃完状态修改为2
            consume c = new consume();

            c.dt   = DateTime.Now;
            c.faid = user.fid;
            c.fid  = id;
            c.uid  = user.id;
            c.kg   = fo.kg;
            db.consume.AddObject(c);
            db.SaveChanges();

            return(Redirect("/home/MessagePage"));
        }
Example #4
0
        /// <summary>
        /// 提交今天吃的食物
        /// </summary>
        /// <param name="id"></param>
        /// <param name="kg"></param>
        /// <returns></returns>
        public ActionResult indexPageRequest(int id, Double kg)
        {
            user_table user     = checkUser();
            var        food     = db.food.SingleOrDefault(f => f.id == id);
            var        eatCount = db.consume.Where(c => c.fid == id).Select(c => c.kg).Sum();

            if (eatCount != null)
            {
                if (eatCount.Value >= food.kg)
                {
                    food.status = 2;
                    db.SaveChanges();
                }
                else
                {
                    if (kg < food.kg - eatCount.Value)
                    {
                        //执行
                        consume con = new consume();
                        con.kg   = kg;
                        con.uid  = user.id;
                        con.fid  = food.id;
                        con.faid = user.fid;
                        con.dt   = DateTime.Now;
                        db.consume.AddObject(con);
                        db.SaveChanges();
                    }
                }
            }
            else
            {
                //执行
                consume con = new consume();
                con.kg   = kg;
                con.uid  = user.id;
                con.fid  = food.id;
                con.faid = user.fid;
                con.dt   = DateTime.Now;
                db.consume.AddObject(con);
                db.SaveChanges();
            }

            return(Redirect("/home/index"));
        }
        public ActionResult XiaoFeiJiLu(consume info)
        {
            if (info.consume_Condition.Equals("全部"))
            {
                int current = 1;
                if (current > 1)
                {
                    ViewBag.currents = current - 1;
                }
                else
                {
                    ViewBag.currents = 1;
                }
                int            count = 5;
                ConsumeManager a     = new ConsumeManager();

                if (info.consume_cause == null)
                {
                    List <consume> detail  = a.GetAll();
                    var            list    = detail.OrderByDescending(x => x.consume_Time).Skip((current - 1) * count).Take(count).ToList();
                    int            zongshu = detail.Count();
                    int            zongye  = zongshu / count;
                    zongye = zongshu % count == 0 ? zongye : zongye + 1;
                    if (current < zongye)
                    {
                        ViewBag.currentc = current + 1;
                    }
                    else
                    {
                        ViewBag.currentc = zongye;
                    }
                    ViewBag.zongye  = zongye;
                    ViewBag.current = current;
                    return(View(list));
                }
                else
                {
                    List <consume> detail = a.Where(x => x.consume_cause.Contains(info.consume_cause)).ToList();
                    var            list   = detail.OrderByDescending(x => x.consume_Time).Skip((current - 1) * count).Take(count).ToList();

                    int zongshu = detail.Count();
                    int zongye  = zongshu / count;
                    zongye = zongshu % count == 0 ? zongye : zongye + 1;
                    if (current < zongye)
                    {
                        ViewBag.currentc = current + 1;
                    }
                    else
                    {
                        ViewBag.currentc = zongye;
                    }
                    ViewBag.zongye  = zongye;
                    ViewBag.current = current;
                    return(View(list));
                }
            }
            else
            {
                int current = 1;
                if (current > 1)
                {
                    ViewBag.currents = current - 1;
                }
                else
                {
                    ViewBag.currents = 1;
                }
                int            count = 5;
                ConsumeManager a     = new ConsumeManager();
                //List<action> detail = a.GetAll();
                if (info.consume_cause == null)
                {
                    List <consume> detail  = a.Where(x => x.consume_Condition == info.consume_Condition).ToList();
                    var            list    = detail.OrderByDescending(x => x.consume_Time).Skip((current - 1) * count).Take(count).ToList();
                    int            zongshu = detail.Count();
                    int            zongye  = zongshu / count;
                    zongye = zongshu % count == 0 ? zongye : zongye + 1;
                    if (current < zongye)
                    {
                        ViewBag.currentc = current + 1;
                    }
                    else
                    {
                        ViewBag.currentc = zongye;
                    }
                    ViewBag.zongye  = zongye;
                    ViewBag.current = current;
                    return(View(list));
                }
                else
                {
                    List <consume> detail = a.Where(x => x.consume_cause.Contains(info.consume_cause) && x.consume_Condition == info.consume_Condition).ToList();
                    //List<action> detail = a.Where(x => x.actionhead.Contains(info.actionhead)).ToList();
                    var list = detail.OrderByDescending(x => x.consume_Time).Skip((current - 1) * count).Take(count).ToList();

                    int zongshu = detail.Count();
                    int zongye  = zongshu / count;
                    zongye = zongshu % count == 0 ? zongye : zongye + 1;
                    if (current < zongye)
                    {
                        ViewBag.currentc = current + 1;
                    }
                    else
                    {
                        ViewBag.currentc = zongye;
                    }
                    ViewBag.zongye  = zongye;
                    ViewBag.current = current;
                    return(View(list));
                }
            }
        }
Example #6
0
        /// <summary>
        /// 获取消费信息记录
        /// </summary>
        /// <returns></returns>
        public static List <consume> GetConsume(string StaffNo, string startConsumeMoney, string endConsumeMoney, string startConsumeDatetime, string endConsumeDatetime)
        {
            List <consume> consumeList = new List <consume>();
            StringBuilder  sql         = new StringBuilder("select consumetable.ID,consumetable.BookID,consumetable.StaffNo,staffs.StaffName,consumetable.ConsumeMoney,consumetable.ConsumeDatetime,consumetable.Remark,consumetable.CreateStaffNo ");

            sql.Append("from consumetable inner join staffs on consumetable.StaffNo = staffs.StaffNo ");
            sql.Append("where consumetable.State = 0 and staffs.State=0 ");
            List <MySqlParameter> parameter = new List <MySqlParameter>();

            if (!string.IsNullOrEmpty(StaffNo))
            {
                sql.Append(" and StaffNo = @staffno ");
                parameter.Add(new MySqlParameter
                {
                    ParameterName = "@staffno",
                    MySqlDbType   = MySqlDbType.VarChar,
                    Value         = string.Format("{0}", StaffNo.Trim())
                });
            }
            if (!string.IsNullOrEmpty(startConsumeMoney))
            {
                decimal dt = Convert.ToDecimal(startConsumeMoney);
                sql.Append(" and ConsumeMoney >= @startconsumemoney ");
                parameter.Add(new MySqlParameter
                {
                    ParameterName = "@startconsumemoney",
                    MySqlDbType   = MySqlDbType.Decimal,
                    Value         = dt
                });
            }
            if (!string.IsNullOrEmpty(endConsumeMoney))
            {
                decimal dt = Convert.ToDecimal(endConsumeMoney);
                sql.Append(" and ConsumeMoney <= @endconsumemoney ");
                parameter.Add(new MySqlParameter
                {
                    ParameterName = "@endconsume",
                    MySqlDbType   = MySqlDbType.Decimal,
                    Value         = dt
                });
            }
            if (!string.IsNullOrEmpty(startConsumeDatetime))
            {
                DateTime dt = Convert.ToDateTime(startConsumeDatetime);
                sql.Append(" and ConsumeDatetime >= @startconsumedatetime ");
                parameter.Add(new MySqlParameter
                {
                    ParameterName = "@startconsumedatetime",
                    MySqlDbType   = MySqlDbType.DateTime,
                    Value         = dt
                });
            }
            if (!string.IsNullOrEmpty(endConsumeDatetime))
            {
                DateTime dt = Convert.ToDateTime(endConsumeDatetime);
                sql.Append(" and ConsumeDatetime <= @endconsumedatetime ");
                parameter.Add(new MySqlParameter
                {
                    ParameterName = "@endrechargedatetime",
                    MySqlDbType   = MySqlDbType.DateTime,
                    Value         = dt
                });
            }
            MySqlDataReader dr = MySQLHelper.ExecuteReader(CommandType.Text, sql.ToString(), parameter.ToArray());


            while (dr.Read())
            {
                consume newconsume = new consume();

                newconsume.ID              = Convert.ToInt32(dr["ID"]);
                newconsume.BookID          = Convert.ToInt32(dr["BookID"]);
                newconsume.StaffNo         = Convert.ToString(dr["StaffNo"]);
                newconsume.StaffName       = Convert.ToString(dr["StaffName"]);
                newconsume.ConsumeMoney    = Convert.ToDecimal(dr["ConsumeMoney"]);
                newconsume.ConsumeDatetime = Convert.ToDateTime(dr["ConsumeDatetime"]);
                newconsume.Remark          = Convert.ToString(dr["Remark"]);
                newconsume.CreateStaffNo   = Convert.ToString(dr["CreateStaffNo"]);

                consumeList.Add(newconsume);
            }
            dr.Close();
            return(consumeList);
        }