protected void DataBinds(int ID)
        {
            LabMS.BLL.CourseOutLine couOutLin = new LabMS.BLL.CourseOutLine();
            LabMS.Model.CourseOutLine couOutLinModel = new LabMS.Model.CourseOutLine();

            couOutLinModel = couOutLin.GetModel(ID);
            try
            {
                tb_Submitter.Text = couOutLinModel.COutLine_Submiter;
                tb_Time.Text = string.Format("{0:d}", couOutLinModel.COutLine_SubmitTime);
                tb_CourseName.Text = couOutLinModel.COutLine_Course;
                tb_CourseCode.Text = couOutLinModel.COutLine_CourseCode;
                tb_KeyWord.Text = couOutLinModel.COutLine_KeyWord;
                tb_Content.Text = couOutLinModel.COutLine_Content.Replace("\r\n", "<br/>");
                tb_CourseID.Text = couOutLinModel.COutLine_CourseID.ToString();
                AttachID.Value = couOutLinModel.COutLine_Attach.ToString();
                if (couOutLinModel.COutLine_Attach == null)
                {
                    a1.Visible = false;
                    AttachmentName.Visible = false;
                    IsDelCB.Checked = true;
                    fp_Attachment.Attributes.Add("style", "display:block");
                }
                else
                {
                    AttachmentName.Text = GetAttachName(int.Parse(couOutLinModel.COutLine_Attach.ToString()));
                }
            }
            catch
            {
                ERRLbl.Text = "系统异常,参数不合法!";
                ERRLbl.Visible = true;
                ModifyBtn.Visible = false;
            }
        }
        protected void Modify_Click(object sender, EventArgs e)
        {
            #region 验证
            if (tb_KeyWord.Text.Equals(""))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "关键字不能为空!");
                return;
            }
            if (tb_Content.Text.Equals(""))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "大纲内容不能为空!");
                return;
            }
            #endregion
            LabMS.BLL.CourseOutLine OutLine = new LabMS.BLL.CourseOutLine();
            LabMS.Model.CourseOutLine model = new LabMS.Model.CourseOutLine();
            model.COutLine_Submiter = tb_Submitter.Text;
            model.COutLine_SubmitTime = DateTime.Parse(tb_Time.Text.Trim());
            model.COutLine_KeyWord = tb_KeyWord.Text.Trim();
            model.COutLine_CourseID = Convert.ToInt32(tb_CourseID.Text.Trim());
            model.COutLine_Course = tb_CourseName.Text;
            model.COutLine_CourseCode = tb_CourseCode.Text;
            model.COutLine_Content = tb_Content.Text;

            if (IsDelCB.Checked)
            {
                int AttachIDTemp=UpLoadFile();
                if (AttachIDTemp == 0 || AttachIDTemp == -1)
                {
                    return;
                }
                else
                {
                    model.COutLine_Attach = AttachIDTemp;
                }
            }
            else
            {
                model.COutLine_Attach = int.Parse(AttachID.Value);
            }
            model.ID = int.Parse(CouOutLinID.Value);
            OutLine.Update(model);
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "<script type='text/javascript'>alert('更新成功!');window.location.href='CourseOutLinePreview.aspx"+model.ID+"';</script>");
        }
Beispiel #3
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public LabMS.Model.CourseOutLine GetModel(int ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 ID,COutLine_SubmitTime,COutLine_Submiter,COutLine_CourseID,COutLine_Course,COutLine_CourseCode,COutLine_KeyWord,COutLine_Content,COutLine_Attach from CourseOutLine ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters = {
                    new SqlParameter("@ID", SqlDbType.Int,4)};
            parameters[0].Value = ID;

            LabMS.Model.CourseOutLine model=new LabMS.Model.CourseOutLine();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                if(ds.Tables[0].Rows[0]["ID"].ToString()!="")
                {
                    model.ID=int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if(ds.Tables[0].Rows[0]["COutLine_SubmitTime"].ToString()!="")
                {
                    model.COutLine_SubmitTime=DateTime.Parse(ds.Tables[0].Rows[0]["COutLine_SubmitTime"].ToString());
                }
                model.COutLine_Submiter=ds.Tables[0].Rows[0]["COutLine_Submiter"].ToString();
                if(ds.Tables[0].Rows[0]["COutLine_CourseID"].ToString()!="")
                {
                    model.COutLine_CourseID=int.Parse(ds.Tables[0].Rows[0]["COutLine_CourseID"].ToString());
                }
                model.COutLine_Course=ds.Tables[0].Rows[0]["COutLine_Course"].ToString();
                model.COutLine_CourseCode=ds.Tables[0].Rows[0]["COutLine_CourseCode"].ToString();
                model.COutLine_KeyWord=ds.Tables[0].Rows[0]["COutLine_KeyWord"].ToString();
                model.COutLine_Content=ds.Tables[0].Rows[0]["COutLine_Content"].ToString();
                if(ds.Tables[0].Rows[0]["COutLine_Attach"].ToString()!="")
                {
                    model.COutLine_Attach=int.Parse(ds.Tables[0].Rows[0]["COutLine_Attach"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }
        protected void Save_Click(object sender, EventArgs e)
        {
            LabMS.BLL.CourseOutLine OutLine = new LabMS.BLL.CourseOutLine();
            List<LabMS.Model.CourseOutLine> outlinelist = new List<LabMS.Model.CourseOutLine>();
            LabMS.Model.CourseOutLine model = new LabMS.Model.CourseOutLine();

            #region ��֤

            int TempID=0;
            if (!int.TryParse(tb_CourseID.Text, out TempID))
            {
                if (TempID <= 0)
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('ϵͳ�쳣');window.location.href='../ClassPlan/ProjectCourseList.aspx';</script>");
                }
            }
            int CourseID = TempID;

            if (tb_CourseID.Text.Equals(""))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "�γ����Ʋ���Ϊ��!");
                return;
            }
            if (tb_KeyWord.Text.Equals(""))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "�ؼ��ֲ���Ϊ��!");
                return;
            }
            if (tb_Content.Text.Equals(""))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "������ݲ���Ϊ��!");
                return;
            }
            string strWhere = " COutLine_CourseID=" + CourseID;
            outlinelist = OutLine.GetModelList(strWhere);
            if (outlinelist.Count != 0)
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "��ѡ�γ��Ѵ��ڴ��!");
                return;
            }
            if (string.IsNullOrEmpty(tb_Submitter.Text))
            {
                LabMS.Common.JShelper.JSAlert(Page, "error", "�����Ϊ�գ�����ϵ����Ա");
                return;
            }
            #endregion

            model.COutLine_Submiter = tb_Submitter.Text;
            model.COutLine_SubmitTime = DateTime.Now;
            model.COutLine_KeyWord = tb_KeyWord.Text.Trim();
            model.COutLine_CourseID = CourseID;
            model.COutLine_Course = tb_CourseName.Text;
            model.COutLine_CourseCode = tb_CourseCode.Text;
            model.COutLine_Content = tb_Content.Text;
            int AttachIDTemp = UpLoadFile();

            if (AttachIDTemp > 0)
            {
                model.COutLine_Attach = UpLoadFile();
            }
            try
            {
                OutLine.Add(model);
            }
            catch
            {
                LabMS.Common.JShelper.JSAlert(Page, "AddFailed", "���ʧ��!");
                return;
            }
            LabMS.Common.JShelper.JSAlertAndRedirect(Page, "AddSuccess", "��ӳɹ�!", "../../ClassPlan/ProjectCourseList.aspx");
        }