protected void BindChapter(Model.CCOM.Subject model, int children)
        {
            BLL.CCOM.Subject bll = new BLL.CCOM.Subject();
            int subjectId        = model.Subject_id;

            if (model.Value_type == 3)
            {
                //数字
                if (children > 0)
                {
                    chapterBuilder.Append(levelCountValue[model.Subject_level - 1, Math.Abs(children) - 1]);
                }
                else if (children == 0)
                {
                    chapterBuilder.Append(levelCountValue[model.Subject_level - 1, 0]);
                }
                else
                {
                    chapterBuilder.Append(levelCountValue[model.Subject_level - 2, Math.Abs(children) - 1]);
                }
                chapterBuilder.Append(valueDic[model.Subject_id][0].Usv_value + "<br/>");
            }
            if (children <= 0)
            {
                //子节点
                if (model.Value_type == 0)
                {
                    int i = 0;
                    //多项类型,往下Bind
                    foreach (Model.CCOM.Subject Cmodel in subjectDic.Values)
                    {
                        if (Cmodel.Fs_id == model.Subject_id)
                        {
                            BindChapter(Cmodel, -++i);
                        }
                    }
                }
                else if (model.Value_type == 1)
                {
                    //单选,绑一个
                    BindChapter(model, 1);
                }
                else if (model.Value_type == 2)
                {
                    //多选类型,有几个绑几个
                    for (int i = 1; i <= model.Value_count; i++)
                    {
                        BindChapter(model, i);
                    }
                }
            }
            else
            {
                Model.CCOM.Subject Cmodel = subjectDic[Convert.ToInt32(valueDic[subjectId][children].Usv_value)];
                //数字
                chapterBuilder.Append(levelCountValue[Cmodel.Subject_level - 2, children - 1]);
                chapterBuilder.Append(Cmodel.Subject_title + "<br/>");
                BindChapter(Cmodel, 0);
            }
        }
Esempio n. 2
0
        protected int refreshAttachRow(Model.CCOM.Subject model)
        {
            int attachRowValue = 0;

            BLL.CCOM.Subject bll    = new BLL.CCOM.Subject();
            int          subjectId  = model.Subject_id;
            TableRow     subjectRow = (TableRow)this.subjectTable.FindControl("subjectRow" + subjectId);
            DropDownList value_type = (DropDownList)subjectRow.FindControl("valueType" + subjectId);
            int          value      = 5;

            if (value_type != null)
            {
                value = Convert.ToInt32(value_type.SelectedValue);
            }
            else
            {
                value = model.Value_type;
            }
            if (value <= 2)
            {
                //有值类型,往下Bind
                int flag = 0;
                foreach (Model.CCOM.Subject Cmodel in subjectDic.Values)
                {
                    if (Cmodel.Fs_id == model.Subject_id)
                    {
                        attachRowValue = refreshAttachRow(Cmodel);
                        flag++;
                    }
                }
                if (flag == 0)
                {
                    attachRowValue = subjectTable.Rows.GetRowIndex(subjectRow);
                }
                if (value == 0 && flag >= 10)
                {
                    Button btnAdd = (Button)subjectRow.FindControl("btnAdd" + subjectId);
                    btnAdd.Visible = false;
                }
                if (value == 0 && flag < 10)
                {
                    Button btnAdd = (Button)subjectRow.FindControl("btnAdd" + subjectId);
                    btnAdd.Visible = true;
                }
            }
            else
            {
                if (subjectRow.FindControl("btnAdd" + model.Subject_id) != null)
                {
                    subjectRow.FindControl("btnAdd" + model.Subject_id).Visible = false;
                }
                attachRowValue = subjectTable.Rows.GetRowIndex(subjectRow);
            }
            HiddenField attachRow = (HiddenField)subjectRow.FindControl("attachRow" + subjectId);

            attachRow.Value = attachRowValue.ToString();

            return(attachRowValue);
        }
        protected TableRow newSubjectRow(Model.CCOM.Subject model)
        {
            int level     = model.Subject_level;
            int subjectId = model.Subject_id;
            //当前项TableRow
            TableRow  subjectRow = new TableRow();
            TableCell titleCell  = new TableCell();

            subjectRow.Cells.Add(titleCell);
            //空格
            Label  span  = new Label();
            string blank = "";

            for (int i = 0; i < model.Subject_level; i++)
            {
                blank += "&nbsp;&nbsp;";
            }
            span.Text = blank;
            titleCell.Controls.Add(span);

            TableCell subjectTypeCell = new TableCell();

            subjectTypeCell.HorizontalAlign = HorizontalAlign.Center;
            subjectRow.Cells.Add(subjectTypeCell);
            TableCell descriptionCell = new TableCell();

            descriptionCell.HorizontalAlign = HorizontalAlign.Center;
            subjectRow.Cells.Add(descriptionCell);
            //标题
            Label title = new Label();

            title.ID   = "title" + subjectId;
            title.Text = model.Subject_title;
            if (model.Subject_level == 1)
            {
                title.Font.Bold = true;
            }
            titleCell.Controls.Add(title);
            if (level == 2)
            {
                //笔试/面试
                Label subjectType = new Label();
                subjectType.ID   = "subjectType" + subjectId;
                subjectType.Text = (bool)model.Subject_type ? "面试" : "笔试";
                subjectTypeCell.Controls.Add(subjectType);
            }
            TextBox description = new TextBox();

            description.ID       = "description" + subjectId;
            description.ReadOnly = true;
            description.TextMode = TextBoxMode.MultiLine;
            description.Rows     = 2;
            description.Text     = model.Subject_description.ToString();
            descriptionCell.Controls.Add(description);

            return(subjectRow);
        }
Esempio n. 4
0
        //children:0表示不是子节点,超过0表示第几个子节点
        protected void BindSubject(Model.CCOM.Subject model, HtmlGenericControl div, int children, bool isShow)
        {
            BLL.CCOM.Subject bll = new BLL.CCOM.Subject();
            int   subjectId      = model.Subject_id;
            Panel subjectPanel   = null;

            if (children != 0)
            {
                subjectPanel         = newSubjectPanel(model, children);
                subjectPanel.Visible = isShow;
                div.Controls.Add(subjectPanel);
            }
            if (children <= 0)
            {
                if (children != 0)
                {
                    subjectPanel.ID = "subjectPanel" + subjectId;
                }
                //子节点
                if (model.Value_type == 0)
                {
                    int i = 0;
                    //多项类型,往下Bind
                    foreach (Model.CCOM.Subject Cmodel in subjectDic.Values)
                    {
                        if (Cmodel.Fs_id == model.Subject_id)
                        {
                            BindSubject(Cmodel, div, -++i, isShow);
                        }
                    }
                }
                else if (model.Value_type == 1)
                {
                    //单选,绑一个
                    BindSubject(model, div, 1, isShow);
                }
                else if (model.Value_type == 2)
                {
                    //多选类型,有几个绑几个
                    for (int i = 1; i <= model.Value_count; i++)
                    {
                        BindSubject(model, div, i, isShow);
                    }
                }
            }
            else
            {
                subjectPanel.ID = "subjectPanel" + subjectId + "children" + children;
                foreach (Model.CCOM.Subject Cmodel in subjectDic.Values)
                {
                    if (Cmodel.Fs_id == subjectId)
                    {
                        BindSubject(Cmodel, div, 0, false);
                    }
                }
            }
        }
Esempio n. 5
0
        protected int BindSubject(Model.CCOM.Subject model)
        {
            int      attachRowValue = 0;
            int      subjectId      = model.Subject_id;
            TableRow subjectRow     = newSubjectRow(model);

            subjectRow.ID = "subjectRow" + subjectId;
            this.subjectTable.Rows.Add(subjectRow);
            DropDownList value_type = (DropDownList)subjectRow.FindControl("valueType" + subjectId);
            int          value      = 5;

            if (value_type != null)
            {
                value = Convert.ToInt32(value_type.SelectedValue);
            }
            else
            {
                value = model.Value_type;
            }
            if (value <= 2)
            {
                //有值类型,往下Bind
                bool flag = true;
                foreach (Model.CCOM.Subject Cmodel in subjectDic.Values)
                {
                    if (Cmodel.Fs_id == model.Subject_id)
                    {
                        attachRowValue = BindSubject(Cmodel);
                        flag           = false;
                    }
                }
                if (flag)
                {
                    attachRowValue = subjectTable.Rows.GetRowIndex(subjectRow);
                }
                if (value == 2)
                {
                    subjectRow.FindControl("valueCount" + model.Subject_id).Visible = true;
                    subjectRow.FindControl("Label1" + model.Subject_id).Visible     = true;
                    subjectRow.FindControl("Label2" + model.Subject_id).Visible     = true;
                }
            }
            else
            {
                if (subjectRow.FindControl("btnAdd" + model.Subject_id) != null)
                {
                    subjectRow.FindControl("btnAdd" + model.Subject_id).Visible = false;
                }
                attachRowValue = subjectTable.Rows.GetRowIndex(subjectRow);
            }
            HiddenField attachRow = (HiddenField)subjectRow.FindControl("attachRow" + subjectId);

            attachRow.Value = attachRowValue.ToString();

            return(attachRowValue);
        }
Esempio n. 6
0
        protected void rowHadEdit(int subjectId)
        {
            Model.CCOM.Subject model   = subjectDic[subjectId];
            Button             btnSave = ((Button)this.subjectTable.FindControl("btnSave" + subjectId));

            if (model.Fs_id != 0)
            {
                rowHadEdit(model.Fs_id);
            }
        }
