/// <summary> /// 更新一条数据 /// </summary> public void Update(XBase.Model.Personal.MessageBox.MyContact model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update officedba.MyContact set "); strSql.Append("GroupID=@GroupID,"); strSql.Append("CompanyCD=@CompanyCD,"); strSql.Append("ContactID=@ContactID,"); strSql.Append("Creator=@Creator,"); strSql.Append("CreateDate=@CreateDate,"); strSql.Append("ModifiedDate=@ModifiedDate,"); strSql.Append("ModifiedUserID=@ModifiedUserID"); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4), new SqlParameter("@GroupID", SqlDbType.Int, 4), new SqlParameter("@CompanyCD", SqlDbType.VarChar, 8), new SqlParameter("@ContactID", SqlDbType.Int, 4), new SqlParameter("@Creator", SqlDbType.Int, 4), new SqlParameter("@CreateDate", SqlDbType.DateTime), new SqlParameter("@ModifiedDate", SqlDbType.DateTime), new SqlParameter("@ModifiedUserID", SqlDbType.VarChar, 50) }; parameters[0].Value = model.ID; parameters[1].Value = model.GroupID; parameters[2].Value = model.CompanyCD; parameters[3].Value = model.ContactID; parameters[4].Value = model.Creator; parameters[5].Value = model.CreateDate; parameters[6].Value = model.ModifiedDate; parameters[7].Value = model.ModifiedUserID; SqlHelper.ExecuteTransSql(strSql.ToString(), parameters); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(XBase.Model.Personal.MessageBox.MyContact model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into officedba.MyContact("); strSql.Append("GroupID,CompanyCD,ContactID,Creator,CreateDate,ModifiedDate,ModifiedUserID)"); strSql.Append(" values ("); strSql.Append("@GroupID,@CompanyCD,@ContactID,@Creator,@CreateDate,@ModifiedDate,@ModifiedUserID)"); strSql.Append(";select @ID=@@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@GroupID", SqlDbType.Int, 4), new SqlParameter("@CompanyCD", SqlDbType.VarChar, 8), new SqlParameter("@ContactID", SqlDbType.Int, 4), new SqlParameter("@Creator", SqlDbType.Int, 4), new SqlParameter("@CreateDate", SqlDbType.DateTime), new SqlParameter("@ModifiedDate", SqlDbType.DateTime), new SqlParameter("@ModifiedUserID", SqlDbType.VarChar, 50), new SqlParameter("@ID", SqlDbType.Int, 0) }; parameters[0].Value = model.GroupID; parameters[1].Value = model.CompanyCD; parameters[2].Value = model.ContactID; parameters[3].Value = model.Creator; parameters[4].Value = model.CreateDate; parameters[5].Value = model.ModifiedDate; parameters[6].Value = model.ModifiedUserID; parameters[7].Direction = ParameterDirection.Output; SqlHelper.ExecuteTransSql(strSql.ToString(), parameters); return(int.Parse(parameters[7].Value.ToString())); }
/// <summary> /// 得到一个对象实体 /// </summary> public XBase.Model.Personal.MessageBox.MyContact GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,GroupID,CompanyCD,ContactID,Creator,CreateDate,ModifiedDate,ModifiedUserID from MyContact "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; XBase.Model.Personal.MessageBox.MyContact model = new XBase.Model.Personal.MessageBox.MyContact(); DataTable dt = SqlHelper.ExecuteSql(strSql.ToString(), parameters); DataSet ds = new DataSet(); ds.Tables.Add(dt); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ID"].ToString() != "") { model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if (ds.Tables[0].Rows[0]["GroupID"].ToString() != "") { model.GroupID = int.Parse(ds.Tables[0].Rows[0]["GroupID"].ToString()); } model.CompanyCD = ds.Tables[0].Rows[0]["CompanyCD"].ToString(); if (ds.Tables[0].Rows[0]["ContactID"].ToString() != "") { model.ContactID = int.Parse(ds.Tables[0].Rows[0]["ContactID"].ToString()); } if (ds.Tables[0].Rows[0]["Creator"].ToString() != "") { model.Creator = int.Parse(ds.Tables[0].Rows[0]["Creator"].ToString()); } if (ds.Tables[0].Rows[0]["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString()); } if (ds.Tables[0].Rows[0]["ModifiedDate"].ToString() != "") { model.ModifiedDate = DateTime.Parse(ds.Tables[0].Rows[0]["ModifiedDate"].ToString()); } model.ModifiedUserID = ds.Tables[0].Rows[0]["ModifiedUserID"].ToString(); return(model); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public XBase.Model.Personal.MessageBox.MyContact GetModel(int ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 ID,GroupID,CompanyCD,ContactID,Creator,CreateDate,ModifiedDate,ModifiedUserID from MyContact "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int,4)}; parameters[0].Value = ID; XBase.Model.Personal.MessageBox.MyContact model=new XBase.Model.Personal.MessageBox.MyContact(); DataTable dt = SqlHelper.ExecuteSql(strSql.ToString(), parameters); DataSet ds = new DataSet(); ds.Tables.Add(dt); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["ID"].ToString()!="") { model.ID=int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if(ds.Tables[0].Rows[0]["GroupID"].ToString()!="") { model.GroupID=int.Parse(ds.Tables[0].Rows[0]["GroupID"].ToString()); } model.CompanyCD=ds.Tables[0].Rows[0]["CompanyCD"].ToString(); if(ds.Tables[0].Rows[0]["ContactID"].ToString()!="") { model.ContactID=int.Parse(ds.Tables[0].Rows[0]["ContactID"].ToString()); } if(ds.Tables[0].Rows[0]["Creator"].ToString()!="") { model.Creator=int.Parse(ds.Tables[0].Rows[0]["Creator"].ToString()); } if(ds.Tables[0].Rows[0]["CreateDate"].ToString()!="") { model.CreateDate=DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString()); } if(ds.Tables[0].Rows[0]["ModifiedDate"].ToString()!="") { model.ModifiedDate=DateTime.Parse(ds.Tables[0].Rows[0]["ModifiedDate"].ToString()); } model.ModifiedUserID=ds.Tables[0].Rows[0]["ModifiedUserID"].ToString(); return model; } else { return null; } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(XBase.Model.Personal.MessageBox.MyContact model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(XBase.Model.Personal.MessageBox.MyContact model) { return(dal.Add(model)); }