Ejemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static bool InsertAgendaInfo(PersonalDateArrange model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into officedba.PersonalDateArrange(");
            strSql.Append("CompanyCD,ArrangeTItle,Critical,Content,StartDate,StartTime,EndTime,Creator,IsPublic,CreateDate,IsMobileNotice,AheadTimes,ModifiedDate,ModifiedUserID,Important)");
            strSql.Append(" values (");
            strSql.Append("@CompanyCD,@ArrangeTItle,@Critical,@Content,@StartDate,@StartTime,@EndTime,@Creator,@IsPublic,@CreateDate,@IsMobileNotice,@AheadTimes,@ModifiedDate,@ModifiedUserID,@Important)");
            strSql.Append("; select  @SourceID = @@IDENTITY  ");

            if (model.IsMobileNotice == "1")
            {
                strSql.Append("insert into officedba.NoticeHistory(");
                strSql.Append("   CompanyCD,SourceFlag,SourceID,PlanNoticeDate  )  ");
                strSql.Append("      values(@CompanyCD, @SourceFlag,@SourceID,@PlanNoticeDate  ) ");
            }
            SqlParameter[] parameters = {
					new SqlParameter("@CompanyCD", SqlDbType.VarChar,8),
					new SqlParameter("@ArrangeNo", SqlDbType.VarChar,50),
					new SqlParameter("@ArrangeTItle", SqlDbType.VarChar,100),
					new SqlParameter("@Critical", SqlDbType.Char,1),
					new SqlParameter("@Content", SqlDbType.VarChar,200),
					new SqlParameter("@StartDate", SqlDbType.DateTime),
					new SqlParameter("@StartTime", SqlDbType.VarChar,4),
					new SqlParameter("@EndTime", SqlDbType.VarChar,4),
					new SqlParameter("@Creator", SqlDbType.Int,4),
					new SqlParameter("@IsPublic", SqlDbType.Char,1),
					new SqlParameter("@CreateDate", SqlDbType.DateTime),
					new SqlParameter("@IsMobileNotice", SqlDbType.Char,1),
					new SqlParameter("@AheadTimes", SqlDbType.Int,4),
					new SqlParameter("@ModifiedDate", SqlDbType.DateTime),
					new SqlParameter("@ModifiedUserID", SqlDbType.VarChar,10),
                    new SqlParameter("@SourceFlag", SqlDbType.Char,1),
                    new SqlParameter("@PlanNoticeDate", SqlDbType.DateTime)  ,
                    new SqlParameter("@SourceID", SqlDbType.Int,4),
                    new SqlParameter("@Important", SqlDbType.Char,1) };
            parameters[0].Value = model.CompanyCD;
            parameters[1].Value = "未定义";
            parameters[2].Value = model.ArrangeTItle;
            parameters[3].Value = model.Critical;
            parameters[4].Value = model.Content;
            parameters[5].Value = model.StartDate;
            parameters[6].Value = model.StartTime;
            parameters[7].Value = model.EndTime;
            parameters[8].Value = model.Creator;
            parameters[9].Value = model.IsPublic;
            parameters[10].Value = DateTime.Now;
            parameters[11].Value = model.IsMobileNotice;
            parameters[12].Value = model.AheadTimes;
            parameters[13].Value = DateTime.Now;
            parameters[14].Value = model.ModifiedUserID;
            parameters[15].Value = '1';
            if (model.IsMobileNotice == "1")
            {
                try
                {
                    double hour = Convert.ToDouble(model.StartTime.Substring(0, 2));
                    double minite = Convert.ToDouble(model.StartTime.Substring(2, 2));
                    DateTime datetime = (DateTime)model.StartDate;
                    datetime = datetime.AddHours(hour);
                    datetime = datetime.AddMinutes(minite);
                    double aheadtime = Convert.ToDouble(model.AheadTimes) * -1;
                    datetime = datetime.AddHours(aheadtime);
                    parameters[16].Value = datetime;
                }
                catch
                {
                    parameters[16].Value = DateTime.Now;
                }


            }
            else
            {
                parameters[16].Value = DateTime.Now;
            }
            parameters[17].Value = 0;
            parameters[18].Value = model.Important;


            //定义更新基本信息的命令
            SqlCommand comm = new SqlCommand();
            comm.CommandText = strSql.ToString();
            //设置保存的参数
            foreach (SqlParameter sqp in parameters)
                comm.Parameters.Add(sqp);
            //返回操作结果  
            return SqlHelper.ExecuteTransWithCommand(comm);
        }
Ejemplo n.º 2
0
        public static bool SaveAgendaInfo(PersonalDateArrange model)
        {
            //获取登陆用户信息
            UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
            //设置公司代码
            model.CompanyCD = userInfo.CompanyCD;
            //定义返回变量
            bool isSucc = false;

            //ID存在时,更新
            if (ConstUtil.EDIT_FLAG_UPDATE.Equals(model.EditFlag))
            {

                try
                {
                    //执行更新操作
                    isSucc = AgendaInfoDBHelper.UpdateAgendaInfo(model);
                    LogInfoModel logModel = InitLogInfo("更新日程");
                    if (isSucc)
                    {
                        logModel.Remark = ConstUtil.LOG_PROCESS_SUCCESS;
                    }
                    else
                    {
                        logModel.Remark = ConstUtil.LOG_PROCESS_FAILED;
                    }
                    logModel.Element = ConstUtil.LOG_PROCESS_UPDATE;
                    logModel.ModuleID = "10411";
                    LogDBHelper.InsertLog(logModel);
                }
                catch (Exception ex)
                {
                    WriteSystemLog(userInfo, ex, ConstUtil.MODULE_ID_AGENDA_INFO);
                }
            }
            //插入
            else
            {
                try
                {
                    //执行插入操作
                    isSucc = AgendaInfoDBHelper.InsertAgendaInfo(model);
                    LogInfoModel logModel = InitLogInfo("新建日程");
                    if (isSucc)
                    {
                        logModel.Remark = ConstUtil.LOG_PROCESS_SUCCESS;
                    }
                    else
                    {
                        logModel.Remark = ConstUtil.LOG_PROCESS_FAILED;
                    }
                    logModel.Element = ConstUtil.LOG_PROCESS_INSERT;
                    logModel.ModuleID = "10411";
                    LogDBHelper.InsertLog(logModel);
                }
                catch (Exception ex)
                {
                    WriteSystemLog(userInfo, ex, ConstUtil.MODULE_ID_AGENDA_INFO);

                }
            }
            return isSucc;
        }