Esempio n. 7
0
        protected void BindAllSubject()
        {
            userId = GetAdminInfo_CCOM().User_id;
            BLL.CCOM.User_property   pbll   = new BLL.CCOM.User_property();
            Model.CCOM.User_property pmodel = pbll.GetModel("User_id=" + userId);
            int majorId = pmodel.Agency_id;

            //科目字典
            BLL.CCOM.Subject bll = new BLL.CCOM.Subject();
            try
            {
                List <Model.CCOM.Subject> subjectList = bll.GetModelList("Major_Agency_id=" + majorId);
                foreach (Model.CCOM.Subject subject in subjectList)
                {
                    subjectDic.Add(subject.Subject_id, subject);
                }
            }
            catch (Exception e)
            {
                return;
            }
            //旧值字典
            BLL.CCOM.User_subject_value vbll = new BLL.CCOM.User_subject_value();
            try
            {
                List <Model.CCOM.User_subject_value> valueList = vbll.GetModelList("User_id=" + GetAdminInfo_CCOM().User_id);
                foreach (Model.CCOM.User_subject_value value in valueList)
                {
                    if (!oldDic.ContainsKey(value.Subject_id))
                    {
                        oldDic.Add(value.Subject_id, new Dictionary <int, Model.CCOM.User_subject_value>());
                    }
                    if (value.Usv_children == null)
                    {
                        oldDic[value.Subject_id].Add(0, value);
                    }
                    else
                    {
                        oldDic[value.Subject_id].Add((int)value.Usv_children, value);
                    }
                }
            }
            catch (Exception e)
            {
                return;
            }
            root = bll.GetModel("Major_Agency_id=" + majorId + "and Subject_level=0");
            foreach (Model.CCOM.Subject Cmodel in subjectDic.Values)
            {
                if (Cmodel.Fs_id == root.Subject_id)
                {
                    BindTest(Cmodel);
                }
            }
        }
Esempio n. 8
0
        //通过subjectRow存储数据
        //temp表示是不是临时存储
        //返回为空正确,否则错误语句
        protected void saveRow(TableRow subjectRow, bool temp)
        {
            if (subjectRow.Visible == false)
            {
                return;
            }
            //存自己
            BLL.CCOM.Subject bll = new BLL.CCOM.Subject();
            int subjectId        = Convert.ToInt32(subjectRow.ID.Replace("subjectRow", ""));

            Model.CCOM.Subject        model       = subjectDic[subjectId];
            List <Model.CCOM.Subject> subjectList = bll.GetModelList("Fs_id=" + subjectId);

            if (model.Subject_level != 0)
            {
                TextBox title = (TextBox)subjectRow.FindControl("title" + subjectId);
                model.Subject_title = title.Text;
                DropDownList valueType = (DropDownList)subjectRow.FindControl("valueType" + subjectId);
                model.Value_type = Convert.ToInt32(valueType.SelectedValue);
                if (model.Value_type == 2)
                {
                    TextBox valueCount = (TextBox)subjectRow.FindControl("valueCount" + subjectId);
                    model.Value_count = Convert.ToInt32(valueCount.Text);
                }
                //特殊项
                if (model.Subject_level == 1 || model.Subject_level == 2)
                {
                    if (model.Subject_level == 2)
                    {
                        DropDownList subjectType = (DropDownList)subjectRow.FindControl("subjectType" + subjectId);
                        model.Subject_type = subjectType.SelectedIndex == 1;
                        DropDownList manageAgency = (DropDownList)subjectRow.FindControl("manageAgency" + subjectId);
                        model.Manage_Agency_id = Convert.ToInt32(manageAgency.SelectedValue);
                    }
                    TextBox weight = (TextBox)subjectRow.FindControl("weight" + subjectId);
                    model.Subject_weight = Convert.ToInt32(weight.Text);
                }
                TextBox description = (TextBox)subjectRow.FindControl("description" + subjectId);
                model.Subject_description = description.Text;
                bll.Update(model);
            }
            //临时存仍为修改状态,无子节点
            if (!temp)
            {
                //存子节点
                foreach (Model.CCOM.Subject Cmodel in subjectList)
                {
                    int childrenId = Cmodel.Subject_id;
                    saveRow((TableRow)this.subjectTable.FindControl("subjectRow" + childrenId), false);
                }
            }
        }
Esempio n. 9
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            Button btnAdd   = (Button)sender;
            int    fatherId = Convert.ToInt32(btnAdd.ID.Replace("btnAdd", ""));

            BLL.CCOM.Subject   bll         = new BLL.CCOM.Subject();
            Model.CCOM.Subject fatherModel = subjectDic[fatherId];

            //新建model
            Model.CCOM.Subject model = new Model.CCOM.Subject();
            //通过父节点赋值
            model.Fs_id           = Convert.ToInt32(fatherId);
            model.Major_Agency_id = fatherModel.Major_Agency_id;
            model.Period_id       = fatherModel.Period_id;
            model.Subject_level   = fatherModel.Subject_level + 1;
            //默认值
            model.Subject_title = "请输入标题";
            model.Value_type    = 4;
            if (model.Subject_level == 1 || model.Subject_level == 2)
            {
                if (model.Subject_level == 2)
                {
                    model.Subject_type     = false;
                    model.Manage_Agency_id = Convert.ToInt32(ddlDepartment.SelectedValue);
                }
                model.Subject_weight = 1;
            }
            if (model.Subject_level != 0)
            {
                model.Subject_description = "";
            }

            //新建TableRow
            model.Subject_id = bll.Add(model);
            TableRow subjectRow = newSubjectRow(model);

            subjectRow.ID = "subjectRow" + model.Subject_id;
            subjectDic.Add(model.Subject_id, model);

            //找准位置
            TableRow    fatherRow      = (TableRow)btnAdd.Parent.Parent;
            HiddenField attachRow      = (HiddenField)FindControl("attachRow" + fatherId);
            int         attachRowValue = Convert.ToInt32(attachRow.Value);

            this.subjectTable.Rows.AddAt(attachRowValue + 1, subjectRow);
            //变颜色
            subjectRow.BackColor = fatherRow.BackColor;
            refreshAttachRow(root);
            rowHadEdit(model.Subject_id);
            MakeClickableErrorMessage();
        }
 //children:0表示不是子节点,超过0表示第几个子节点
 protected void BindSubject(Model.CCOM.Subject model, int children, bool isShow)
 {
     BLL.CCOM.Subject bll = new BLL.CCOM.Subject();
     int subjectId = model.Subject_id;
     
     if (children != 0&&model.Subject_level==2)
     {
         sub.Add(model.Subject_id);
     }
     if (children <= 0)
     {
        
         //子节点
         if (model.Value_type == 0)
         {
             int i = 0;
             //多项类型,往下Bind
             foreach (Model.CCOM.Subject Cmodel in subjectDic.Values)
             {
                 if (Cmodel.Fs_id == model.Subject_id)
                 {
                     BindSubject(Cmodel,  -++i, isShow);
                 }
             }
         }
         else if (model.Value_type == 1)
         {
             //单选,绑一个
             BindSubject(model,  1, isShow);
         }
         else if (model.Value_type == 2)
         {
             //多选类型,有几个绑几个
             for (int i = 1; i <= model.Value_count; i++)
             {
                 BindSubject(model,  i, isShow);
             }
         }
     }
     else
     {
         
         foreach (Model.CCOM.Subject Cmodel in subjectDic.Values)
         {
             if (Cmodel.Fs_id == subjectId)
             {
                 BindSubject(Cmodel,  0, false);
             }
         }
     }
 }
        protected void BindSubject(Model.CCOM.Subject model)
        {
            BLL.CCOM.Subject bll = new BLL.CCOM.Subject();
            int subjectId        = model.Subject_id;

            if (model.Subject_level != 0)
            {
                TableRow subjectRow = newSubjectRow(model);
                this.subjectTable.Rows.Add(subjectRow);
            }
            if (model.Subject_level <= 1)
            {
                foreach (Model.CCOM.Subject Cmodel in subjectDic.Values)
                {
                    if (Cmodel.Fs_id == subjectId)
                    {
                        BindSubject(Cmodel);
                    }
                }
            }
        }
Esempio n. 12
0
 protected void changeChildrenRow(Model.CCOM.Subject subject, bool isShow, bool isMyself)
 {
     BLL.CCOM.Subject bll = new BLL.CCOM.Subject();
     if (!isMyself)
     {
         TableRow subjectRow = (TableRow)this.subjectTable.FindControl("subjectRow" + subject.Subject_id);
         if (subjectRow == null)
         {
             bll.Delete(subject.Subject_id);
             return;
         }
         subjectRow.Visible = isShow;
     }
     foreach (Model.CCOM.Subject model in subjectDic.Values)
     {
         if (model.Fs_id == subject.Subject_id)
         {
             changeChildrenRow(model, isShow, false);
         }
     }
 }
