/// <summary>
        /// 增加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <Result <MaterialInfo> > addAsync(MaterialInfo model)
        {
            Result <MaterialInfo> result    = new Result <MaterialInfo>();
            MaterialInfoQuery     condition = new MaterialInfoQuery()
            {
                materialName = model.materialName, mat_size = model.mat_size
            };
            var isExist = dao.searchCountByCondition(condition);

            if (isExist > 0)
            {
                result.addError("产品已存在");
            }
            else
            {
                model.findIndx = BeanHelper.getFistCharUpper(model.materialName);
                var resultDAO = await dao.add(model);

                if (!resultDAO.success)
                {
                    result.addError(resultDAO.message);
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        public T Clone()
        {
            T item = new T();

            BeanHelper.ObjectClone(this, item);
            return(item);
        }
Exemplo n.º 3
0
        public virtual T[] Select(params MyField[] paramfields)
        {
            string fields = "";

            Type t = this.GetType();

            PropertyInfo[] props = t.GetProperties();

            foreach (PropertyInfo p in props)
            {
                string fName = p.Name.ToUpper();
                fields += fName + ",";
            }
            fields = fields.Substring(0, fields.Length - 1);

            DataTable table = TableManager.Select(this.GetTableName(), fields, paramfields);
            List <T>  list  = new List <T>();

            foreach (DataRow row in table.Rows)
            {
                T item = new T();
                BeanHelper.DataRowToModel(row, item);
                list.Add(item);
            }
            return(list.ToArray());
        }
Exemplo n.º 4
0
        public MyField Clone()
        {
            MyField ret = new MyField();

            BeanHelper.ObjectClone(this, ret);

            return(ret);
        }
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public async Task <Result <int> > update(MaterialInfo model)
 {
     model.findIndx = BeanHelper.getFistCharUpper(model.materialName);
     return(await dao.update(model));
 }