Exemple #1
0
 public int Save(IList<Model.DataBean> list)
 {
     int i = list.Count;
     int b = 0;
     StringBuilder sb = new StringBuilder();
     sb.Append("INSERT INTO SalesRecords ");
     DBHelper db = new DBHelper();
     foreach (var item in list)
     {
         b++;
         if (b != i)
         {
             sb.Append("select '" + item.guid + "','" + item.ZydBh + "','" + item.ShcBh + "','" + item.ShcDj +
                       "','" + item.XSSL + "','" + item.XSTime + "','" + item.JyJlID + "'  union ");
         }
         else
         {
             sb.Append("select '" + item.guid + "','" + item.ZydBh + "','" + item.ShcBh + "','" + item.ShcDj +
                       "','" + item.XSSL + "','" + item.XSTime + "','" + item.JyJlID + "'");
         }
     }
     DbCommand cmd = db.GetSqlStringCommand(sb.ToString());
     object result = db.ExecuteNonQuery(cmd);
     int m = result == null ? -1 : Convert.ToInt16(result);
     SaveRequestLog(m, "提交数据", list[0].ZydBh);
     return m;
 }
Exemple #2
0
 public bool SaveRequestLog(int i,string type,string zydbh)
 {
     DBHelper db=new DBHelper();
     Guid id = Guid.NewGuid();
     string sql = "";
     if (i > 0)
     {
        sql="insert into RequestLog select '"+id+"','"+zydbh+"','"+type+"','"+DateTime.Now+
         "','1'";
     }
     else
     {
          sql = "insert into RequestLog select '" + id + "','" + zydbh + "','" + type + "','" + DateTime.Now +
        "','0'";
     }
     DbCommand cmd = db.GetSqlStringCommand(sql);
     if (db.ExecuteNonQuery(cmd) > 0)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Exemple #3
0
 public IList<Model.PriceLog> GetList(string zydbn)
 {
     IList<PriceLog> list=new List<PriceLog>();
     string time = DateTime.Now.ToString("yyyy-MM-dd");
     string sql =
         "select ScBh,Price,PriceTime,ScName=(select ScName from Vegetables v where v.ScBh=p.ScBh) from PriceLog p where PriceTime='" +
         time+"'";
     DBHelper db=new DBHelper();
     DbCommand cmd = db.GetSqlStringCommand(sql);
     DataTable dt = db.ExecuteDataTable(cmd);
     foreach (DataRow VARIABLE in dt.Rows)
     {
         PriceLog pr=new PriceLog();
         pr.Price = Convert.ToDecimal(VARIABLE["Price"]);
         pr.PriceTime = Convert.ToDateTime(VARIABLE["PriceTime"]);
         pr.ScBh = Convert.ToString(VARIABLE["ScBh"]);
         pr.ScName = Convert.ToString(VARIABLE["ScName"]);
         list.Add(pr);
     }
     SaveRequestLog(list.Count, "获取价格", zydbn);
     return list;
 }