Example #1
0
        /// <summary>
        /// 设定时间表
        /// </summary>
        /// <param name="schedule"></param>
        /// <param name="trans"></param>
        /// <returns></returns>
        public static int SetSchedule(Dal.Models.Schedule schedule, OleDbConnection conn, OleDbTransaction trans = null)
        {
            if (schedule == null ||
                (schedule.SpecialtyID == null && schedule.ActivityID == null) ||
                (schedule.SpecialtyID != null && schedule.ActivityID != null))
            {
                return(-1);
            }

            // 专业一旦设定了时间表,则自动修改其继承状态为否
            int iResult = 0;

            if (schedule.SpecialtyID != null)
            {
                Dal.Models.Specialty specialty = Specialty.GetSpecialty(schedule.SpecialtyID.Value, conn, trans);

                if (specialty.IsInheritSchedule == null || specialty.IsInheritSchedule.Value)
                {
                    specialty.IsInheritSchedule = false;
                    Specialty.UpdateSpecialty(specialty, conn, trans);
                    iResult = CreateSchedule(schedule, conn, trans);
                }
                else
                {
                    Dal.Models.Schedule sc = GetSpecialtySchedule(schedule.SpecialtyID.Value, conn, trans);
                    if (sc != null)
                    {
                        schedule.ScheduleID = sc.ScheduleID;
                        iResult             = UpdateSchedule(schedule, conn, trans);
                    }
                    else
                    {
                        iResult = CreateSchedule(schedule, conn, trans);
                    }
                }
            }
            else
            {
                Dal.Models.Schedule sc = GetActivitySchedule(schedule.ActivityID.Value, conn, trans);
                if (sc != null)
                {
                    schedule.ScheduleID = sc.ScheduleID;
                    iResult             = UpdateSchedule(schedule, conn, trans);
                }
                else
                {
                    iResult = CreateSchedule(schedule, conn, trans);
                }
            }

            return(iResult);
        }
Example #2
0
        protected void gvActivity_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Dal.Models.UserInfo user = (Dal.Models.UserInfo)Session["UserInfo"];
            string strActivityType   = Session["ActivityType"].ToString();

            string          strMessage = "";
            OleDbConnection conn       = new OleDbConnection(Dal.OleDbHlper.ConnectionString);

            conn.Open();
            OleDbTransaction tran = null;

            Dal.Models.Activity act          = null;
            Dal.Models.Activity actActivated = null;
            Dal.Models.Schedule UcSchedule   = new Dal.Models.Schedule();
            switch (e.CommandName)
            {
            case "Activate":
                tran         = conn.BeginTransaction();
                actActivated = BLL.Activity.GetActivity(strActivityType, conn, tran);
                if (actActivated != null)
                {
                    strMessage = "已存在进行中的评优活动,激活失败!";
                    tran.Rollback();
                }
                else
                {
                    act = BLL.Activity.GetActivity(Convert.ToInt32(e.CommandArgument), conn, tran);
                    Dal.Models.Schedule schedule = BLL.Schedule.GetActivitySchedule(act.ActivityID.Value, conn, tran);
                    act.ActivityStatus = "1101";
                    try
                    {
                        if (schedule != null)
                        {
                            UcSchedule.ScheduleID = schedule.ScheduleID;
                        }
                        UcSchedule.IsDeclarationStart         = false;
                        UcSchedule.IsDeclarationAutoStart     = false;
                        UcSchedule.IsDeclarationAutoEnd       = false;
                        UcSchedule.IsPrimaryElectionStart     = false;
                        UcSchedule.IsPrimaryElectionAutoStart = false;
                        UcSchedule.IsPrimaryElectionAutoEnd   = false;
                        UcSchedule.IsExpertReviewStart        = false;
                        UcSchedule.IsExpertReviewAutoStart    = false;
                        UcSchedule.IsExpertReviewAutoEnd      = false;
                        UcSchedule.IsDownloadStart            = false;
                        UcSchedule.IsDownloadAutoStart        = false;
                        UcSchedule.IsDownloadAutoEnd          = false;
                        UcSchedule.IsVoteStart     = false;
                        UcSchedule.IsVoteAutoStart = false;
                        UcSchedule.IsVoteAutoEnd   = false;
                        UcSchedule.IsReVoteStart   = false;
                        BLL.Activity.UpdateActivity(act, conn, tran);
                        BLL.Schedule.SetSchedule(UcSchedule, conn, tran);
                        tran.Commit();

                        ucSchedule.activityRefresh();
                        panelCreateActivity.Visible = false;
                        panelActivityInfo.Visible   = true;
                        txtCurrentActivity.Text     = act.ActivityName;

                        strMessage = "激活成功!";
                    }
                    catch (Exception ex)
                    {
                        tran.Rollback();
                        strMessage = ex.Message;
                    }
                }

                hdMsg.Value = strMessage;
                break;
            }

            conn.Close();
        }
