コード例 #1
0
ファイル: NL_ContactsDAL.cs プロジェクト: hofmannzhu/bwjs
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BWJS.Model.NL_Contacts GetModel(int ContactId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ContactId, EditId, EditDate, ConsultId, FullName, Mobile, RelationId, Depth, IsDeleted, CreateId, CreateDate  ");
            strSql.Append("  from dbo.[NL_Contacts] ");
            strSql.Append(" where ContactId=@ContactId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ContactId", SqlDbType.Int, 4)
            };
            parameters[0].Value = ContactId;


            BWJS.Model.NL_Contacts model = new BWJS.Model.NL_Contacts();
            DataSet ds = BWJSHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
ファイル: NL_ContactsDAL.cs プロジェクト: hofmannzhu/bwjs
        /// <summary>
        /// datarow转成对象实体
        /// </summary>
        public BWJS.Model.NL_Contacts DataRowToModel(DataRow row)
        {
            BWJS.Model.NL_Contacts model = new BWJS.Model.NL_Contacts();

            if (row != null)
            {
                if (row["ContactId"].ToString() != "")
                {
                    model.ContactId = int.Parse(row["ContactId"].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.FullName = row["FullName"].ToString();
                model.Mobile   = row["Mobile"].ToString();
                if (row["RelationId"].ToString() != "")
                {
                    model.RelationId = int.Parse(row["RelationId"].ToString());
                }
                if (row["Depth"].ToString() != "")
                {
                    model.Depth = int.Parse(row["Depth"].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());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
ファイル: NL_ContactsDAL.cs プロジェクト: hofmannzhu/bwjs
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(BWJS.Model.NL_Contacts model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update dbo.[NL_Contacts] set ");

            strSql.Append(" EditId = @EditId , ");
            strSql.Append(" EditDate = @EditDate , ");
            strSql.Append(" ConsultId = @ConsultId , ");
            strSql.Append(" FullName = @FullName , ");
            strSql.Append(" Mobile = @Mobile , ");
            strSql.Append(" RelationId = @RelationId , ");
            strSql.Append(" Depth = @Depth , ");
            strSql.Append(" IsDeleted = @IsDeleted , ");
            strSql.Append(" CreateId = @CreateId , ");
            strSql.Append(" CreateDate = @CreateDate  ");
            strSql.Append(" where ContactId=@ContactId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@ContactId",  model.ContactId),
                new SqlParameter("@EditId",     model.EditId),
                new SqlParameter("@EditDate",   model.EditDate),
                new SqlParameter("@ConsultId",  model.ConsultId),
                new SqlParameter("@FullName",   model.FullName),
                new SqlParameter("@Mobile",     model.Mobile),
                new SqlParameter("@RelationId", model.RelationId),
                new SqlParameter("@Depth",      model.Depth),
                new SqlParameter("@IsDeleted",  model.IsDeleted),
                new SqlParameter("@CreateId",   model.CreateId),
                new SqlParameter("@CreateDate", model.CreateDate)
            };

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
ファイル: NL_ContactsDAL.cs プロジェクト: hofmannzhu/bwjs
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(BWJS.Model.NL_Contacts model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into dbo.[NL_Contacts](");
            strSql.Append("EditId,EditDate,ConsultId,FullName,Mobile,RelationId,Depth,IsDeleted,CreateId,CreateDate");
            strSql.Append(") values (");
            strSql.Append("@EditId,@EditDate,@ConsultId,@FullName,@Mobile,@RelationId,@Depth,@IsDeleted,@CreateId,@CreateDate");
            strSql.Append(") ");
            strSql.Append(";select SCOPE_IDENTITY()");
            SqlParameter[] parameters =
            {
                new SqlParameter("@EditId",     model.EditId),
                new SqlParameter("@EditDate",   model.EditDate),
                new SqlParameter("@ConsultId",  model.ConsultId),
                new SqlParameter("@FullName",   model.FullName),
                new SqlParameter("@Mobile",     model.Mobile),
                new SqlParameter("@RelationId", model.RelationId),
                new SqlParameter("@Depth",      model.Depth),
                new SqlParameter("@IsDeleted",  model.IsDeleted),
                new SqlParameter("@CreateId",   model.CreateId),
                new SqlParameter("@CreateDate", model.CreateDate)
            };


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

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