コード例 #1
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="sql"></param>
 public bool Add(CarDispatchAudit model)
 {
     try
     {
         var parameters = new List <QfParameter>();
         parameters.Add(new QfParameter("AuditID", model.AuditID));
         parameters.Add(new QfParameter("DispatchID", model.DispatchID));
         parameters.Add(new QfParameter("CarID", model.CarID));
         parameters.Add(new QfParameter("AuditDate", string.Format(@"'{0}'", model.AuditDate)));
         parameters.Add(new QfParameter("EmployeeID", model.EmployeeID));
         parameters.Add(new QfParameter("Result", string.Format(@"'{0}'", model.Result)));
         parameters.Add(new QfParameter("Note", string.Format(@"'{0}'", model.Note)));
         parameters.Add(new QfParameter("OperatorID", model.OperatorID));
         parameters.Add(new QfParameter("OperateTime", string.Format(@"'{0}'", model.OperateTime)));
         string colStr   = string.Join(",", parameters.FindAll(m => ValueConvert.ToString(m.Value) != null && ValueConvert.ToString(m.Value) != "''").Select(n => n.ParameterName));
         string atColStr = string.Join(",", parameters.FindAll(m => ValueConvert.ToString(m.Value) != null && ValueConvert.ToString(m.Value) != "''").Select(n => n.Value));
         string sql      = string.Format("insert into t_car_dispatch_audit({0}) values ({1})", colStr, atColStr);
         int    row      = MysqlHelper.ExecuteNonQuery(sql);
         return(row == 1);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(false);
     }
 }
コード例 #2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="sql"></param>
 public bool Update(CarDispatchAudit model)
 {
     try
     {
         var parameters = new List <QfParameter>();
         parameters.Add(new QfParameter("AuditID", model.AuditID));
         parameters.Add(new QfParameter("DispatchID", model.DispatchID));
         parameters.Add(new QfParameter("CarID", model.CarID));
         parameters.Add(new QfParameter("AuditDate", string.Format(@"'{0}'", model.AuditDate)));
         parameters.Add(new QfParameter("EmployeeID", model.EmployeeID));
         parameters.Add(new QfParameter("Result", string.Format(@"'{0}'", model.Result)));
         parameters.Add(new QfParameter("Note", string.Format(@"'{0}'", model.Note)));
         parameters.Add(new QfParameter("OperatorID", model.OperatorID));
         parameters.Add(new QfParameter("OperateTime", string.Format(@"'{0}'", model.OperateTime)));
         string setStr = "";
         foreach (var item in parameters)
         {
             if (item.Value != null && ValueConvert.ToString(item.Value) != "''")
             {
                 setStr += string.Format(" {0} = {1},", item.ParameterName, item.Value);
             }
         }
         setStr = setStr.Substring(0, setStr.LastIndexOf(","));
         string sql = string.Format("update t_car_dispatch_audit set {0} where AuditID = {1}", setStr, model.AuditID);
         int    row = MysqlHelper.ExecuteNonQuery(sql);
         return(row == 1);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(false);
     }
 }
コード例 #3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="sql"></param>
 public bool UpdateAuditDate(CarDispatchAudit model)
 {
     try
     {
         string sql = string.Format("update t_car_dispatch set AuditDate = '{0}', Note = '{1}' where DispatchID = {2}", model.AuditDate, model.Note, model.DispatchID);
         int    row = MysqlHelper.ExecuteNonQuery(sql);
         return(row == 1);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(false);
     }
 }
コード例 #4
0
 /// <summary>
 /// 删除一条数据
 /// </summary>
 /// <param name="sql"></param>
 public bool Delete(CarDispatchAudit model)
 {
     try
     {
         string sql = string.Format("delete from t_car_dispatch_audit where AuditID = {0}", model.AuditID);
         int    row = MysqlHelper.ExecuteNonQuery(sql);
         return(row == 1);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(false);
     }
 }
コード例 #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 /// <param name="sql"></param>
 public CarDispatchAudit GetModel(int AuditID)
 {
     try
     {
         string           sql   = string.Format("select * from t_car_dispatch_audit where AuditID = {0} limit 1", AuditID);
         DataTable        dt    = MysqlHelper.ExecuteDataTable(sql);
         CarDispatchAudit model = ModelConvert.ToModel <CarDispatchAudit>(dt);
         return(model);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(null);
     }
 }