Exemplo n.º 1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <RestaurantMIS.Model.Wine> DataTableToList(DataTable dt)
        {
            List <RestaurantMIS.Model.Wine> modelList = new List <RestaurantMIS.Model.Wine>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                RestaurantMIS.Model.Wine model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new RestaurantMIS.Model.Wine();
                    if (dt.Rows[n]["ID"].ToString() != "")
                    {
                        model.ID = int.Parse(dt.Rows[n]["ID"].ToString());
                    }
                    model.Name = dt.Rows[n]["Name"].ToString();
                    model.Type = dt.Rows[n]["Type"].ToString();
                    model.Unit = dt.Rows[n]["Unit"].ToString();
                    if (dt.Rows[n]["YesterdayStorkNum"].ToString() != "")
                    {
                        model.YesterdayStorkNum = int.Parse(dt.Rows[n]["YesterdayStorkNum"].ToString());
                    }
                    if (dt.Rows[n]["TodayInNum"].ToString() != "")
                    {
                        model.TodayInNum = int.Parse(dt.Rows[n]["TodayInNum"].ToString());
                    }
                    if (dt.Rows[n]["TodayOutNum"].ToString() != "")
                    {
                        model.TodayOutNum = int.Parse(dt.Rows[n]["TodayOutNum"].ToString());
                    }
                    if (dt.Rows[n]["TodayStorkNum"].ToString() != "")
                    {
                        model.TodayStorkNum = int.Parse(dt.Rows[n]["TodayStorkNum"].ToString());
                    }
                    if (dt.Rows[n]["Price"].ToString() != "")
                    {
                        model.Price = decimal.Parse(dt.Rows[n]["Price"].ToString());
                    }
                    if (dt.Rows[n]["IncomeSum"].ToString() != "")
                    {
                        model.IncomeSum = decimal.Parse(dt.Rows[n]["IncomeSum"].ToString());
                    }
                    if (dt.Rows[n]["LogDate"].ToString() != "")
                    {
                        model.LogDate = DateTime.Parse(dt.Rows[n]["LogDate"].ToString());
                    }
                    model.Memo = dt.Rows[n]["Memo"].ToString();
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(RestaurantMIS.Model.Wine model)
 {
     dal.Update(model);
 }
Exemplo n.º 3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Add(RestaurantMIS.Model.Wine model)
 {
     dal.Add(model);
 }