/// <summary> /// 更新 /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool update(OutCar entity) { string sqlstr = String.Format(@"update t_c_outinfo set carid='{0}',updatedate='{1}',updateuser='******',destn='{3}',remark='{4}',outstart='{5}',outend='{6}',driver='{7}' where id='{8}'", entity.CarNO, entity.UpdateDate, entity.UpdateUser, entity.Destn, entity.Remark, entity.OutStart, entity.OutEnd, entity.Driver, entity.ID); MyDataOp db = new MyDataOp(sqlstr); return(db.ExecuteCommand()); }
/// <summary> /// 新增、修改时的重复性检查 /// </summary> /// <param name="entity"></param> /// <param name="flag"></param> /// <returns></returns> public bool IsExist(OutCar entity, string flag) { bool Existflag = false; string constr = ""; if (flag == "1")//0-新增;1-修改 { constr = " and id!='" + entity.ID + "'"; } string sqlstr = String.Format(@"select * from t_c_outinfo where carid='{0}' and (outstart between '{1}' and '{2}' or outend between '{3}' and '{4}')" + constr, entity.CarNO, entity.OutStart, entity.OutEnd, entity.OutStart, entity.OutEnd); DataSet ds = new MyDataOp(sqlstr).CreateDataSet(); if (ds.Tables[0].Rows.Count > 0) { Existflag = true; } return(Existflag); }
/// <summary> /// 添加 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int add(OutCar entity) { int id = 0; string sqlstr = String.Format(@"insert into t_c_outinfo(carid,destn,remark,createdate,createuser,outstart,outend,driver) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", entity.CarNO, entity.Destn, entity.Remark, entity.CreateDate, entity.CreateUser, entity.OutStart, entity.OutEnd, entity.Driver); MyDataOp db = new MyDataOp(sqlstr); if (db.ExecuteCommand()) { db = null; string selectstr = String.Format(@"select * from t_c_outinfo where carid='{0}' and outstart='{1}' and outend='{2}'", entity.CarNO, entity.OutStart, entity.OutEnd); SqlDataReader sdr = new MyDataOp(selectstr).CreateReader(); while (sdr.Read()) { id = int.Parse(sdr["id"].ToString()); } } return(id); }
public bool IsExist(OutCar entity, Person person, string flag) { bool Existflag = false; string constr = ""; if (flag == "1")//0-新增;1-修改 { constr = " and id!='" + person.ID + "'"; } string sqlstr = String.Format(@"select * from t_c_outinfo inner join t_c_outdetail on t_c_outinfo.id=t_c_outdetail.outid where name='{0}' and (outstart between '{1}' and '{2}' or outend between '{3}' and '{4}')" + constr, person.Name, entity.OutStart, entity.OutEnd, entity.OutStart, entity.OutEnd); DataSet ds = new MyDataOp(sqlstr).CreateDataSet(); if (ds.Tables[0].Rows.Count > 0) { Existflag = true; } return(Existflag); }