Esempio n. 13
0
 protected void changeChildrenRow(Model.CCOM.Subject subject, bool isShow, bool isMyself)
 {
     BLL.CCOM.Subject bll = new BLL.CCOM.Subject();
     if (!isMyself)
     {
         TableRow subjectRow = (TableRow)this.subjectTable.FindControl("subjectRow" + subject.Subject_id);
         subjectRow.Visible = isShow;
         ImageButton symbol = (ImageButton)subjectRow.FindControl("symbol" + subject.Subject_id);
         if (symbol.ImageUrl == "../../../images/exam/add.png")
         {
             return;
         }
     }
     foreach (Model.CCOM.Subject model in subjectDic.Values)
     {
         if (model.Fs_id == subject.Subject_id)
         {
             changeChildrenRow(model, isShow, false);
         }
     }
 }
        protected void BindAllSubject()
        {
            BLL.CCOM.Subject bll = new BLL.CCOM.Subject();
            try
            {
                List <Model.CCOM.Subject> subjectList = bll.GetModelList("Major_Agency_id=" + Convert.ToInt32(this.ddlMajor.SelectedItem.Value));
                foreach (Model.CCOM.Subject subject in subjectList)
                {
                    subjectDic.Add(subject.Subject_id, subject);
                }
            }
            catch (Exception e)
            {
                return;
            }
            //添加表头
            TableHeaderRow header = new TableHeaderRow();

            this.subjectTable.Controls.Add(header);
            TableHeaderCell headerCell1 = new TableHeaderCell();

            headerCell1.Text = "标题";
            headerCell1.Attributes.Add("width", "20%");
            header.Cells.Add(headerCell1);
            TableHeaderCell headerCell3 = new TableHeaderCell();

            headerCell3.Text = "考试方式";
            headerCell3.Attributes.Add("width", "20%");
            header.Cells.Add(headerCell3);
            TableHeaderCell headerCell6 = new TableHeaderCell();

            headerCell6.Text = "描述";
            headerCell6.Attributes.Add("width", "20%");
            header.Cells.Add(headerCell6);
            int majorId = Convert.ToInt32(this.ddlMajor.SelectedItem.Value);

            root = bll.GetModel("Major_Agency_id=" + majorId + "and Subject_level=0");
            BindSubject(root);
        }
Esempio n. 15
0
        protected void BindTest(Model.CCOM.Subject model)
        {
            HtmlGenericControl widgetPurpleDiv = new HtmlGenericControl();

            widgetPurpleDiv.TagName             = "div";
            widgetPurpleDiv.Attributes["class"] = "widget purple";
            divControls.Controls.Add(widgetPurpleDiv);

            HtmlGenericControl widgetTitleDiv = new HtmlGenericControl();

            widgetTitleDiv.TagName             = "div";
            widgetTitleDiv.Attributes["class"] = "widget-title";
            widgetPurpleDiv.Controls.Add(widgetTitleDiv);
            HtmlGenericControl ff1NameH4 = new HtmlGenericControl();

            ff1NameH4.TagName   = "h4";
            ff1NameH4.InnerHtml = model.Subject_title;
            widgetTitleDiv.Controls.Add(ff1NameH4);
            HtmlGenericControl toolsSpan = new HtmlGenericControl();

            toolsSpan.TagName             = "span";
            toolsSpan.Attributes["class"] = "tools";
            widgetTitleDiv.Controls.Add(toolsSpan);
            HtmlGenericControl iconA = new HtmlGenericControl();

            iconA.TagName             = "a";
            iconA.Attributes["href"]  = "javascript:;";
            iconA.Attributes["class"] = "icon-chevron-down";
            toolsSpan.Controls.Add(iconA);

            HtmlGenericControl widgetBodyDiv = new HtmlGenericControl();

            widgetBodyDiv.TagName             = "div";
            widgetBodyDiv.Attributes["class"] = "widget-body";
            widgetBodyDiv.Attributes["style"] = "display: block;";
            widgetPurpleDiv.Controls.Add(widgetBodyDiv);

            BindSubject(model, widgetBodyDiv, 0, true);
        }
