Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(XBase.Model.Personal.MessageBox.MyContactGroup model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update officedba.MyContactGroup set ");
            strSql.Append("CompanyCD=@CompanyCD,");
            strSql.Append("GroupName=@GroupName,");
            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("@CompanyCD",      SqlDbType.VarChar,    8),
                new SqlParameter("@GroupName",      SqlDbType.VarChar,   50),
                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.CompanyCD;
            parameters[2].Value = model.GroupName;
            parameters[3].Value = model.Creator;
            parameters[4].Value = model.CreateDate;
            parameters[5].Value = model.ModifiedDate;
            parameters[6].Value = model.ModifiedUserID;

            SqlHelper.ExecuteTransSql(strSql.ToString(), parameters);
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(XBase.Model.Personal.MessageBox.MyContactGroup model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into officedba.MyContactGroup(");
            strSql.Append("CompanyCD,GroupName,Creator,CreateDate,ModifiedDate,ModifiedUserID)");
            strSql.Append(" values (");
            strSql.Append("@CompanyCD,@GroupName,@Creator,@CreateDate,@ModifiedDate,@ModifiedUserID)");
            strSql.Append(";select @ID=@@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CompanyCD",      SqlDbType.VarChar,    8),
                new SqlParameter("@GroupName",      SqlDbType.VarChar,   50),
                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.CompanyCD;
            parameters[1].Value     = model.GroupName;
            parameters[2].Value     = model.Creator;
            parameters[3].Value     = model.CreateDate;
            parameters[4].Value     = model.ModifiedDate;
            parameters[5].Value     = model.ModifiedUserID;
            parameters[6].Direction = ParameterDirection.Output;

            SqlHelper.ExecuteTransSql(strSql.ToString(), parameters);
            return(int.Parse(parameters[6].Value.ToString()));
        }
Пример #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XBase.Model.Personal.MessageBox.MyContactGroup GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,CompanyCD,GroupName,Creator,CreateDate,ModifiedDate,ModifiedUserID from officedba.MyContactGroup");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            XBase.Model.Personal.MessageBox.MyContactGroup model = new XBase.Model.Personal.MessageBox.MyContactGroup();
            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());
                }
                model.CompanyCD = ds.Tables[0].Rows[0]["CompanyCD"].ToString();
                model.GroupName = ds.Tables[0].Rows[0]["GroupName"].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);
            }
        }
Пример #4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(XBase.Model.Personal.MessageBox.MyContactGroup model)
 {
     dal.Update(model);
 }
Пример #5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(XBase.Model.Personal.MessageBox.MyContactGroup model)
 {
     return(dal.Add(model));
 }
Пример #6
0
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public XBase.Model.Personal.MessageBox.MyContactGroup GetModel(int ID)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 ID,CompanyCD,GroupName,Creator,CreateDate,ModifiedDate,ModifiedUserID from officedba.MyContactGroup");
			strSql.Append(" where ID=@ID ");
			SqlParameter[] parameters = {
					new SqlParameter("@ID", SqlDbType.Int,4)};
			parameters[0].Value = ID;

			XBase.Model.Personal.MessageBox.MyContactGroup model=new XBase.Model.Personal.MessageBox.MyContactGroup();
            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());
				}
				model.CompanyCD=ds.Tables[0].Rows[0]["CompanyCD"].ToString();
				model.GroupName=ds.Tables[0].Rows[0]["GroupName"].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;
			}
		}