Beispiel #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LPWeb.Model.ContactMailCampaign GetModel(int ContactMailCampaignId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ContactMailCampaignId,ContactId,CID,LID,BranchId,Added,AddedBy,Result from ContactMailCampaign ");
            strSql.Append(" where ContactMailCampaignId=@ContactMailCampaignId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ContactMailCampaignId", SqlDbType.Int, 4)
            };
            parameters[0].Value = ContactMailCampaignId;

            LPWeb.Model.ContactMailCampaign model = new LPWeb.Model.ContactMailCampaign();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ContactMailCampaignId"] != null && ds.Tables[0].Rows[0]["ContactMailCampaignId"].ToString() != "")
                {
                    model.ContactMailCampaignId = int.Parse(ds.Tables[0].Rows[0]["ContactMailCampaignId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ContactId"] != null && ds.Tables[0].Rows[0]["ContactId"].ToString() != "")
                {
                    model.ContactId = int.Parse(ds.Tables[0].Rows[0]["ContactId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CID"] != null && ds.Tables[0].Rows[0]["CID"].ToString() != "")
                {
                    model.CID = ds.Tables[0].Rows[0]["CID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["LID"] != null && ds.Tables[0].Rows[0]["LID"].ToString() != "")
                {
                    model.LID = ds.Tables[0].Rows[0]["LID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["BranchId"] != null && ds.Tables[0].Rows[0]["BranchId"].ToString() != "")
                {
                    model.BranchId = int.Parse(ds.Tables[0].Rows[0]["BranchId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Added"] != null && ds.Tables[0].Rows[0]["Added"].ToString() != "")
                {
                    model.Added = DateTime.Parse(ds.Tables[0].Rows[0]["Added"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AddedBy"] != null && ds.Tables[0].Rows[0]["AddedBy"].ToString() != "")
                {
                    model.AddedBy = int.Parse(ds.Tables[0].Rows[0]["AddedBy"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Result"] != null && ds.Tables[0].Rows[0]["Result"].ToString() != "")
                {
                    model.Result = ds.Tables[0].Rows[0]["Result"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(LPWeb.Model.ContactMailCampaign model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ContactMailCampaign set ");
            strSql.Append("ContactId=@ContactId,");
            strSql.Append("CID=@CID,");
            strSql.Append("LID=@LID,");
            strSql.Append("BranchId=@BranchId,");
            strSql.Append("Added=@Added,");
            strSql.Append("AddedBy=@AddedBy,");
            strSql.Append("Result=@Result");
            strSql.Append(" where ContactMailCampaignId=@ContactMailCampaignId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ContactId",             SqlDbType.Int,         4),
                new SqlParameter("@CID",                   SqlDbType.NVarChar,  255),
                new SqlParameter("@LID",                   SqlDbType.NVarChar,  255),
                new SqlParameter("@BranchId",              SqlDbType.Int,         4),
                new SqlParameter("@Added",                 SqlDbType.DateTime),
                new SqlParameter("@AddedBy",               SqlDbType.Int,         4),
                new SqlParameter("@Result",                SqlDbType.NVarChar,   50),
                new SqlParameter("@ContactMailCampaignId", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.ContactId;
            parameters[1].Value = model.CID;
            parameters[2].Value = model.LID;
            parameters[3].Value = model.BranchId;
            parameters[4].Value = model.Added;
            parameters[5].Value = model.AddedBy;
            parameters[6].Value = model.Result;
            parameters[7].Value = model.ContactMailCampaignId;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(LPWeb.Model.ContactMailCampaign model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ContactMailCampaign(");
            strSql.Append("ContactId,CID,LID,BranchId,Added,AddedBy,Result)");
            strSql.Append(" values (");
            strSql.Append("@ContactId,@CID,@LID,@BranchId,@Added,@AddedBy,@Result)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ContactId", SqlDbType.Int,         4),
                new SqlParameter("@CID",       SqlDbType.NVarChar,  255),
                new SqlParameter("@LID",       SqlDbType.NVarChar,  255),
                new SqlParameter("@BranchId",  SqlDbType.Int,         4),
                new SqlParameter("@Added",     SqlDbType.DateTime),
                new SqlParameter("@AddedBy",   SqlDbType.Int,         4),
                new SqlParameter("@Result",    SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.ContactId;
            parameters[1].Value = model.CID;
            parameters[2].Value = model.LID;
            parameters[3].Value = model.BranchId;
            parameters[4].Value = model.Added;
            parameters[5].Value = model.AddedBy;
            parameters[6].Value = model.Result;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }