/// <summary> /// 得到一个对象实体 /// </summary> public BWJS.Model.NL_Task GetModel(int AutoId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select AutoId, IsDeleted, CreateId, CreateDate, EditId, EditDate, ConsultId, TelNo, ServicePwd, TaskId, State, TaskStatus, ImgStr, Mark "); strSql.Append(" from dbo.[NL_Task] "); strSql.Append(" where AutoId=@AutoId"); SqlParameter[] parameters = { new SqlParameter("@AutoId", SqlDbType.Int, 4) }; parameters[0].Value = AutoId; BWJS.Model.NL_Task model = new BWJS.Model.NL_Task(); DataSet ds = BWJSHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// datarow转成对象实体 /// </summary> public BWJS.Model.NL_Task DataRowToModel(DataRow row) { BWJS.Model.NL_Task model = new BWJS.Model.NL_Task(); if (row != null) { if (row["AutoId"].ToString() != "") { model.AutoId = int.Parse(row["AutoId"].ToString()); } if (row["IsDeleted"].ToString() != "") { model.IsDeleted = int.Parse(row["IsDeleted"].ToString()); } if (row["CreateId"].ToString() != "") { model.CreateId = int.Parse(row["CreateId"].ToString()); } if (row["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(row["CreateDate"].ToString()); } if (row["EditId"].ToString() != "") { model.EditId = int.Parse(row["EditId"].ToString()); } if (row["EditDate"].ToString() != "") { model.EditDate = DateTime.Parse(row["EditDate"].ToString()); } if (row["ConsultId"].ToString() != "") { model.ConsultId = int.Parse(row["ConsultId"].ToString()); } model.TelNo = row["TelNo"].ToString(); model.ServicePwd = row["ServicePwd"].ToString(); model.TaskId = row["TaskId"].ToString(); model.State = row["State"].ToString(); model.TaskStatus = row["TaskStatus"].ToString(); model.ImgStr = row["ImgStr"].ToString(); if (row["Mark"].ToString() != "") { if ((row["Mark"].ToString() == "1") || (row["Mark"].ToString().ToLower() == "true")) { model.Mark = true; } else { model.Mark = false; } } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BWJS.Model.NL_Task model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update dbo.[NL_Task] set "); strSql.Append(" IsDeleted = @IsDeleted , "); strSql.Append(" CreateId = @CreateId , "); strSql.Append(" CreateDate = @CreateDate , "); strSql.Append(" EditId = @EditId , "); strSql.Append(" EditDate = @EditDate , "); strSql.Append(" ConsultId = @ConsultId , "); strSql.Append(" TelNo = @TelNo , "); strSql.Append(" ServicePwd = @ServicePwd , "); strSql.Append(" TaskId = @TaskId , "); strSql.Append(" State = @State , "); strSql.Append(" TaskStatus = @TaskStatus , "); strSql.Append(" ImgStr = @ImgStr , "); strSql.Append(" Mark = @Mark "); strSql.Append(" where AutoId=@AutoId "); SqlParameter[] parameters = { new SqlParameter("@AutoId", model.AutoId), new SqlParameter("@IsDeleted", model.IsDeleted), new SqlParameter("@CreateId", model.CreateId), new SqlParameter("@CreateDate", model.CreateDate), new SqlParameter("@EditId", model.EditId), new SqlParameter("@EditDate", model.EditDate), new SqlParameter("@ConsultId", model.ConsultId), new SqlParameter("@TelNo", model.TelNo), new SqlParameter("@ServicePwd", model.ServicePwd), new SqlParameter("@TaskId", model.TaskId), new SqlParameter("@State", model.State), new SqlParameter("@TaskStatus", model.TaskStatus), new SqlParameter("@ImgStr", model.ImgStr), new SqlParameter("@Mark", model.Mark) }; int rows = BWJSHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(BWJS.Model.NL_Task model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into dbo.[NL_Task]("); strSql.Append("IsDeleted,CreateId,CreateDate,EditId,EditDate,ConsultId,TelNo,ServicePwd,TaskId,State,TaskStatus,ImgStr,Mark"); strSql.Append(") values ("); strSql.Append("@IsDeleted,@CreateId,@CreateDate,@EditId,@EditDate,@ConsultId,@TelNo,@ServicePwd,@TaskId,@State,@TaskStatus,@ImgStr,@Mark"); strSql.Append(") "); strSql.Append(";select SCOPE_IDENTITY()"); SqlParameter[] parameters = { new SqlParameter("@IsDeleted", model.IsDeleted), new SqlParameter("@CreateId", model.CreateId), new SqlParameter("@CreateDate", model.CreateDate), new SqlParameter("@EditId", model.EditId), new SqlParameter("@EditDate", model.EditDate), new SqlParameter("@ConsultId", model.ConsultId), new SqlParameter("@TelNo", model.TelNo), new SqlParameter("@ServicePwd", model.ServicePwd), new SqlParameter("@TaskId", model.TaskId), new SqlParameter("@State", model.State), new SqlParameter("@TaskStatus", model.TaskStatus), new SqlParameter("@ImgStr", model.ImgStr), new SqlParameter("@Mark", model.Mark) }; object obj = BWJSHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BWJS.Model.NL_Task model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(BWJS.Model.NL_Task model) { return(dal.Add(model)); }