Esempio n. 16
0
        protected TableRow newSubjectRow(Model.CCOM.Subject model)
        {
            int level     = model.Subject_level;
            int subjectId = model.Subject_id;
            //当前项TableRow
            TableRow  subjectRow = new TableRow();
            TableCell titleCell  = new TableCell();

            subjectRow.Cells.Add(titleCell);
            //空格
            Label  span  = new Label();
            string blank = "";

            for (int i = 0; i < model.Subject_level; i++)
            {
                blank += "&nbsp;&nbsp;";
            }
            span.Text = blank;
            titleCell.Controls.Add(span);
            //加减号
            ImageButton symbol = new ImageButton();

            symbol.ID               = "symbol" + subjectId;
            symbol.ImageUrl         = "../../../images/exam/minus.png";
            symbol.Click           += symbol_Click;
            symbol.CausesValidation = false;
            symbol.Width            = 10;
            titleCell.Controls.Add(symbol);
            Label space = new Label();

            space.Text = "&nbsp";
            titleCell.Controls.Add(space);

            TableCell valueTypeCell = new TableCell();

            valueTypeCell.HorizontalAlign = HorizontalAlign.Center;
            subjectRow.Cells.Add(valueTypeCell);
            TableCell subjectTypeCell = new TableCell();

            subjectTypeCell.HorizontalAlign = HorizontalAlign.Center;
            subjectRow.Cells.Add(subjectTypeCell);
            TableCell manageAgencyCell = new TableCell();

            manageAgencyCell.HorizontalAlign = HorizontalAlign.Center;
            subjectRow.Cells.Add(manageAgencyCell);
            TableCell weightCell = new TableCell();

            weightCell.HorizontalAlign = HorizontalAlign.Center;
            subjectRow.Cells.Add(weightCell);
            TableCell descriptionCell = new TableCell();

            descriptionCell.HorizontalAlign = HorizontalAlign.Center;
            subjectRow.Cells.Add(descriptionCell);
            TableCell btnCell = new TableCell();

            btnCell.HorizontalAlign = HorizontalAlign.Center;
            subjectRow.Cells.Add(btnCell);
            HiddenField attachRow = new HiddenField();

            attachRow.ID = "attachRow" + subjectId;
            btnCell.Controls.Add(attachRow);
            if (level == 0)
            {
                //标题
                Label title = new Label();
                title.ID   = "title" + subjectId;
                title.Text = ddlMajor.SelectedItem.Text + "专业科目";
                titleCell.Controls.Add(title);
            }
            else
            {
                //标题
                TextBox title = new TextBox();
                title.ID   = "title" + subjectId;
                title.Text = model.Subject_title;
                title.Attributes.Add("OnFocus", "if(this.value=='请输入标题') {this.value=''}");
                title.Attributes.Add("OnBlur", "if(this.value==''){this.value='请输入标题'}");
                title.Attributes.Add("OnChange", "document.getElementById('btnSave').className='btn btn-success';document.getElementById('labelSave').innerHTML='内容已变更,请保存';");
                titleCell.Controls.Add(title);
                RequiredFieldValidator titleValidator = new RequiredFieldValidator();
                titleValidator.ControlToValidate = "title" + subjectId;
                titleValidator.ID           = "titleValidator" + subjectId;
                titleValidator.Display      = ValidatorDisplay.Dynamic;
                titleValidator.ErrorMessage = "请输入标题";
                titleValidator.InitialValue = "请输入标题";
                titleCell.Controls.Add(titleValidator);
                CustomValidator CtitleValidator = new CustomValidator();
                CtitleValidator.ControlToValidate = "title" + subjectId;
                CtitleValidator.ID              = "CtitleValidator" + subjectId;
                CtitleValidator.Display         = ValidatorDisplay.Dynamic;
                CtitleValidator.ServerValidate += invalid_ServerValidate;
                CtitleValidator.ErrorMessage    = "请勿输入非法字符";
                titleCell.Controls.Add(CtitleValidator);
                //值方式
                DropDownList valueType = new DropDownList();
                valueType.ID = "valueType" + subjectId;
                if (model.Subject_level <= 5)
                {
                    valueType.Items.Add(new ListItem("多项", "0"));
                    valueType.Items.Add(new ListItem("单选", "1"));
                    valueType.Items.Add(new ListItem("多选", "2"));
                }
                valueType.Items.Add(new ListItem("文本", "3"));
                valueType.Items.Add(new ListItem("不填", "4"));
                valueType.SelectedValue         = model.Value_type.ToString();
                valueType.Width                 = 70;
                valueType.SelectedIndexChanged += valueType_SelectedIndexChanged;
                valueType.AutoPostBack          = true;
                valueTypeCell.Controls.Add(valueType);

                Label label1 = new Label();
                label1.ID      = "label1" + subjectId;
                label1.Text    = "&nbsp;";
                label1.Visible = false;
                valueTypeCell.Controls.Add(label1);
                TextBox valueCount = new TextBox();
                valueCount.ID      = "valueCount" + subjectId;
                valueCount.Text    = "2";
                valueCount.Enabled = false;
                valueCount.Width   = 20;
                valueCount.Visible = false;
                valueTypeCell.Controls.Add(valueCount);
                ImageButton btnValueCountUp = new ImageButton();
                btnValueCountUp.ID                = "btnValueCountUp" + subjectId;
                btnValueCountUp.Width             = 12;
                btnValueCountUp.Style["position"] = "relative";
                btnValueCountUp.Style["top"]      = "-8px";
                btnValueCountUp.Style["left"]     = "2px";
                btnValueCountUp.ImageUrl          = "../../../images/exam/add.png";
                btnValueCountUp.Visible           = false;
                btnValueCountUp.CausesValidation  = false;
                valueTypeCell.Controls.Add(btnValueCountUp);
                ImageButton btnValueCountDown = new ImageButton();
                btnValueCountDown.ID                = "btnValueCountDown" + subjectId;
                btnValueCountDown.Width             = 12;
                btnValueCountDown.Style["position"] = "relative";
                btnValueCountDown.Style["top"]      = "8px";
                btnValueCountDown.Style["left"]     = "-10px";
                btnValueCountDown.ImageUrl          = "../../../images/exam/minus.png";
                btnValueCountDown.Visible           = false;
                btnValueCountDown.CausesValidation  = false;
                valueTypeCell.Controls.Add(btnValueCountDown);
                NumericUpDownExtender valueCountUpDown = new NumericUpDownExtender();
                valueCountUpDown.TargetControlID    = "valueCount" + subjectId;
                valueCountUpDown.Maximum            = 10;
                valueCountUpDown.Minimum            = 2;
                valueCountUpDown.TargetButtonUpID   = "btnValueCountUp" + subjectId;
                valueCountUpDown.TargetButtonDownID = "btnValueCountDown" + subjectId;
                valueTypeCell.Controls.Add(valueCountUpDown);
                Label label2 = new Label();
                label2.ID      = "label2" + subjectId;
                label2.Text    = "项";
                label2.Visible = false;
                valueTypeCell.Controls.Add(label2);
                CustomValidator lackSonValidator = new CustomValidator();
                lackSonValidator.ControlToValidate = "valueType" + subjectId;
                lackSonValidator.ID              = "lackSonValidator" + subjectId;
                lackSonValidator.Display         = ValidatorDisplay.Dynamic;
                lackSonValidator.ServerValidate += lackSonValidator_ServerValidate;
                lackSonValidator.ErrorMessage    = "缺少子项目";
                valueTypeCell.Controls.Add(lackSonValidator);
                CustomValidator errorSonValidator = new CustomValidator();
                errorSonValidator.ControlToValidate = "valueType" + subjectId;
                errorSonValidator.ID              = "errorSonValidator" + subjectId;
                errorSonValidator.Display         = ValidatorDisplay.Dynamic;
                errorSonValidator.ServerValidate += errorSonValidator_ServerValidate;
                errorSonValidator.ErrorMessage    = "多选子项只可以为文本或不填";
                valueTypeCell.Controls.Add(errorSonValidator);
                if (level == 1 || level == 2)
                {
                    if (level == 2)
                    {
                        //笔试/面试
                        DropDownList subjectType = new DropDownList();
                        subjectType.ID = "subjectType" + subjectId;
                        subjectType.Items.Insert(0, "笔试");
                        subjectType.Items.Insert(1, "面试");
                        subjectType.Width         = 70;
                        subjectType.SelectedIndex = (Convert.ToBoolean(model.Subject_type) ? 1 : 0);
                        subjectTypeCell.Controls.Add(subjectType);
                        DropDownList manageAgency = new DropDownList();
                        manageAgency.ID = "manageAgency" + subjectId;
                        BindAgency(manageAgency);
                        manageAgency.Width         = 140;
                        manageAgency.SelectedValue = model.Manage_Agency_id.ToString();
                        manageAgencyCell.Controls.Add(manageAgency);
                    }
                    //权值
                    TextBox weight = new TextBox();
                    weight.ID      = "weight" + subjectId;
                    weight.Width   = 30;
                    weight.Text    = model.Subject_weight.ToString();
                    weight.Enabled = false;
                    weightCell.Controls.Add(weight);
                    ImageButton btnWeightUp = new ImageButton();
                    btnWeightUp.ID                = "btnWeightUp" + subjectId;
                    btnWeightUp.Width             = 12;
                    btnWeightUp.Style["position"] = "relative";
                    btnWeightUp.Style["top"]      = "-8px";
                    btnWeightUp.Style["left"]     = "2px";
                    btnWeightUp.ImageUrl          = "../../../images/exam/add.png";
                    weightCell.Controls.Add(btnWeightUp);
                    ImageButton btnWeightDown = new ImageButton();
                    btnWeightDown.ID                = "btnWeightDown" + subjectId;
                    btnWeightDown.Width             = 12;
                    btnWeightDown.Style["position"] = "relative";
                    btnWeightDown.Style["top"]      = "8px";
                    btnWeightDown.Style["left"]     = "-10px";
                    btnWeightDown.ImageUrl          = "../../../images/exam/minus.png";
                    weightCell.Controls.Add(btnWeightDown);
                    NumericUpDownExtender weightUpDown = new NumericUpDownExtender();
                    weightUpDown.TargetControlID    = "weight" + subjectId;
                    weightUpDown.Maximum            = 10;
                    weightUpDown.Minimum            = 0;
                    weightUpDown.TargetButtonUpID   = "btnWeightUp" + subjectId;
                    weightUpDown.TargetButtonDownID = "btnWeightDown" + subjectId;
                    weightCell.Controls.Add(weightUpDown);
                }
                TextBox description = new TextBox();
                description.ID       = "description" + subjectId;
                description.TextMode = TextBoxMode.MultiLine;
                description.Rows     = 2;
                description.Width    = 150;
                description.Text     = model.Subject_description.ToString();
                descriptionCell.Controls.Add(description);
                CustomValidator CdescriptionValidator = new CustomValidator();
                CdescriptionValidator.ControlToValidate = "description" + subjectId;
                CdescriptionValidator.ID              = "CdescriptionValidator" + subjectId;
                CdescriptionValidator.Display         = ValidatorDisplay.Dynamic;
                CdescriptionValidator.ServerValidate += invalid_ServerValidate;
                CdescriptionValidator.ErrorMessage    = "请勿输入非法字符";
                descriptionCell.Controls.Add(CdescriptionValidator);
            }
            //按钮
            if (level != 0)
            {
                Button btnDelete = new Button();
                btnDelete.ID               = "btnDelete" + subjectId;
                btnDelete.Text             = "删除";
                btnDelete.Click           += btnDelete_Click;
                btnDelete.CssClass         = "btn";
                btnDelete.CausesValidation = false;
                btnCell.Controls.Add(btnDelete);
            }
            if (level <= 5)
            {
                Button btnAdd = new Button();
                btnAdd.ID               = "btnAdd" + subjectId;
                btnAdd.Text             = "新建";
                btnAdd.Click           += btnAdd_Click;
                btnAdd.CssClass         = "btn";
                btnAdd.CausesValidation = false;
                btnCell.Controls.Add(btnAdd);
            }
            return(subjectRow);
        }
        private void bindData()
        {
            long _id = GetAdminInfo_CCOM().User_id;

            if (_id > 0)
            {
                Model.CCOM.User_infomation user_model = new BLL.CCOM.User_infomation().GetModel(_id);
                if ((int)user_model.User_type != 1)
                {
                    JscriptMsg("只有考生才有打印报名表功能", "/AdminMetro/index.aspx", "Error");
                    return;
                }
                Model.CCOM.User_property property_model = new BLL.CCOM.User_property().GetModel(" User_id=" + _id);

                try
                {
                    int period = int.Parse(new BLL.CCOM.Period().GetModel(property_model.Period_id).Period_year);
                    this.title.Text = "中央音乐学院" + period + "年本科招生专业考试报名表";
                }
                catch
                {
                    JscriptMsg("考生信息出错", "/AdminMetro/index.aspx", "Error");
                    //Response.Redirect("");
                }

                if (user_model != null && property_model != null)
                {
                    this.name.Text      = user_model.User_realname;
                    this.id_number.Text = user_model.User_ID_number;
                    if (user_model.User_gender != null && (bool)user_model.User_gender)
                    {
                        this.gender.Text = "女";
                    }
                    else
                    {
                        this.gender.Text = "男";
                    }
                    if (user_model.User_birthday != null)
                    {
                        this.birthday.Text = ((DateTime)user_model.User_birthday).ToString("yyyyMMdd");
                    }
                    else
                    {
                        JscriptMsg("出生日期信息不全,请先完善信息再行打印", "/AdminMetro/index.aspx", "Error");
                        return;
                    }

                    var nation_model = new BLL.CCOM.Nationality().GetModel(property_model.UP_nationality);
                    if (nation_model != null)
                    {
                        this.nation.Text = nation_model.Nationality_name;
                    }
                    else
                    {
                        JscriptMsg("民族不存在", "/AdminMetro/index.aspx", "Error");
                        return;
                    }


                    var province_model = new BLL.CCOM.Province().GetModel(property_model.UP_province);
                    if (province_model != null)
                    {
                        this.birth_place.Text  = province_model.Province_name;
                        this.stu_province.Text = province_model.Province_name;
                    }
                    else
                    {
                        JscriptMsg("省份不存在,请先完善信息再行打印", "/AdminMetro/index.aspx", "Error");
                        return;
                    }

                    if (property_model.UP_high_school != null)
                    {
                        this.file_address.Text = property_model.UP_high_school;
                    }
                    else
                    {
                        JscriptMsg("高中院校信息不全,请先完善信息再行打印", "/AdminMetro/index.aspx", "Error");
                        return;
                    }


                    var politics_model = new BLL.CCOM.Politics().GetModel(property_model.UP_politics);
                    if (politics_model != null)
                    {
                        this.politics.Text = politics_model.Politics_name;
                    }
                    else
                    {
                        JscriptMsg("政治面貌不存在,请先完善信息再行打印", "/AdminMetro/index.aspx", "Error");
                        return;
                    }

                    if (property_model.UP_picture != null)
                    {
                        this.head_pic.Src = property_model.UP_picture;
                    }
                    else
                    {
                        JscriptMsg("证件照信息不全,请先完善信息再行打印", "/AdminMetro/index.aspx", "Error");
                        return;
                    }



                    var agency_model = new BLL.CCOM.Agency().GetModel(property_model.Agency_id);
                    if (agency_model != null)
                    {
                        this.major.Text = agency_model.Agency_name;
                    }
                    else
                    {
                        JscriptMsg("专业不存在,请先完善信息再行打印", "/AdminMetro/index.aspx", "Error");
                        return;
                    }

                    this.entrance_exam_number.Text = property_model.UP_CCOM_number;
                    this.stu_entrance_number.Text  = property_model.UP_CCOM_number;

                    if (property_model.UP_receiver_phone != null)
                    {
                        this.exam_phone.Text     = property_model.UP_receiver_phone;
                        this.reciever_phone.Text = property_model.UP_receiver_phone;
                    }
                    else
                    {
                        JscriptMsg("联系电话信息不全,请先完善信息再行打印", "/AdminMetro/index.aspx", "Error");
                        return;
                    }
                    if (property_model.UP_address != null)
                    {
                        this.admit_address.Text = property_model.UP_address;
                    }
                    else
                    {
                        JscriptMsg("录取通知书邮寄地址信息不全,请先完善信息再行打印", "/AdminMetro/index.aspx", "Error");
                        return;
                    }
                    if (property_model.UP_postal_code != null)
                    {
                        this.city_id.Text = property_model.UP_postal_code;
                    }
                    else
                    {
                        JscriptMsg("邮编信息不全,请先完善信息再行打印", "/AdminMetro/index.aspx", "Error");
                        return;
                    }
                    this.reciever.Text = user_model.User_realname;
                    this.stu_name.Text = user_model.User_realname;
                }
                else
                {
                    JscriptMsg("考生不存在", "/AdminMetro/index.aspx", "Error");
                    return;
                }

                //获取报考科目
                int majorId = property_model.Agency_id;
                //科目字典
                BLL.CCOM.Subject sub_bll = new BLL.CCOM.Subject();
                try
                {
                    List <Model.CCOM.Subject> subjectList = sub_bll.GetModelList("Major_Agency_id=" + majorId);
                    foreach (Model.CCOM.Subject subject in subjectList)
                    {
                        subjectDic.Add(subject.Subject_id, subject);
                    }
                }
                catch (Exception e)
                {
                    return;
                }
                root = sub_bll.GetModel("Major_Agency_id=" + majorId + "and Subject_level=0");
                foreach (Model.CCOM.Subject Cmodel in subjectDic.Values)
                {
                    if (Cmodel.Fs_id == root.Subject_id)
                    {
                        BindSubject(Cmodel, 0, true);
                    }
                }
                StringBuilder      sb        = new StringBuilder();
                Model.CCOM.Subject sub_model = null;
                int flag = 0;
                for (int i = 0; i < sub.Count; i++)
                {
                    sub_model = sub_bll.GetModel(sub[i]);
                    if (sub_model != null)
                    {
                        if (flag == 1)
                        {
                            flag = 0;
                            continue;
                        }
                        if (sub_model.Value_type == 1 && flag == 0)
                        {
                            flag = 1;
                        }
                        sb.Append("<div class=\"control-group\" style=\"margin-top:5px;\"><div class=\"line\">");
                        sb.Append("<div class=\"course_name\">");
                        sb.Append("<span>");
                        sb.Append(sub_model.Subject_title);
                        sb.Append("</span>");
                        sb.Append("</div>");
                        sb.Append("<div class=\"exam_form\">");
                        sb.Append("<span>");
                        if (sub_model.Subject_type != null && (bool)sub_model.Subject_type)
                        {
                            sb.Append("面试");
                        }
                        else
                        {
                            sb.Append("笔试");
                        }
                        sb.Append("</span>");
                        sb.Append("</div>");


                        Label chapter = newChapterLabel(_id, sub[i]);
                        sb.Append("<div class=\"exam_song\">");
                        sb.Append(chapter.Text.ToString());
                        sb.Append("</div>");

                        sb.Append("</div></div><br>");
                        //sb.Append("<div class=\"line_decration\"></div>");
                    }
                }
                this.examination_course.InnerHtml = sb.ToString();
            }
        }
        protected void bindUserInfo()
        {
            //int[] margin = {1,1,2,2,2,3,3,4};
            long _id = GetAdminInfo_CCOM().User_id;
            var user_model = new BLL.CCOM.User_infomation().GetModel(_id);
            if ((int)user_model.User_type != 1)
            {
                JscriptMsg("只有考生才有打印准考证功能", "/AdminMetro/index.aspx", "Error");
                return;
            }
            var property_model = new BLL.CCOM.User_property().GetModel(" User_id=" + _id);
            if (property_model != null)
            {
                if (property_model.UP_picture != null && property_model.UP_picture != "")
                {
                    if (!property_model.UP_picture.StartsWith("http"))
                    {
                        this.stu_pic.Src = DataDic.FILE_URL + property_model.UP_picture;
                    }
                    else
                    {
                        this.stu_pic.Src = property_model.UP_picture;
                    }
                }
                else
                {
                    this.stu_pic.Src = "/admin/images/default_user_avatar.gif";
                }
                try
                {
                    int period = int.Parse(new BLL.CCOM.Period().GetModel(property_model.Period_id).Period_year);
                    this.tit.Text = "中央音乐学院本科招生" + period + "年专业考试准考证";
                }
                catch
                {
                    JscriptMsg("考生信息出错", "/AdminMetro/index.aspx", "Error");
                    //Response.Redirect("");
                }
                
                this.print_time.Text = "打印时间:" + DateTime.Now.ToString("yyyy年MM月dd日");
                //var user_model = new BLL.CCOM.User_infomation().GetModel(_id);
                this.stu_name.Text = user_model.User_realname;
                this.addmission_number.Text = property_model.UP_CCOM_number;
                this.ID_number.Text = user_model.User_ID_number;
                //this.qrcode.Src = "QrCode.ashx?data=" + DESEncrypt.Encrypt(property_model.UP_CCOM_number);
                if (property_model.Agency_id >0)
                {
                    var angency_model = new BLL.CCOM.Agency().GetModel(property_model.Agency_id);
                    if (angency_model != null)
                    {
                        this.major.Text = angency_model.Agency_name;
                    }

                    //获取报考科目
                    int majorId = property_model.Agency_id;
                    //科目字典
                    BLL.CCOM.Subject sub_bll = new BLL.CCOM.Subject();
                    try
                    {
                        List<Model.CCOM.Subject> subjectList = sub_bll.GetModelList("Major_Agency_id=" + majorId);
                        foreach (Model.CCOM.Subject subject in subjectList)
                        {
                            subjectDic.Add(subject.Subject_id, subject);
                        }
                    }
                    catch (Exception e)
                    {
                        return;
                    }
                    root = sub_bll.GetModel("Major_Agency_id=" + majorId + "and Subject_level=0");
                    foreach (Model.CCOM.Subject Cmodel in subjectDic.Values)
                    {
                        if (Cmodel.Fs_id == root.Subject_id)
                        {
                            BindSubject(Cmodel,0, true);
                        }
                    }


                    //获取已排考科目
                    //var exam_list = new BLL.CCOM.Examination_arrangement_detail().GetModelList(" User_id=" + GetAdminInfo_CCOM().User_id);
                    //if (exam_list != null && exam_list.Count>0)
                    //{
                    //    var bll = new BLL.CCOM.Examination_subject();
                    //    Model.CCOM.Examination_subject model = null;
                    //    for(int i=0;i<exam_list.Count;i++)
                    //    {
                    //        model = bll.GetModel(" Ea_id="+exam_list[i].Ea_id);

                    //    }
                    //}
                    //else//未有排考信息
                    //{
                    //    JscriptMsg("尚未排考完成,请等候排考结束再行打印!", "/AdminMetro/index.aspx", "Error");
                    //    return;
                    //}



                    long user_id = GetAdminInfo_CCOM().User_id;
                    int flag = 0;//记录该场考试是否已排该考生
                    StringBuilder sb = new StringBuilder();
                    BLL.CCOM.Examination_subject exam_sub_bll = new BLL.CCOM.Examination_subject();
                    BLL.CCOM.Examination_arrangement_detail exam_detail_bll = new BLL.CCOM.Examination_arrangement_detail();

                    int single = 0; //单选只输出一次
                    for (int i = 0; i < sub.Count; i++)
                    {
                        var exam_sub_model_list = exam_sub_bll.GetModelList(" Esn_id=" + sub[i]);
                        if (exam_sub_model_list != null)
                        {
                            for (int j = 0; j < exam_sub_model_list.Count; j++)
                            {
                                if (single == 1)
                                {
                                    single = 0;
                                    continue;
                                }
                                if (new BLL.CCOM.Subject().GetModel(sub[i]).Value_type == 1 && single == 0)
                                {
                                    single = 1;
                                }

                                flag = 0;
                                var detail_model_list = exam_detail_bll.GetModelList(" Ea_id=" + exam_sub_model_list[j].Ea_id);
                                for (int k = 0; k < detail_model_list.Count; k++)
                                {
                                    if (detail_model_list[k].User_id == user_id)
                                    {
                                        
                                        flag = 1;
                                        var model = new BLL.CCOM.Examination_arrangement().GetModel(" Ea_id=" + detail_model_list[k].Ea_id);
                                        string st_time = model.Ea_starttime.ToString("MM月dd日hh:mm");
                                        //st_time = st_time.Substring(0, st_time.Length - 6);
                                        string end_time = ((DateTime)model.Ea_endtime).ToString("hh:mm");
                                        var room = new BLL.CCOM.Examination_room().GetModel(model.Ea_room);
                                        
                                        sb.Append("<div class=\"exam_line\">");
                                        sb.Append("<div class=\"course\">");
                                        sb.Append("<span>");
                                        sb.Append(model.Ea_name);
                                        sb.Append("</span>");
                                        sb.Append("</div>");
                                        sb.Append("<div class=\"arrange\">");
                                        sb.Append("<span>");
                                        sb.Append(st_time+"-"+end_time);
                                        sb.Append("</span>");
                                        sb.Append("<br />");
                                        sb.Append("<span >");
                                        sb.Append("考场:"+room.Er_building+room.Er_room);
                                        if (model.Ea_restroom != null)
                                        {
                                            var rest_room = new BLL.CCOM.Examination_room().GetModel((int)model.Ea_restroom);
                                            sb.Append(" 候考场:" + room.Er_building +    room.Er_room);
                                        }
                                        sb.Append("</span>");
                                        sb.Append(" </div>");
                                        sb.Append(" </div>");

                                        break;
                                    }
                                }
                                if (flag == 0)//该科目尚未排考
                                {

                                }
                            }
                        }
                    }
                    this.exam_info.InnerHtml=sb.ToString();
                }
                if (user_model.User_gender != null)
                {
                    if ((bool)user_model.User_gender)
                    {
                        this.gender.Text = "女";
                    }
                    else
                    {
                        this.gender.Text = "男";
                    }
                }
            }
            else
            {
                JscriptMsg("考生不存在", "", "Error");
                return;
            }
        }
