コード例 #1
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="sql"></param>
 public bool Add(CarDispatchApply model)
 {
     try
     {
         var parameters = new List <QfParameter>();
         parameters.Add(new QfParameter("ApplyID", model.ApplyID));
         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)));
         parameters.Add(new QfParameter("ApplyMode", string.Format(@"'{0}'", model.ApplyMode)));
         parameters.Add(new QfParameter("IsDriver", model.IsDriver));
         parameters.Add(new QfParameter("CarModel", string.Format(@"'{0}'", model.CarModel)));
         parameters.Add(new QfParameter("DriverName", string.Format(@"'{0}'", model.DriverName)));
         parameters.Add(new QfParameter("DriverLicense", string.Format(@"'{0}'", model.DriverLicense)));
         parameters.Add(new QfParameter("DispatchID", model.DispatchID));
         parameters.Add(new QfParameter("EmployeeID", model.EmployeeID));
         parameters.Add(new QfParameter("ApplyDate", string.Format(@"'{0}'", model.ApplyDate)));
         parameters.Add(new QfParameter("CarID", model.CarID));
         parameters.Add(new QfParameter("DispatchReason", string.Format(@"'{0}'", model.DispatchReason)));
         parameters.Add(new QfParameter("PlaceBackDate", string.Format(@"'{0}'", model.PlaceBackDate)));
         parameters.Add(new QfParameter("CarBackDate", string.Format(@"'{0}'", model.CarBackDate)));
         parameters.Add(new QfParameter("Status", model.Status));
         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_apply({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 UpdateApplyDate(CarDispatchApply model)
 {
     try
     {
         string sql = string.Format("update t_car_dispatch set ApplyDate = '{0}' where DispatchID = {1}", model.ApplyDate, model.DispatchID);
         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 Delete(CarDispatchApply model)
 {
     try
     {
         string sql = string.Format("delete from t_car_dispatch_apply where ApplyID = {0}", model.ApplyID);
         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 CarDispatchApply GetModel(int ApplyID)
 {
     try
     {
         string           sql   = string.Format("select * from t_car_dispatch_apply where ApplyID = {0} limit 1", ApplyID);
         DataTable        dt    = MysqlHelper.ExecuteDataTable(sql);
         CarDispatchApply model = ModelConvert.ToModel <CarDispatchApply>(dt);
         return(model);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(null);
     }
 }
コード例 #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="sql"></param>
 public bool Update(CarDispatchApply model)
 {
     try
     {
         var parameters = new List <QfParameter>();
         parameters.Add(new QfParameter("ApplyID", model.ApplyID));
         parameters.Add(new QfParameter("DispatchID", model.DispatchID));
         parameters.Add(new QfParameter("EmployeeID", model.EmployeeID));
         parameters.Add(new QfParameter("ApplyDate", string.Format(@"'{0}'", model.ApplyDate)));
         parameters.Add(new QfParameter("CarID", model.CarID));
         parameters.Add(new QfParameter("DispatchReason", string.Format(@"'{0}'", model.DispatchReason)));
         parameters.Add(new QfParameter("PlaceBackDate", string.Format(@"'{0}'", model.PlaceBackDate)));
         parameters.Add(new QfParameter("CarBackDate", string.Format(@"'{0}'", model.CarBackDate)));
         parameters.Add(new QfParameter("Status", model.Status));
         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_apply set {0} where ApplyID = {1}", setStr, model.ApplyID);
         int    row = MysqlHelper.ExecuteNonQuery(sql);
         return(row == 1);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(false);
     }
 }