コード例 #1
0
ファイル: NewMaintainAdd.aspx.cs プロジェクト: pcstx/OA
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            NewsListEntity _NewsListEntity = new NewsListEntity();
            _NewsListEntity.CreateDate = DateTime.Now;
            _NewsListEntity.Creator = userEntity.UserName;
            if (txtExpDate.Text == "")
                _NewsListEntity.ExpireDate = DateTime.Parse("2038-01-01");
            else
                _NewsListEntity.ExpireDate = DateTime.Parse(txtExpDate.Text);

            _NewsListEntity.IsPublish = chkIsPublish.Checked==true ? '1':'0';
            _NewsListEntity.LastModifier = userEntity.UserName;
            _NewsListEntity.LastModifyDate = DateTime.Now;
            _NewsListEntity.NewsBody = FreeTextBox1.Text;

            _NewsListEntity.NewsTitle = txtTitle.Text;
            _NewsListEntity.NewsTypeID = Int32.Parse(dpType.SelectedValue);
            _NewsListEntity.PublishDate = DateTime.Parse("2012-01-01");
            string szResult = DbHelper.GetInstance().AddNewsListInfor(_NewsListEntity);

            NewsUser _NewsUser = new NewsUser();
            _NewsUser.NewsID =Convert.ToInt32(szResult);
            _NewsUser.NewsTypeDetailName = ddlOperatorTypeDetail.SelectedItem.Text;
            _NewsUser.NewsTypeuserName = txtObjectValueN.Text;
            DbHelper.GetInstance().AddNewsUser(_NewsUser);

            Context.Response.Redirect("NewMaintain.aspx");
        }
コード例 #2
0
ファイル: DbHelperHR.cs プロジェクト: pcstx/OA
        //add Rio
        public string AddNewsListInfor(NewsListEntity _NewsListEntity)
        {
            DbParameter[] pramsInsert = {
                                       MakeInParam("@NewsTitle",(DbType)SqlDbType.VarChar,200,_NewsListEntity.NewsTitle),
                                       MakeInParam("@NewsBody",(DbType)SqlDbType.VarChar,2000,_NewsListEntity.NewsBody),
                                       MakeInParam("@NewsTypeID",(DbType)SqlDbType.Int,4,_NewsListEntity.NewsTypeID),
                                       MakeInParam("@IsPublish",(DbType)SqlDbType.Char,1,_NewsListEntity.IsPublish),
                                       MakeInParam("@ExpiredDate",(DbType)SqlDbType.DateTime,20,_NewsListEntity.ExpireDate),
                                       MakeInParam("@CreateDate",(DbType)SqlDbType.DateTime,20,_NewsListEntity.CreateDate),
                                       MakeInParam("@Creator",(DbType)SqlDbType.VarChar,50,_NewsListEntity.Creator),
                                       MakeInParam("@PublishDate",(DbType)SqlDbType.DateTime,20,_NewsListEntity.PublishDate),
                                       MakeInParam("@LastModifier",(DbType)SqlDbType.VarChar,50,_NewsListEntity.LastModifier ),
                                       MakeInParam("@LastModifyDate",(DbType)SqlDbType.DateTime,20,_NewsListEntity.LastModifyDate ),
                                             };
                StringBuilder sb = new StringBuilder();
                sb.Append("INSERT INTO [dbo].[News_NewsList]");
                sb.Append("([NewsTitle]");
                sb.Append(",[NewsBody]");
                sb.Append(",[NewsTypeID]");
                sb.Append(",[IsPublish]");
                sb.Append(",[ExpiredDate]");
                sb.Append(",[CreateDate]");
                sb.Append(",[Creator]");
                sb.Append(",[PublishDate]");
                sb.Append(",[LastModifier]");
                sb.Append(",[LastModifyDate]");
                sb.Append(")");
                sb.Append("VALUES");
                sb.Append("(@NewsTitle");
                sb.Append(",@NewsBody");
                sb.Append(",@NewsTypeID");
                sb.Append(",@IsPublish");
                sb.Append(",@ExpiredDate ");
                sb.Append(",@CreateDate");
                sb.Append(",@Creator");
                sb.Append(",@PublishDate");
                sb.Append(",@LastModifier");
                sb.Append(",@LastModifyDate");
                sb.Append(")");
                sb.Append(" select @@identity;");

                return ExecuteScalar(CommandType.Text, sb.ToString(), pramsInsert).ToString();
        }