Esempio n. 19
0
        protected TableRow newSubjectRow(Model.CCOM.Subject model)
        {
            int level     = model.Subject_level;
            int subjectId = model.Subject_id;
            //当前项TableRow
            TableRow  subjectRow = new TableRow();
            TableCell titleCell  = new TableCell();

            subjectRow.Cells.Add(titleCell);
            //空格
            Label  span  = new Label();
            string blank = "";

            for (int i = 0; i < model.Subject_level; i++)
            {
                blank += "&nbsp;&nbsp;";
            }
            span.Text = blank;
            titleCell.Controls.Add(span);
            //加减号
            ImageButton symbol = new ImageButton();

            symbol.ID       = "symbol" + subjectId;
            symbol.ImageUrl = "../../../images/exam/minus.png";
            symbol.Click   += symbol_Click;
            symbol.Width    = 10;
            titleCell.Controls.Add(symbol);

            TableCell valueTypeCell = new TableCell();

            valueTypeCell.HorizontalAlign = HorizontalAlign.Center;
            subjectRow.Cells.Add(valueTypeCell);
            TableCell subjectTypeCell = new TableCell();

            subjectTypeCell.HorizontalAlign = HorizontalAlign.Center;
            subjectRow.Cells.Add(subjectTypeCell);
            TableCell manageAgencyCell = new TableCell();

            manageAgencyCell.HorizontalAlign = HorizontalAlign.Center;
            subjectRow.Cells.Add(manageAgencyCell);
            TableCell weightCell = new TableCell();

            weightCell.HorizontalAlign = HorizontalAlign.Center;
            subjectRow.Cells.Add(weightCell);
            TableCell descriptionCell = new TableCell();

            descriptionCell.HorizontalAlign = HorizontalAlign.Center;
            subjectRow.Cells.Add(descriptionCell);
            TableCell btnCell = new TableCell();

            btnCell.HorizontalAlign = HorizontalAlign.Center;
            subjectRow.Cells.Add(btnCell);
            HiddenField attachRow = new HiddenField();

            attachRow.ID = "attachRow" + subjectId;
            btnCell.Controls.Add(attachRow);
            if (level == 0)
            {
                //标题
                Label title = new Label();
                title.ID   = "title" + subjectId;
                title.Text = ddlMajor.SelectedItem.Text + "专业科目";
                titleCell.Controls.Add(title);
            }
            else
            {
                //标题
                TextBox title = new TextBox();
                title.ID   = "title" + subjectId;
                title.Text = model.Subject_title;
                title.Attributes.Add("OnFocus", "if(this.value=='请输入标题') {this.value=''}");
                title.Attributes.Add("OnBlur", "if(this.value==''){this.value='请输入标题'}");
                title.TextChanged += title_TextChanged;
                title.AutoPostBack = true;
                titleCell.Controls.Add(title);
                //值方式
                DropDownList valueType = new DropDownList();
                valueType.ID = "valueType" + subjectId;
                if (model.Subject_level <= 5)
                {
                    valueType.Items.Add(new ListItem("多项", "0"));
                    valueType.Items.Add(new ListItem("单选", "1"));
                    valueType.Items.Add(new ListItem("多选", "2"));
                }
                valueType.Items.Add(new ListItem("文本", "3"));
                valueType.Items.Add(new ListItem("不填", "4"));
                valueType.SelectedValue         = model.Value_type.ToString();
                valueType.Width                 = 70;
                valueType.SelectedIndexChanged += valueType_SelectedIndexChanged;
                valueType.AutoPostBack          = true;
                valueTypeCell.Controls.Add(valueType);
                Label label1 = new Label();
                label1.ID      = "label1" + subjectId;
                label1.Text    = "&nbsp;";
                label1.Visible = false;
                valueTypeCell.Controls.Add(label1);
                TextBox valueCount = new TextBox();
                valueCount.ID           = "valueCount" + subjectId;
                valueCount.Text         = "2";
                valueCount.Width        = 20;
                valueCount.TextChanged += valueCount_TextChanged;
                valueCount.Visible      = false;
                valueTypeCell.Controls.Add(valueCount);
                Label label2 = new Label();
                label2.ID      = "label2" + subjectId;
                label2.Text    = "项";
                label2.Visible = false;
                valueTypeCell.Controls.Add(label2);
                if (level == 1 || level == 2)
                {
                    if (level == 2)
                    {
                        //笔试/面试
                        DropDownList subjectType = new DropDownList();
                        subjectType.ID = "subjectType" + subjectId;
                        subjectType.Items.Insert(0, "笔试");
                        subjectType.Items.Insert(1, "面试");
                        subjectType.Width                 = 70;
                        subjectType.SelectedIndex         = (Convert.ToBoolean(model.Subject_type) ? 1 : 0);
                        subjectType.SelectedIndexChanged += subjectType_SelectedIndexChanged;
                        subjectType.AutoPostBack          = true;
                        subjectTypeCell.Controls.Add(subjectType);
                        DropDownList manageAgency = new DropDownList();
                        manageAgency.ID = "manageAgency" + subjectId;
                        BindAgency(manageAgency);
                        manageAgency.Width                 = 140;
                        manageAgency.SelectedValue         = model.Manage_Agency_id.ToString();
                        manageAgency.SelectedIndexChanged += manageAgency_SelectedIndexChanged;
                        manageAgency.AutoPostBack          = true;
                        manageAgencyCell.Controls.Add(manageAgency);
                    }
                    //权值
                    TextBox weight = new TextBox();
                    weight.ID           = "weight" + subjectId;
                    weight.Width        = 30;
                    weight.Text         = model.Subject_weight.ToString();
                    weight.TextChanged += weight_TextChanged;
                    weight.AutoPostBack = true;
                    weightCell.Controls.Add(weight);
                }
                TextBox description = new TextBox();
                description.ID           = "description" + subjectId;
                description.TextMode     = TextBoxMode.MultiLine;
                description.Rows         = 2;
                description.Width        = 150;
                description.Text         = model.Subject_description.ToString();
                description.TextChanged += description_TextChanged;
                description.AutoPostBack = true;
                descriptionCell.Controls.Add(description);
            }
            //按钮
            Button btnSave = new Button();

            btnSave.ID       = "btnSave" + subjectId;
            btnSave.Text     = "保存";
            btnSave.Click   += btnSave_Click;
            btnSave.CssClass = "btn";
            btnCell.Controls.Add(btnSave);
            if (level != 0)
            {
                Button btnDelete = new Button();
                btnDelete.ID       = "btnDelete" + subjectId;
                btnDelete.Text     = "删除";
                btnDelete.Click   += btnDelete_Click;
                btnDelete.CssClass = "btn";
                btnCell.Controls.Add(btnDelete);
            }
            if (level <= 5)
            {
                Button btnAdd = new Button();
                btnAdd.ID       = "btnAdd" + subjectId;
                btnAdd.Text     = "新建";
                btnAdd.Click   += btnAdd_Click;
                btnAdd.CssClass = "btn";
                btnCell.Controls.Add(btnAdd);
            }
            return(subjectRow);
        }
