Example #1
0
        // 传入DataRow,将其转换为ModelSupplier
        private ModelSupplier toModel(DataRow dr)
        {
            ModelSupplier model = new ModelSupplier();

            //通过循环为ModelSupplier赋值,其中为数据值为空时,DateTime类型的空值为:0001/1/1 0:00:00    int类型得空值为: 0,其余的还没试验
            foreach (PropertyInfo propertyInfo in typeof(ModelSupplier).GetProperties())
            {
                //如果数据库的字段为空,跳过其赋值
                if (dr[propertyInfo.Name].ToString() == "")
                {
                    continue;
                }
                //赋值
                model.GetType().GetProperty(propertyInfo.Name).SetValue(model, dr[propertyInfo.Name], null);
            }
            return(model);
        }
Example #2
0
 public void AddNew(ModelSupplier supplier)
 {
     db.Supplier.InsertOnSubmit(supplier);
     db.SubmitChanges();
 }
Example #3
0
        public ModelSupplier GetById(int id)
        {
            ModelSupplier supplier = db.Supplier.First(s => s.Id == id);

            return(supplier);
        }
Example #4
0
        public string GetById(int id)
        {
            ModelSupplier supplier = SupplierDAO.GetById(id);

            return(JsonHelpers.stringify(supplier));
        }
 public SupplierManage()
 {
     data = DataConexion.getInstance();
     model = new ModelSupplier();
 }