Example #1
0
 /// <summary>
 /// 根据学年取得ID,用于更新
 /// </summary>
 /// <param name="Year"></param>
 /// <returns></returns>
 public int GetIDByDDLYear(int Year)
 {
     LabMS.BLL.SysSetting bSys = new LabMS.BLL.SysSetting();
     string str = "CurrentYear="+Year;
     List<LabMS.Model.SysSetting> list = new List<LabMS.Model.SysSetting>();
     list = bSys.GetModelList(str);
     int ID = list[0].ID;
     return ID;
 }
Example #2
0
 public LabMS.Model.SysSetting GetCurrentSetting()
 {
     LabMS.BLL.SysSetting bsys = new LabMS.BLL.SysSetting();
     List<LabMS.Model.SysSetting> listsys = new List<LabMS.Model.SysSetting>();
     listsys = bsys.GetModelList("");
     if (listsys.Count == 0)
     {
         throw (new Exception("系统数据需初始化!"));
     }
     return listsys[0];
 }
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            #region 验证
            if (string.IsNullOrEmpty(tb1.Text.Trim()))
            {
                Common.JShelper.JSAlert(this.Page,"","实验预约应提前几天不能为空!");
                tb1.Focus();
            }
            else if (string.IsNullOrEmpty(tb2.Text.Trim()))
            {
                Common.JShelper.JSAlert(this.Page, "", "取消预约应提前几天不能为空!");
                tb2.Focus();
            }
            else if (string.IsNullOrEmpty(tb3.Text.Trim()))
            {
                Common.JShelper.JSAlert(this.Page, "", "学生提交预习报告应提前几天不能为空!");
                tb3.Focus();
            }
            else if(string.IsNullOrEmpty(tb4.Text.Trim()))
            {
                Common.JShelper.JSAlert(this.Page, "", "成绩的及格分数线不能为空!");
                tb4.Focus();
            }
            #endregion
            else
            {
                LabMS.Model.SysSetting MSysSetting = new LabMS.Model.SysSetting();
                ExtendBLL.SysSetting eSys = new ExtendBLL.SysSetting();
                MSysSetting.ID = eSys.GetIDByDDLYear(int.Parse(ddlYear.SelectedValue.ToString()));//根据学年取ID
                MSysSetting.CurrentYear = int.Parse(ddlYear.SelectedValue.ToString());
                MSysSetting.CurrentSemester = int.Parse(ddlSem.SelectedValue.ToString());
                MSysSetting.ExperimentApproval = rb1.Checked ? true : false;   //1为是,0为否
                MSysSetting.ExperimentAutoGenerateID = rb2.Checked ? true:false;
                MSysSetting.ExperimentBookForward =int.Parse(tb1.Text.Trim().ToString());
                MSysSetting.ExperimentCancleForward =int.Parse(tb2.Text.Trim().ToString());
                MSysSetting.PreparationReportRequired = rb3.Checked ? true : false;
                MSysSetting.PreparationReportSubmitForward =int.Parse(tb3.Text.Trim().ToString());
                MSysSetting.PassedLimit =decimal.Parse(tb4.Text.Trim());
                MSysSetting.ScoreType = rb4.Checked ? 1 : 2;//1代表百分制,2代表等级制

                LabMS.BLL.SysSetting BS = new LabMS.BLL.SysSetting();

                if (hd.Value == "update")
                {
                    LabMS.BLL.SysSetting bS = new LabMS.BLL.SysSetting();
                    bool success = false;
                    try
                    {
                        bS.Update(MSysSetting);
                        success = true;
                    }
                    catch(Exception ex)
                    {
                        throw ex;
                    }
                    if (success==true)
                    {
                        Common.JShelper.JSAlert(this.Page, "", "保存成功!");
                        InitBind();
                    }
                    else
                    {
                        Common.JShelper.JSAlert(this.Page, "", "保存失败!");
                    }
                }
                else if(hd.Value=="insert")
                {
                    int count=BS.Add(MSysSetting);
                    if (count > 0)
                    {
                        Common.JShelper.JSAlert(this.Page, "", "保存成功!");
                    }
                    else
                    {
                        Common.JShelper.JSAlert(this.Page, "", "保存失败!");
                    }
                }

            }
        }
 /// <summary>
 /// 页面初始化
 /// </summary>
 protected void InitBind()
 {
     BindDDL();
     LabMS.BLL.SysSetting BSY = new LabMS.BLL.SysSetting();
     DataSet ds = new DataSet();
     ds=BSY.GetAllList();
     ddlYear.SelectedValue=ds.Tables[0].Rows[0]["CurrentYear"].ToString();
     ddlSem.SelectedValue = ds.Tables[0].Rows[0]["CurrentSemester"].ToString();
     if (ds.Tables[0].Rows[0]["ExperimentApproval"].ToString() == "1")
     {
         rb1.Checked = true;
     }
     else
     {
         rb11.Checked = true;
     }
     if (ds.Tables[0].Rows[0]["ExperimentAutoGenerateID"].ToString() == "1")
     {
         rb2.Checked = true;
     }
     else
     {
         rb22.Checked = true;
     }
     tb1.Text = ds.Tables[0].Rows[0]["ExperimentBookForward"].ToString();
     tb2.Text = ds.Tables[0].Rows[0]["ExperimentCancleForward"].ToString();
     if (ds.Tables[0].Rows[0]["PreparationReportRequired"].ToString() == "1")
     {
         rb3.Checked = true;
     }
     else
     {
         rb33.Checked = true;
     }
     tb3.Text = ds.Tables[0].Rows[0]["PreparationReportSubmitForward"].ToString();
     tb4.Text = ds.Tables[0].Rows[0]["PassedLimit"].ToString();
     if (ds.Tables[0].Rows[0]["ScoreType"].ToString() == "1")
     {
         rb4.Checked = true;//1代表百分制,2代表等级制
     }
     else
     {
         rb44.Checked = true;
     }
 }