Esempio n. 20
0
        //children:0表示不是子节点,超过0表示第几个子节点
        protected void showSubject(Model.CCOM.Subject model, int children, bool isShow)
        {
            int   subjectId    = model.Subject_id;
            Panel subjectPanel = null;

            if (children <= 0)
            {
                subjectPanel = (Panel)this.divControls.FindControl("subjectPanel" + subjectId);
                if (model.Value_type == 0)
                {
                    //多项类型,往下Bind
                    int i = 0;
                    foreach (Model.CCOM.Subject Cmodel in subjectDic.Values)
                    {
                        if (Cmodel.Fs_id == model.Subject_id)
                        {
                            showSubject(Cmodel, -++i, isShow);
                        }
                    }
                }
                else if (model.Value_type == 1)
                {
                    //单选,绑一个
                    showSubject(model, 1, isShow);
                }
                else if (model.Value_type == 2)
                {
                    //多选类型,有几个绑几个
                    for (int i = 1; i <= model.Value_count; i++)
                    {
                        showSubject(model, i, isShow);
                    }
                }
            }
            else
            {
                subjectPanel = (Panel)this.divControls.FindControl("subjectPanel" + model.Subject_id + "children" + children);
                DropDownList title       = (DropDownList)subjectPanel.FindControl("title" + model.Subject_id + "children" + children);
                HiddenField  oldTitle    = (HiddenField)subjectPanel.FindControl("oldTitle" + model.Subject_id + "children" + children);
                Label        description = (Label)subjectPanel.FindControl("description" + model.Subject_id + "children" + children);
                if (title.Text != oldTitle.Value)
                {
                    if (oldTitle.Value != "#")
                    {
                        foreach (Model.CCOM.Subject Cmodel in subjectDic.Values)
                        {
                            if (Cmodel.Fs_id == Convert.ToInt32(oldTitle.Value))
                            {
                                showSubject(Cmodel, 0, false);
                            }
                        }
                    }
                    if (title.Text != "#")
                    {
                        foreach (Model.CCOM.Subject Cmodel in subjectDic.Values)
                        {
                            if (Cmodel.Fs_id == Convert.ToInt32(title.Text))
                            {
                                showSubject(Cmodel, 0, true);
                            }
                        }
                        if (subjectDic[Convert.ToInt32(title.SelectedValue)].Value_type == 3)
                        {
                            subjectPanel.FindControl("value" + model.Subject_id + "children" + children).Visible = true;
                            ((RequiredFieldValidator)subjectPanel.FindControl("valueValidator" + model.Subject_id + "children" + children)).Enabled = true;
                            ((CustomValidator)subjectPanel.FindControl("CvalueValidator" + model.Subject_id + "children" + children)).Enabled       = true;
                        }
                        else
                        {
                            subjectPanel.FindControl("value" + model.Subject_id + "children" + children).Visible = false;
                            ((RequiredFieldValidator)subjectPanel.FindControl("valueValidator" + model.Subject_id + "children" + children)).Enabled = false;
                            ((CustomValidator)subjectPanel.FindControl("CvalueValidator" + model.Subject_id + "children" + children)).Enabled       = false;
                        }
                        description.Text = ":" + model.Subject_description;
                    }
                    else
                    {
                        subjectPanel.FindControl("value" + model.Subject_id + "children" + children).Visible = false;
                        ((RequiredFieldValidator)subjectPanel.FindControl("valueValidator" + model.Subject_id + "children" + children)).Enabled = false;
                        ((CustomValidator)subjectPanel.FindControl("CvalueValidator" + model.Subject_id + "children" + children)).Enabled       = false;
                        description.Text = "";
                    }
                    oldTitle.Value = title.Text;
                }
            }
            subjectPanel.Visible = isShow;
        }
