Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(Maticsoft.Model.ProductSeries model)
        {
            DataTable dt = dal.GetList("").Tables[0];

            for (int i = 1; true; i++)
            {
                string Code = i < 10 ? "0" + i.ToString() : i.ToString();
                if (dt.Select("Code='" + Code + "'").Length == 0)
                {
                    model.Code = Code;
                    break;
                }
            }
            return(dal.Add(model));
        }
Esempio n. 2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Maticsoft.Model.ProductSeries model)
 {
     return(dal.Update(model));
 }
Esempio n. 3
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Maticsoft.Model.ProductSeries> DataTableToList(DataTable dt)
        {
            List <Maticsoft.Model.ProductSeries> modelList = new List <Maticsoft.Model.ProductSeries>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Maticsoft.Model.ProductSeries model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Maticsoft.Model.ProductSeries();
                    if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "")
                    {
                        model.ID = long.Parse(dt.Rows[n]["ID"].ToString());
                    }
                    if (dt.Rows[n]["Code"] != null && dt.Rows[n]["Code"].ToString() != "")
                    {
                        model.Code = dt.Rows[n]["Code"].ToString();
                    }
                    if (dt.Rows[n]["Name"] != null && dt.Rows[n]["Name"].ToString() != "")
                    {
                        model.Name = dt.Rows[n]["Name"].ToString();
                    }
                    if (dt.Rows[n]["Enabled"] != null && dt.Rows[n]["Enabled"].ToString() != "")
                    {
                        if ((dt.Rows[n]["Enabled"].ToString() == "1") || (dt.Rows[n]["Enabled"].ToString().ToLower() == "true"))
                        {
                            model.Enabled = true;
                        }
                        else
                        {
                            model.Enabled = false;
                        }
                    }
                    if (dt.Rows[n]["Status"] != null && dt.Rows[n]["Status"].ToString() != "")
                    {
                        model.Status = int.Parse(dt.Rows[n]["Status"].ToString());
                    }
                    if (dt.Rows[n]["Remark"] != null && dt.Rows[n]["Remark"].ToString() != "")
                    {
                        model.Remark = dt.Rows[n]["Remark"].ToString();
                    }
                    if (dt.Rows[n]["Value0"] != null && dt.Rows[n]["Value0"].ToString() != "")
                    {
                        model.Value0 = dt.Rows[n]["Value0"].ToString();
                    }
                    if (dt.Rows[n]["Value1"] != null && dt.Rows[n]["Value1"].ToString() != "")
                    {
                        model.Value1 = dt.Rows[n]["Value1"].ToString();
                    }
                    if (dt.Rows[n]["Value2"] != null && dt.Rows[n]["Value2"].ToString() != "")
                    {
                        model.Value2 = dt.Rows[n]["Value2"].ToString();
                    }
                    if (dt.Rows[n]["Value3"] != null && dt.Rows[n]["Value3"].ToString() != "")
                    {
                        model.Value3 = dt.Rows[n]["Value3"].ToString();
                    }
                    if (dt.Rows[n]["Value4"] != null && dt.Rows[n]["Value4"].ToString() != "")
                    {
                        model.Value4 = dt.Rows[n]["Value4"].ToString();
                    }
                    if (dt.Rows[n]["Value5"] != null && dt.Rows[n]["Value5"].ToString() != "")
                    {
                        model.Value5 = dt.Rows[n]["Value5"].ToString();
                    }
                    if (dt.Rows[n]["Value6"] != null && dt.Rows[n]["Value6"].ToString() != "")
                    {
                        model.Value6 = dt.Rows[n]["Value6"].ToString();
                    }
                    if (dt.Rows[n]["Value7"] != null && dt.Rows[n]["Value7"].ToString() != "")
                    {
                        model.Value7 = dt.Rows[n]["Value7"].ToString();
                    }
                    if (dt.Rows[n]["Value8"] != null && dt.Rows[n]["Value8"].ToString() != "")
                    {
                        model.Value8 = dt.Rows[n]["Value8"].ToString();
                    }
                    if (dt.Rows[n]["Value9"] != null && dt.Rows[n]["Value9"].ToString() != "")
                    {
                        model.Value9 = dt.Rows[n]["Value9"].ToString();
                    }
                    if (dt.Rows[n]["CreateUser"] != null && dt.Rows[n]["CreateUser"].ToString() != "")
                    {
                        model.CreateUser = dt.Rows[n]["CreateUser"].ToString();
                    }
                    if (dt.Rows[n]["CreateDate"] != null && dt.Rows[n]["CreateDate"].ToString() != "")
                    {
                        model.CreateDate = DateTime.Parse(dt.Rows[n]["CreateDate"].ToString());
                    }
                    if (dt.Rows[n]["UpdateUser"] != null && dt.Rows[n]["UpdateUser"].ToString() != "")
                    {
                        model.UpdateUser = dt.Rows[n]["UpdateUser"].ToString();
                    }
                    if (dt.Rows[n]["UpdateDate"] != null && dt.Rows[n]["UpdateDate"].ToString() != "")
                    {
                        model.UpdateDate = DateTime.Parse(dt.Rows[n]["UpdateDate"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }