Esempio n. 1
0
        public List <Supplier> GetSupplier(string fieldName, string fieldValue)
        {
            List <Supplier> results = new List <Supplier>();
            DataTable       dt      = new DataTable();

            if (string.IsNullOrEmpty(fieldName) && string.IsNullOrEmpty(fieldValue))
            {
                dt = SqlHepler.GetDataTable(new Supplier().TableName);
            }
            else if (fieldName == "Name")
            {
                dt = SqlHepler.GetDataTable1(new Supplier(), fieldName, fieldValue);
            }
            else
            {
                dt = SqlHepler.GetDataTable(new Supplier(), fieldName, fieldValue);
            }
            foreach (DataRow dr in dt.Rows)
            {
                results.Add(
                    new Supplier(
                        dr[0].ToString(),
                        dr[1].ToString(),
                        dr[2].ToString(),
                        dr[3].ToString(),
                        dr[4].ToString(),
                        dr[5].ToString(),
                        dr[6].ToString()
                        ));
            }
            return(results);
        }
Esempio n. 2
0
 public void Add(ModelBase model)
 {
     if (model is Inventory)
     {
         if (((Inventory)model).ID == 0)
         {
             SqlHepler.Execute(SqlHepler.InsertSQL(model));
             if (this.ModelAdded != null)
             {
                 this.ModelAdded(this, new ModelAddedEventArgs(model));
             }
         }
         else
         {
             SqlHepler.Execute(SqlHepler.UpdateSQL(model));
         }
     }
     else if (model is Sale)
     {
         if (((Sale)model).ID == 0)
         {
             SqlHepler.Execute(SqlHepler.InsertSQL(model));
             if (this.ModelAdded != null)
             {
                 this.ModelAdded(this, new ModelAddedEventArgs(model));
             }
         }
         else
         {
             SqlHepler.Execute(SqlHepler.UpdateSQL(model));
             //更新商品库存
         }
     }
     else
     {
         if (AlreadyExisting(model))
         {
             SqlHepler.Execute(SqlHepler.UpdateSQL(model));
         }
         else
         {
             SqlHepler.Execute(SqlHepler.InsertSQL(model));
             if (model is Employee)
             {
                 User user = new User();
                 user.EmployeeID = ((Employee)model).ID;
                 user.Password   = "******";
                 user.IsAdmin    = "0";
                 SqlHepler.Execute(SqlHepler.InsertSQL(user));
             }
             if (this.ModelAdded != null)
             {
                 this.ModelAdded(this, new ModelAddedEventArgs(model));
             }
         }
     }
 }