Esempio n. 21
0
        //通过subjectRow存储数据
        //temp表示是不是临时存储
        //返回为空正确,否则错误语句
        protected String saveRow(TableRow subjectRow, bool temp)
        {
            //存自己
            BLL.CCOM.Subject bll = new BLL.CCOM.Subject();
            int subjectId        = Convert.ToInt32(subjectRow.ID.Replace("subjectRow", ""));

            Model.CCOM.Subject        model       = subjectDic[subjectId];
            List <Model.CCOM.Subject> subjectList = bll.GetModelList("Fs_id=" + subjectId);

            if (model.Subject_level != 0)
            {
                TextBox title = (TextBox)subjectRow.FindControl("title" + subjectId);
                if (title.Text == "请输入标题")
                {
                    ((Button)subjectRow.FindControl("btnSave" + subjectId)).CssClass = "btn btn-danger";
                    return("请输入标题");
                }
                if (Tools.CheckParams(title.Text))
                {
                    ((Button)subjectRow.FindControl("btnSave" + subjectId)).CssClass = "btn btn-danger";
                    return("请勿输入非法字符");
                }
                model.Subject_title = title.Text;
                DropDownList valueType = (DropDownList)subjectRow.FindControl("valueType" + subjectId);
                model.Value_type = Convert.ToInt32(valueType.SelectedValue);
                if (model.Value_type <= 2 && subjectList.Count == 0)
                {
                    ((Button)subjectRow.FindControl("btnSave" + subjectId)).CssClass = "btn btn-danger";
                    return("缺少子科目");
                }
                if (model.Value_type <= 2 && subjectDic[model.Fs_id].Value_type == 2)
                {
                    ((Button)subjectRow.FindControl("btnSave" + subjectId)).CssClass = "btn btn-danger";
                    return("多选子项只可以为文本或不填");
                }
                if (model.Value_type == 2)
                {
                    TextBox valueCount = (TextBox)subjectRow.FindControl("valueCount" + subjectId);
                    try
                    {
                        model.Value_count = Convert.ToInt32(valueCount.Text);
                    }
                    catch (Exception e)
                    {
                        ((Button)subjectRow.FindControl("btnSave" + subjectId)).CssClass = "btn btn-danger";
                        return("项数请输入整数");
                    }
                    if (model.Value_count <= 1)
                    {
                        ((Button)subjectRow.FindControl("btnSave" + subjectId)).CssClass = "btn btn-danger";
                        return("项数请输入大于1的数");
                    }
                }
                //特殊项
                if (model.Subject_level == 1 || model.Subject_level == 2)
                {
                    if (model.Subject_level == 2)
                    {
                        DropDownList subjectType = (DropDownList)subjectRow.FindControl("subjectType" + subjectId);
                        model.Subject_type = subjectType.SelectedIndex == 1;
                        DropDownList manageAgency = (DropDownList)subjectRow.FindControl("manageAgency" + subjectId);
                        model.Manage_Agency_id = Convert.ToInt32(manageAgency.SelectedValue);
                    }
                    TextBox weight = (TextBox)subjectRow.FindControl("weight" + subjectId);
                    try
                    {
                        model.Subject_weight = Convert.ToDecimal(weight.Text);
                    }
                    catch (Exception e)
                    {
                        ((Button)subjectRow.FindControl("btnSave" + subjectId)).CssClass = "btn btn-danger";
                        return("权值请填写数字");
                    }
                }
                TextBox description = (TextBox)subjectRow.FindControl("description" + subjectId);
                if (Tools.CheckParams(title.Text))
                {
                    ((Button)subjectRow.FindControl("btnSave" + subjectId)).CssClass = "btn btn-danger";
                    return("请勿输入非法字符");
                }
                model.Subject_description = description.Text;
                try
                {
                    bll.Update(model);
                }
                catch (Exception e)
                {
                    ((Button)subjectRow.FindControl("btnSave" + subjectId)).CssClass = "btn btn-danger";
                    return("请检查输入");
                }
            }
            //临时存仍为修改状态,无子节点
            if (!temp)
            {
                //存子节点
                foreach (Model.CCOM.Subject Cmodel in subjectList)
                {
                    int    childrenId = Cmodel.Subject_id;
                    String error      = saveRow((TableRow)this.subjectTable.FindControl("subjectRow" + childrenId), false);
                    if (error != "")
                    {
                        return(error);
                    }
                }
            }
            ((Button)subjectRow.FindControl("btnSave" + subjectId)).CssClass = "btn";
            return("");
        }