Example #3
0
        protected void SaveSchedule(object sender, EventArgs e)
        {
            string          strActivityType = Session["ActivityType"].ToString();
            OleDbConnection conn            = new OleDbConnection(Dal.OleDbHlper.ConnectionString);

            conn.Open();
            OleDbTransaction trans = conn.BeginTransaction();

            Dal.Models.Schedule schedule     = new Dal.Models.Schedule();
            Dal.Models.Activity actActivated = BLL.Activity.GetActivity(strActivityType, conn, trans);
            schedule.ActivityID = actActivated.ActivityID;

            DateTime dt;

            if (!string.IsNullOrEmpty(ucSchedule.DeclarationBeginDate) &&
                DateTime.TryParse(ucSchedule.DeclarationBeginDate, out dt))
            {
                schedule.DeclarationBeginDate = dt;
            }

            if (!string.IsNullOrEmpty(ucSchedule.DeclarationEndDate) &&
                DateTime.TryParse(ucSchedule.DeclarationEndDate, out dt))
            {
                schedule.DeclarationEndDate = dt;
            }

            schedule.IsDeclarationStart     = ucSchedule.IsDeclarationStart == "True";
            schedule.IsDeclarationAutoStart = ucSchedule.IsDeclarationAutoStart == "True";
            schedule.IsDeclarationAutoEnd   = ucSchedule.IsDeclarationAutoEnd == "True";

            if (!string.IsNullOrEmpty(ucSchedule.PrimaryElectionBeginDate) &&
                DateTime.TryParse(ucSchedule.PrimaryElectionBeginDate, out dt))
            {
                schedule.PrimaryElectionBeginDate = dt;
            }

            if (!string.IsNullOrEmpty(ucSchedule.PrimaryElectionEndDate) &&
                DateTime.TryParse(ucSchedule.PrimaryElectionEndDate, out dt))
            {
                schedule.PrimaryElectionEndDate = dt;
            }

            schedule.IsPrimaryElectionStart     = ucSchedule.IsPrimaryElectionStart == "True";
            schedule.IsPrimaryElectionAutoStart = ucSchedule.IsPrimaryElectionAutoStart == "True";
            schedule.IsPrimaryElectionAutoEnd   = ucSchedule.IsPrimaryElectionAutoEnd == "True";

            if (!string.IsNullOrEmpty(ucSchedule.ExpertReviewBeginDate) &&
                DateTime.TryParse(ucSchedule.ExpertReviewBeginDate, out dt))
            {
                schedule.ExpertReviewBeginDate = dt;
            }

            if (!string.IsNullOrEmpty(ucSchedule.ExpertReviewEndDate) &&
                DateTime.TryParse(ucSchedule.ExpertReviewEndDate, out dt))
            {
                schedule.ExpertReviewEndDate = dt;
            }

            schedule.IsExpertReviewStart     = ucSchedule.IsExpertReviewStart == "True";
            schedule.IsExpertReviewAutoStart = ucSchedule.IsExpertReviewAutoStart == "True";
            schedule.IsExpertReviewAutoEnd   = ucSchedule.IsExpertReviewAutoEnd == "True";

            if (!string.IsNullOrEmpty(ucSchedule.DownloadBeginDate) &&
                DateTime.TryParse(ucSchedule.DownloadBeginDate, out dt))
            {
                schedule.DownloadBeginDate = dt;
            }

            if (!string.IsNullOrEmpty(ucSchedule.DownloadEndDate) &&
                DateTime.TryParse(ucSchedule.DownloadEndDate, out dt))
            {
                schedule.DownloadEndDate = dt;
            }

            schedule.IsDownloadStart     = ucSchedule.IsDownloadStart == "True";
            schedule.IsDownloadAutoStart = ucSchedule.IsDownloadAutoStart == "True";
            schedule.IsDownloadAutoEnd   = ucSchedule.IsDownloadAutoEnd == "True";

            //投票
            if (!string.IsNullOrEmpty(ucSchedule.VoteBeginDate) &&
                DateTime.TryParse(ucSchedule.VoteBeginDate, out dt))
            {
                schedule.VoteBeginDate = dt;
            }

            if (!string.IsNullOrEmpty(ucSchedule.VoteEndDate) &&
                DateTime.TryParse(ucSchedule.VoteEndDate, out dt))
            {
                schedule.VoteEndDate = dt;
            }

            schedule.IsVoteStart     = ucSchedule.IsVoteStart == "True";
            schedule.IsVoteAutoStart = ucSchedule.IsVoteAutoStart == "True";
            schedule.IsVoteAutoEnd   = ucSchedule.IsVoteAutoEnd == "True";

            schedule.IsReVoteStart = ucSchedule.IsReVoteStart == "True";

            try
            {
                BLL.Schedule.SetSchedule(schedule, conn, trans);
                trans.Commit();
                hdMsg.Value = "时间节点设置成功!";
            }
            catch (Exception ex)
            {
                trans.Rollback();
                hdMsg.Value = ex.Message;
                ViewState["ErrorMessage"] = ex.Message;
            }

            conn.Close();
        }
        protected void btnNext_Click(object sender, EventArgs e)
        {
            Dal.Models.UserInfo user = (Dal.Models.UserInfo)Session["UserInfo"];

            // 创建申报项目
            Dal.Models.Declaration decl = null;
            bool   bChanged             = false;
            string strTemplateCode      = "";

            DateTime dtm;

            if (!DateTime.TryParse(txtDeclarateDate.Text, out dtm))
            {
                hdMsg.Value = "项目申报时间格式错误!";
                return;
            }


            int iPrizeID = Convert.ToInt32(Request["rdlPrize"]);

            if (iPrizeID == 0 && rdlPrize.SelectedValue != "")
            {
                iPrizeID = Convert.ToInt32(rdlPrize.SelectedValue);
            }

            if (iPrizeID == 0)
            {
                hdMsg.Value = "请选择奖项!";
                return;
            }

            OleDbConnection conn = new OleDbConnection(Dal.OleDbHlper.ConnectionString);

            conn.Open();
            string strActivityType = Request.Cookies["ActivityType"].Value;

            Dal.Models.Activity actActivated = BLL.Activity.GetActivity(strActivityType, conn);
            string strDeclarationCode        = "";

            if (ViewState["DeclarationID"] != null)
            {
                decl = BLL.Declaration.GetDeclaration(Convert.ToInt32(ViewState["DeclarationID"]), conn);
                strDeclarationCode = decl.DeclarationCode;
            }
            else
            {
                decl            = new Dal.Models.Declaration();
                decl.UserID     = user.UserID;
                decl.ActivityID = actActivated.ActivityID;
            }

            if (decl.DeclareDate == null || decl.DeclareDate.Value != dtm)
            {
                bChanged         = true;
                decl.DeclareDate = dtm;
            }

            if (string.IsNullOrEmpty(decl.RecommendFrom) || decl.RecommendFrom != ChooseAssociation.SelectedValue)
            {
                bChanged           = true;
                decl.RecommendFrom = ChooseAssociation.SelectedValue;
            }

            if (decl.PrizeID == null || decl.PrizeID != iPrizeID)
            {
                bChanged     = true;
                decl.PrizeID = iPrizeID;
            }

            if (string.IsNullOrEmpty(decl.DeclarationName) || decl.DeclarationName != txtProjectName.Text.Trim())
            {
                bChanged             = true;
                decl.DeclarationName = txtProjectName.Text.Trim();
            }

            Dal.Models.Prize prize = BLL.Prize.GetPrize(decl.PrizeID.Value, conn);
            strTemplateCode = prize.TemplateCode;
            int iSpecilID = prize.SpecialtyID.Value;
            int actID     = prize.ActivityID.Value;

            Dal.Models.Schedule dSchedule = BLL.Schedule.GetSpecialtySchedule(iSpecilID, conn);

            if (dSchedule == null || !dSchedule.IsDeclarationStart.Value)
            {
                hdMsg.Value = "未在专业申报时间内,不能创建!";
                conn.Close();
                return;
            }

            string strSituation = "";

            if (!string.IsNullOrEmpty(Request["Situation"]))
            {
                strSituation = Request["Situation"].Replace("'", "").Replace("\"", "");
            }

            if (bChanged == true && (strSituation == Dal.Models.EnumSituation.Declaration.ToString() || strSituation == ""))
            {
                OleDbTransaction trans = conn.BeginTransaction();
                try
                {
                    BLL.Declaration.Declarate(ref decl, conn, trans);

                    string strImportDeclarationID = ImportDeclarationData.SelectedValue;
                    if (strImportDeclarationID != "0" && strImportDeclarationID != "")
                    {
                        string strDeclarationCode2 = BLL.Declaration.GetDeclaration(Convert.ToInt32(strImportDeclarationID), conn, trans).DeclarationCode;
                        BLL.Declaration.ImportDeclarate(decl.DeclarationID.Value, Convert.ToInt32(strImportDeclarationID), conn, trans);
                        BLL.Declaration.ImportUploadFile(decl.DeclarationID.Value, Convert.ToInt32(strImportDeclarationID), decl.DeclarationCode, strDeclarationCode2, conn, trans);
                    }
                    trans.Commit();
                    ViewState["DeclarationID"] = decl.DeclarationID.Value;
                }
                catch (Exception ex)
                {
                    ViewState.Remove("DeclarationID");
                    trans.Rollback();
                    hdMsg.Value = ex.Message;
                    return;
                }
            }

            // 获取申报项目的模板首页
            string strPartCode = strTemplateCode.Substring(2, 2) + "01";

            // 根据首页获取模板
            TempInfo = BLL.Declaration.GetTemplateInfo(strPartCode, conn);
            TempInfo.DeclarationID   = (int)ViewState["DeclarationID"];
            TempInfo.DeclarationCode = strDeclarationCode;
            if (!string.IsNullOrEmpty(strSituation))
            {
                TempInfo.Situation = (Dal.Models.EnumSituation)Enum.Parse(typeof(Dal.Models.EnumSituation), strSituation, true);
            }
            else
            {
                TempInfo.Situation = (Dal.Models.EnumSituation)Enum.Parse(typeof(Dal.Models.EnumSituation), "Declara", true);
            }

            conn.Close();

            if (TempInfo != null)
            {
                Session.Add("TemplateInfo", TempInfo);

                // 跳转到模板页
                if (strSituation == "ExpertReview" || strSituation == "Delete" || strSituation == "Auditing")
                {
                    Server.Transfer(TempInfo.NewTemplateUrl);
                }
                else
                {
                    Server.Transfer(TempInfo.TemplateUrl);
                }
            }
        }
