Esempio n. 1
0
        private bool DoAdd()
        {
            BLL.common_examination   bll   = new BLL.common_examination();
            Model.common_examination model = new Model.common_examination();

            model.group_id  = (int)EnumCollection.examination_group.精品微课测验;
            model.name      = Convert.ToString(txtname.Text);
            model.parent_id = this.chapter;
            model.nums      = Convert.ToInt32(txtnums.Text);
            model.score     = Convert.ToInt32(txtscore.Text);
            model.qrcode    = "";
            model.add_time  = System.DateTime.Now;

            int row = bll.Add(model);

            if (row > 0)
            {
                addrow       = row;
                model.id     = row;
                model.qrcode = "/QrCode.aspx?type=test&id=" + row;
                bll.Update(model);

                AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加试卷信息,主键:" + row); //记录日志
                return(true);
            }
            else
            {
                return(false);
            }
        }
        //保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("_ybd_common_examination", EnumCollection.ActionEnum.Add.ToString()); //检查权限

            #region
            string strError = string.Empty;
            if (txtgroup_id.Text.Trim() == "" || txtgroup_id.Text.Trim().Length > 4)
            {
                strError += "分组ID为空或超出长度![br]";
            }
            if (txtname.Text.Trim() == "" || txtname.Text.Trim().Length > 50)
            {
                strError += "试卷名称为空或超出长度![br]";
            }
            if (txtparent_id.Text.Trim() == "" || txtparent_id.Text.Trim().Length > 4)
            {
                strError += "主体ID为空或超出长度![br]";
            }
            if (txtnums.Text.Trim() == "" || txtnums.Text.Trim().Length > 4)
            {
                strError += "试题数量为空或超出长度![br]";
            }
            if (txtscore.Text.Trim() == "" || txtscore.Text.Trim().Length > 4)
            {
                strError += "总分为空或超出长度![br]";
            }
            if (txtinfo.Text.Trim() == "" || txtinfo.Text.Trim().Length > 500)
            {
                strError += "描述为空或超出长度![br]";
            }
            if (txtdescript.Text.Trim() == "" || txtdescript.Text.Trim().Length > 4000)
            {
                strError += "结果解析为空或超出长度![br]";
            }
            if (txtqrcode.Text.Trim() == "" || txtqrcode.Text.Trim().Length > 255)
            {
                strError += "二维码为空或超出长度![br]";
            }
            if (txtadd_time.Text.Trim() == "" || txtadd_time.Text.Trim().Length > 8)
            {
                strError += "创建时间为空或超出长度![br]";
            }

            if (strError != string.Empty)
            {
                JscriptMsg(strError, "", "Error");
                return;
            }
            #endregion

            Model.common_examination model = new Model.common_examination();
            BLL.common_examination   bll   = new BLL.common_examination();

            model.group_id  = Convert.ToInt32(txtgroup_id.Text);
            model.name      = Convert.ToString(txtname.Text);
            model.parent_id = Convert.ToInt32(txtparent_id.Text);
            model.nums      = Convert.ToInt32(txtnums.Text);
            model.score     = Convert.ToInt32(txtscore.Text);
            model.info      = Convert.ToString(txtinfo.Text);
            model.descript  = Convert.ToString(txtdescript.Text);
            model.qrcode    = Convert.ToString(txtqrcode.Text);
            model.add_time  = Convert.ToDateTime(txtadd_time.Text);

            int id = bll.Add(model);
            if (id > 0)
            {
                AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加试卷信息信息,主键:" + id); //记录日志
                JscriptMsg("添加试卷信息信息成功!", "Manage.aspx", "");
            }
            else
            {
                JscriptMsg("保存过程中发生错误!", "");
            }
        }