protected void btnCommit_Click(object sender, EventArgs e)
        {
            NormFormula normformula = new NormFormula
            {
                targetNormId = Convert.ToInt32(Request["normId"].ToString().Trim()),
                formula = this.formula.Value,
                formulaShow = this.TextNormFormula.Value,
                termYear = termYear
            };

            DalOperationNorm dal = new DalOperationNorm();
            dal.setFormula(normformula);
            NormFormula rootformula = dal.GetFormula(0,termYear);

            DalOperationAboutTeacher dalteacher = new DalOperationAboutTeacher();
            DataSet dsTeacher = dalteacher.GetTeachers();
            for (int i = 0; i < dsTeacher.Tables[0].Rows.Count; i++)
            {
                string teacherNo = dsTeacher.Tables[0].Rows[i]["teacherNo"].ToString().Trim();

                    if (normformula != null)
                    {
                        dal.Execute(normformula, teacherNo,termYear);

                    }
                    if (rootformula != null)
                    {
                        dal.Execute(rootformula, teacherNo, termYear);
                    }

            }
            string t = "template";
            if (normformula != null)
            {
                dal.Execute(normformula, t, termYear);

            }
            if (rootformula != null)
            {
                dal.Execute(rootformula, t, termYear);
            }
            Javascript.RefreshParentWindow("/Administrator/NormManager.aspx?fragment=2&&term=" + Request["termYear"], Page);
        }
Exemple #2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="formula"></param>
 public void setFormula(NormFormula formula)
 {
     try
     {
         SqlParameter[] parameters = {
             new SqlParameter("@targetNormId",formula.targetNormId),
             new SqlParameter("@termYear",formula.termYear),                        };
         string sql = "SELECT * FROM [USTA].[dbo].[usta_NormFormula] WHERE targetNormId = @targetNormId AND termYear = @termYear";
         DataSet ds = SqlHelper.ExecuteDataset(conn, CommandType.Text, sql, parameters);
         if (ds.Tables[0].Rows.Count > 0)
         {
             UpdateFomula(formula);
         }
         else
         {
             AddFomula(formula);
         }
     }
     catch (Exception ex)
     {
         MongoDBLog.LogRecord(ex);
         CommonUtility.RedirectUrl();
     }
     finally
     {
         conn.Close();
     }
 }
Exemple #3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="targetId"></param>
 /// <param name="termYear"></param>
 /// <returns></returns>
 public NormFormula GetFormula(int targetId,string termYear)
 {
     NormFormula formula = null;
     SqlParameter[] parameters = {
             new SqlParameter("@targetNormId",targetId),
             new SqlParameter("@termYear",termYear)};
     string cmd = "SELECT [targetNormId],[formula],[formulaShow],[termYear] FROM [USTA].[dbo].[usta_NormFormula] WHERE targetNormId = @targetNormId AND termYear = @termYear ";
     SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.Text, cmd, parameters);
     if (dr.Read())
     {
         formula = new NormFormula()
         {
             targetNormId = Convert.ToInt32(dr["targetNormId"].ToString()),
             formula = dr["formula"].ToString().Trim(),
             formulaShow = dr["formulaShow"].ToString().Trim(),
             termYear = dr["termYear"].ToString().Trim()
         };
     }
     dr.Close();
     return formula;
 }
Exemple #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="formula"></param>
        /// <param name="teacherNo"></param>
        /// <param name="term"></param>
        /// <returns></returns>
        public float Execute(NormFormula formula,string teacherNo,string term)
        {
            if (formula.targetNormId != -1)
            {
                string targetExpression = this.GetFromExpression(formula.formula, teacherNo, term, null, null, null,0);
                if (targetExpression == null) return 0;
                if (targetExpression.Contains("/0"))//此处存在bug,懒得解决,dzx帮忙解决下呗!
                {
                    return 0;//TODO该部分没做完。
                }
                float result = qswhEval3(targetExpression);
                this.setNormValue(formula.targetNormId, teacherNo, term, result.ToString());
                return result;
            }
            else
            {
                DataTable dt = GetTeacherCourses(teacherNo, term);
                float result1 = 0;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string targetExpression = this.GetFromExpression(formula.formula, teacherNo, term, dt.Rows[i]["courseNo"].ToString().Trim(), dt.Rows[i]["ClassID"].ToString().Trim(), dt.Rows[i]["termTag"].ToString().Trim(), int.Parse(dt.Rows[i]["atCourseType"].ToString().Trim()));
                    if (targetExpression == null) return 0;
                    if (targetExpression.Contains("/0"))//此处存在bug,懒得解决,dzx帮忙解决下呗!
                    {
                        return 0;//TODO该部分没做完。
                    }
                    result1 += qswhEval3(targetExpression);

                }
                this.setNormValue(formula.targetNormId, teacherNo, term, result1.ToString());
                return result1;
            }
        }
Exemple #5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="formula"></param>
 private void UpdateFomula(NormFormula formula)
 {
     try
     {
         SqlParameter[] parameters = {
             new SqlParameter("@targetNormId",formula.targetNormId),
             new SqlParameter("@formula",formula.formula),
             new SqlParameter("@formulaShow",formula.formulaShow),
              new SqlParameter("@termYear",formula.termYear)};
         string upString = "UPDATE [USTA].[dbo].[usta_NormFormula] SET formula = @formula,formulaShow = @formulaShow WHERE targetNormId = @targetNormId AND termYear=@termYear";
         SqlHelper.ExecuteNonQuery(conn, CommandType.Text, upString, parameters);
     }
     catch (Exception e)
     {
         MongoDBLog.LogRecord(e);
         CommonUtility.RedirectUrl();
     }
 }
Exemple #6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="formula"></param>
 private void AddFomula(NormFormula formula)
 {
     try
     {
         SqlParameter[] parameters = {
             new SqlParameter("@targetNormId",formula.targetNormId),
             new SqlParameter("@formula",formula.formula),
             new SqlParameter("@formulaShow",formula.formulaShow),
             new SqlParameter("@termYear",formula.termYear)};
         string insertString = "INSERT INTO [USTA].[dbo].[usta_NormFormula]([targetNormId],[formula],[formulaShow],[termYear])VALUES(@targetNormId,@formula,@formulaShow,@termYear)";
         SqlHelper.ExecuteNonQuery(conn, CommandType.Text, insertString, parameters);
     }
     catch (Exception ex)
     {
         MongoDBLog.LogRecord(ex);
         CommonUtility.RedirectUrl();
     }
 }