Example #5
0
        public static int CreateSchedule(Dal.Models.Schedule schedule, OleDbConnection conn, OleDbTransaction trans = null)
        {
            StringBuilder sbSql = new StringBuilder();

            sbSql.Append(" INSERT INTO Schedule ( ");
            sbSql.Append("         ActivityID ");
            sbSql.Append("        ,SpecialtyID ");
            sbSql.Append("        ,DeclarationBeginDate ");
            sbSql.Append("        ,DeclarationEndDate ");
            sbSql.Append("        ,IsDeclarationAutoStart");
            sbSql.Append("        ,IsDeclarationAutoEnd ");
            sbSql.Append("        ,IsDeclarationStart ");
            sbSql.Append("        ,PrimaryElectionBeginDate ");
            sbSql.Append("        ,PrimaryElectionEndDate ");
            sbSql.Append("        ,IsPrimaryElectionAutoStart ");
            sbSql.Append("        ,IsPrimaryElectionAutoEnd ");
            sbSql.Append("        ,IsPrimaryElectionStart ");
            sbSql.Append("        ,ExpertReviewBeginDate ");
            sbSql.Append("        ,ExpertReviewEndDate ");
            sbSql.Append("        ,IsExpertReviewAutoStart ");
            sbSql.Append("        ,IsExpertReviewAutoEnd ");
            sbSql.Append("        ,IsExpertReviewStart ");
            sbSql.Append("        ,DownloadBeginDate ");
            sbSql.Append("        ,DownloadEndDate ");
            sbSql.Append("        ,IsDownloadAutoStart ");
            sbSql.Append("        ,IsDownloadAutoEnd ");
            sbSql.Append("        ,IsDownloadStart ");
            sbSql.Append("        ,VoteBeginDate ");
            sbSql.Append("        ,VoteEndDate ");
            sbSql.Append("        ,IsVoteAutoStart ");
            sbSql.Append("        ,IsVoteAutoEnd ");
            sbSql.Append("        ,IsVoteStart ");
            sbSql.Append("        ,IsReVoteStart             ");
            sbSql.Append(" ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ");

            int iResult = Dal.OleDbHlper.ExecuteNonQuery(sbSql.ToString(), conn, CommandType.Text, trans
                                                         , new OleDbParameter("@ActivityID", OleDbType.Integer)
            {
                Value = schedule.ActivityID
            }
                                                         , new OleDbParameter("@SpecialtyID", OleDbType.Integer)
            {
                Value = schedule.SpecialtyID
            }
                                                         , new OleDbParameter("@DeclarationBeginDate", OleDbType.DBDate)
            {
                Value = schedule.DeclarationBeginDate
            }
                                                         , new OleDbParameter("@DeclarationEndDate", OleDbType.DBDate)
            {
                Value = schedule.DeclarationEndDate
            }
                                                         , new OleDbParameter("@IsDeclarationAutoStart", OleDbType.Boolean)
            {
                Value = schedule.IsDeclarationAutoStart
            }
                                                         , new OleDbParameter("@IsDeclarationAutoEnd", OleDbType.Boolean)
            {
                Value = schedule.IsDeclarationAutoEnd
            }
                                                         , new OleDbParameter("@IsDeclarationStart", OleDbType.Boolean)
            {
                Value = schedule.IsDeclarationStart
            }
                                                         , new OleDbParameter("@PrimaryElectionBeginDate", OleDbType.DBDate)
            {
                Value = schedule.PrimaryElectionBeginDate
            }
                                                         , new OleDbParameter("@PrimaryElectionEndDate", OleDbType.DBDate)
            {
                Value = schedule.PrimaryElectionEndDate
            }
                                                         , new OleDbParameter("@IsPrimaryElectionAutoStart", OleDbType.Boolean)
            {
                Value = schedule.IsPrimaryElectionAutoStart
            }
                                                         , new OleDbParameter("@IsPrimaryElectionAutoEnd", OleDbType.Boolean)
            {
                Value = schedule.IsPrimaryElectionAutoEnd
            }
                                                         , new OleDbParameter("@IsPrimaryElectionStart", OleDbType.Boolean)
            {
                Value = schedule.IsPrimaryElectionStart
            }
                                                         , new OleDbParameter("@ExpertReviewBeginDate", OleDbType.DBDate)
            {
                Value = schedule.ExpertReviewBeginDate
            }
                                                         , new OleDbParameter("@ExpertReviewEndDate", OleDbType.DBDate)
            {
                Value = schedule.ExpertReviewEndDate
            }
                                                         , new OleDbParameter("@IsExpertReviewAutoStart", OleDbType.Boolean)
            {
                Value = schedule.IsExpertReviewAutoStart
            }
                                                         , new OleDbParameter("@IsExpertReviewAutoEnd", OleDbType.Boolean)
            {
                Value = schedule.IsExpertReviewAutoEnd
            }
                                                         , new OleDbParameter("@IsExpertReviewStart", OleDbType.Boolean)
            {
                Value = schedule.IsExpertReviewStart
            }
                                                         , new OleDbParameter("@DownloadBeginDate", OleDbType.DBDate)
            {
                Value = schedule.DownloadBeginDate
            }
                                                         , new OleDbParameter("@DownloadEndDate", OleDbType.DBDate)
            {
                Value = schedule.DownloadEndDate
            }
                                                         , new OleDbParameter("@IsDownloadAutoStart", OleDbType.Boolean)
            {
                Value = schedule.IsDownloadAutoStart
            }
                                                         , new OleDbParameter("@IsDownloadAutoEnd", OleDbType.Boolean)
            {
                Value = schedule.IsDownloadAutoEnd
            }
                                                         , new OleDbParameter("@IsDownloadStart", OleDbType.Boolean)
            {
                Value = schedule.IsDownloadStart
            }
                                                         , new OleDbParameter("@VoteBeginDate", OleDbType.DBDate)
            {
                Value = schedule.VoteBeginDate
            }
                                                         , new OleDbParameter("@VoteEndDate", OleDbType.DBDate)
            {
                Value = schedule.VoteEndDate
            }
                                                         , new OleDbParameter("@IsVoteAutoStart", OleDbType.Boolean)
            {
                Value = schedule.IsVoteAutoStart
            }
                                                         , new OleDbParameter("@IsVoteAutoEnd", OleDbType.Boolean)
            {
                Value = schedule.IsVoteAutoEnd
            }
                                                         , new OleDbParameter("@IsVoteStart", OleDbType.Boolean)
            {
                Value = schedule.IsVoteStart
            }
                                                         , new OleDbParameter("@IsReVoteStart", OleDbType.Boolean)
            {
                Value = schedule.IsReVoteStart
            });

            return(iResult);
        }