Esempio n. 22
0
        protected Panel newSubjectPanel(Model.CCOM.Subject model, int children)
        {
            int level     = model.Subject_level;
            int subjectId = model.Subject_id;
            //当前项Panel
            Panel subjectPanel = new Panel();

            subjectPanel.Height = 35;
            Label numLabel = new Label();

            subjectPanel.Controls.Add(numLabel);
            //空格和数字
            string blank = "";

            for (int i = 0; i < model.Subject_level; i++)
            {
                blank += "&nbsp;&nbsp;";
            }
            if (children > 0)
            {
                blank        += "&nbsp;&nbsp;";
                numLabel.Text = blank + levelCountValue[model.Subject_level - 1, Math.Abs(children) - 1];
            }
            else
            {
                numLabel.Text = blank + levelCountValue[model.Subject_level - 2, Math.Abs(children) - 1];
            }

            //标题
            Label subjectLabel = new Label();

            if (children > 0)
            {
                DropDownList title = new DropDownList();
                title.ID = "title" + subjectId + "children" + children;
                title.Items.Add(new ListItem("请选择一项", "#"));
                foreach (Model.CCOM.Subject Cmodel in subjectDic.Values)
                {
                    if (Cmodel.Fs_id == subjectId)
                    {
                        ListItem item = new ListItem();
                        item.Value = Cmodel.Subject_id.ToString();
                        item.Text  = Cmodel.Subject_title;
                        title.Items.Add(item);
                    }
                }
                title.SelectedIndex         = 0;
                title.SelectedIndexChanged += title_SelectedIndexChanged;
                title.AutoPostBack          = true;
                subjectPanel.Controls.Add(title);

                HiddenField oldTitle = new HiddenField();
                oldTitle.ID    = "oldTitle" + subjectId + "children" + children;
                oldTitle.Value = title.SelectedValue;
                subjectPanel.Controls.Add(oldTitle);

                RequiredFieldValidator titleValidator = new RequiredFieldValidator();
                titleValidator.ControlToValidate = "title" + subjectId + "children" + children;
                titleValidator.ID           = "titleValidator" + subjectId + "children" + children;
                titleValidator.Display      = ValidatorDisplay.Dynamic;
                titleValidator.ErrorMessage = "请选择一项考试项目";
                titleValidator.InitialValue = "#";
                subjectPanel.Controls.Add(titleValidator);
            }
            else
            {
                subjectLabel.Text += model.Subject_title;
                if (model.Subject_level == 2)
                {
                    subjectLabel.Font.Bold = true;
                }
            }
            if (level == 2)
            {
                //笔试/面试
                subjectLabel.Text += "(" + ((bool)model.Subject_type ? "面试" : "笔试") + ")";
            }
            subjectLabel.Text += "&nbsp";
            subjectPanel.Controls.Add(subjectLabel);
            //文本
            TextBox value = new TextBox();

            value.Text = "请输入曲目";
            value.Attributes.Add("OnFocus", "if(this.value=='请输入曲目') {this.value=''}");
            value.Attributes.Add("OnBlur", "if(this.value==''){this.value='请输入曲目'}");
            subjectPanel.Controls.Add(value);
            RequiredFieldValidator valueValidator = new RequiredFieldValidator();

            valueValidator.Display      = ValidatorDisplay.Dynamic;
            valueValidator.ErrorMessage = "请输入曲目";
            valueValidator.InitialValue = "请输入曲目";
            CustomValidator CvalueValidator = new CustomValidator();

            CvalueValidator.Display         = ValidatorDisplay.Dynamic;
            CvalueValidator.ServerValidate += CvalueValidator_ServerValidate;
            CvalueValidator.ErrorMessage    = "请勿输入非法字符";
            if (children > 0)
            {
                value.ID = "value" + model.Subject_id + "children" + children;
                valueValidator.ControlToValidate = "value" + model.Subject_id + "children" + children;
                valueValidator.ID = "valueValidator" + model.Subject_id + "children" + children;
                CvalueValidator.ControlToValidate = "value" + model.Subject_id + "children" + children;
                CvalueValidator.ID = "CvalueValidator" + model.Subject_id + "children" + children;
            }
            else
            {
                value.ID = "value" + model.Subject_id;
                valueValidator.ControlToValidate = "value" + model.Subject_id;
                valueValidator.ID = "valueValidator" + model.Subject_id;
                CvalueValidator.ControlToValidate = "value" + model.Subject_id;
                CvalueValidator.ID = "CvalueValidator" + model.Subject_id;
            }
            subjectPanel.Controls.Add(valueValidator);
            subjectPanel.Controls.Add(CvalueValidator);


            if (model.Value_type != 3)
            {
                valueValidator.Enabled  = false;
                CvalueValidator.Enabled = false;
                value.Visible           = false;
            }

            Label description = new Label();

            description.Text        = ":" + model.Subject_description.ToString();
            description.Font.Italic = true;
            subjectPanel.Controls.Add(description);
            if (children > 0)
            {
                description.ID = "description" + model.Subject_id + "children" + children;
            }
            else
            {
                description.ID = "description" + model.Subject_id;
            }

            return(subjectPanel);
        }
Esempio n. 23
0
        protected void BindAllSubject()
        {
            BLL.CCOM.Subject bll = new BLL.CCOM.Subject();
            try
            {
                List <Model.CCOM.Subject> subjectList = bll.GetModelList("Major_Agency_id=" + Convert.ToInt32(this.ddlMajor.SelectedItem.Value));
                foreach (Model.CCOM.Subject subject in subjectList)
                {
                    subjectDic.Add(subject.Subject_id, subject);
                }
            }
            catch (Exception e)
            {
                return;
            }
            //添加表头
            TableHeaderRow header = new TableHeaderRow();

            this.subjectTable.Controls.Add(header);
            TableHeaderCell headerCell1 = new TableHeaderCell();

            headerCell1.Text = "标题";
            headerCell1.Attributes.Add("width", "26%");
            header.Cells.Add(headerCell1);
            TableHeaderCell headerCell2 = new TableHeaderCell();

            headerCell2.Text = "值类型";
            headerCell2.Attributes.Add("width", "14%");
            header.Cells.Add(headerCell2);
            TableHeaderCell headerCell3 = new TableHeaderCell();

            headerCell3.Text = "考试方式";
            headerCell3.Attributes.Add("width", "8%");
            header.Cells.Add(headerCell3);
            TableHeaderCell headerCell4 = new TableHeaderCell();

            headerCell4.Text = "管理机构";
            headerCell4.Attributes.Add("width", "14%");
            header.Cells.Add(headerCell4);
            TableHeaderCell headerCell5 = new TableHeaderCell();

            headerCell5.Text = "权值";
            headerCell5.Attributes.Add("width", "6%");
            header.Cells.Add(headerCell5);
            TableHeaderCell headerCell6 = new TableHeaderCell();

            headerCell6.Text = "描述";
            headerCell6.Attributes.Add("width", "16%");
            header.Cells.Add(headerCell6);
            TableHeaderCell headerCell7 = new TableHeaderCell();

            headerCell7.Text = "操作";
            headerCell7.Attributes.Add("width", "16%");
            header.Cells.Add(headerCell7);
            BLL.CCOM.Period pbll     = new BLL.CCOM.Period();
            var             pmodel   = pbll.GetModel("Period_state=1");
            int             periodId = pmodel.Period_id;

            if (this.ddlMajor.SelectedItem.Value == "#")
            {
                this.subjectTable.Controls.Clear();
                return;
            }
            int majorId = Convert.ToInt32(this.ddlMajor.SelectedItem.Value);

            root = bll.GetModel("Major_Agency_id=" + majorId + "and Subject_level=0");
            if (root == null)
            {
                Model.CCOM.Subject model = new Model.CCOM.Subject();
                model.Major_Agency_id = majorId;
                model.Period_id       = periodId;
                model.Fs_id           = 0;
                model.Subject_weight  = 0;
                model.Value_type      = 0;
                model.Subject_level   = 0;
                model.Subject_title   = "";
                int Fsid = bll.Add(model);
                root = bll.GetModel(Fsid);
            }
            BindSubject(root);
        }
Esempio n. 24
0
        //initial 是否为第一次绑定
        protected int BindSubject(Model.CCOM.Subject model, bool isShow, bool initial, int style)
        {
            int      attachRowValue = 0;
            int      subjectId      = model.Subject_id;
            TableRow subjectRow     = newSubjectRow(model);

            subjectRow.ID      = "subjectRow" + subjectId;
            subjectRow.Visible = isShow;
            switch (style)
            {
            case 0: subjectRow.BackColor = Color.LightGray; break;

            case 1: subjectRow.BackColor = Color.LightSteelBlue; break;

            case 2: subjectRow.BackColor = Color.LightPink; break;

            case 3: subjectRow.BackColor = Color.LightGreen; break;
            }
            this.subjectTable.Rows.Add(subjectRow);
            DropDownList value_type = (DropDownList)subjectRow.FindControl("valueType" + subjectId);
            int          value      = 5;

            if ((!initial) && value_type != null)
            {
                value = Convert.ToInt32(value_type.SelectedValue);
            }
            else
            {
                value = model.Value_type;
            }
            //有值类型,往下Bind
            bool flag       = true;
            int  childrenId = -1;

            foreach (Model.CCOM.Subject Cmodel in subjectDic.Values)
            {
                if (Cmodel.Fs_id == model.Subject_id)
                {
                    childrenId++;
                    if (value <= 2)
                    {
                        attachRowValue = BindSubject(Cmodel, isShow, initial, style == 0 ? childrenId % 3 + 1 : style);
                        if (attachRowValue != 0)
                        {
                            flag = false;
                        }
                    }
                    else
                    {
                        if (initial)
                        {
                            //第一次读取也不会出现,中途关闭产物。删除
                            BLL.CCOM.Subject bll = new BLL.CCOM.Subject();
                            bll.Delete(Cmodel.Subject_id);
                            //subjectDic.Remove(Cmodel.Subject_id);
                        }
                        else
                        {
                            attachRowValue = BindSubject(Cmodel, false, initial, style == 0 ? childrenId % 3 + 1 : style);
                            if (attachRowValue != 0)
                            {
                                flag = false;
                            }
                        }
                    }
                }
            }
            if (flag)
            {
                attachRowValue = subjectTable.Rows.GetRowIndex(subjectRow);
            }
            if (value > 2)
            {
                if (subjectRow.FindControl("btnAdd" + model.Subject_id) != null)
                {
                    subjectRow.FindControl("btnAdd" + model.Subject_id).Visible = false;
                }
            }
            if (value == 2)
            {
                subjectRow.FindControl("valueCount" + model.Subject_id).Visible = true;
                subjectRow.FindControl("Label1" + model.Subject_id).Visible     = true;
                subjectRow.FindControl("Label2" + model.Subject_id).Visible     = true;
                subjectRow.FindControl("btnValueCountUp" + subjectId).Visible   = true;
                subjectRow.FindControl("btnValueCountDown" + subjectId).Visible = true;
            }
            HiddenField attachRow = (HiddenField)subjectRow.FindControl("attachRow" + subjectId);

            attachRow.Value = attachRowValue.ToString();

            return(attachRowValue);
        }