Ejemplo n.º 1
0
        public static List <InstScoreTable> getInstScore(string INSTNO, string itemNo, string evalYear)
        {
            List <InstScoreTable> listData = new List <InstScoreTable>();

            try
            {
                MysqlDBA <InstScoreTable> dbaHRAlloc = new MysqlDBA <InstScoreTable>(FunctionController.CONNSTR);
                DataSet ds = dbaHRAlloc.getDataSet(string.Format("SELECT * FROM InstScoreTable WHERE INSTNO='{0}' AND EvalYear='{1}' AND ItemNo='{2}'", INSTNO, evalYear, itemNo));
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    InstScoreTable data = new InstScoreTable();
                    data.EvalYear  = row["EvalYear"].ToString();
                    data.INSTNO    = row["INSTNO"].ToString();
                    data.ItemNo    = row["ItemNo"].ToString();
                    data.SelfScore = row["SelfScore"].ToString();
                    data.EvalScore = row["EvalScore"].ToString();
                    data.EvalDesc  = row["EvalDesc"].ToString();
                    data.EvalDate  = row["EvalDate"].ToString();
                    data.SelfDate  = row["SelfDate"].ToString();
                    listData.Add(data);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(listData);
        }
Ejemplo n.º 2
0
        public ActionResult Calc(FormCollection formData)
        {
            MysqlDBA <InstScoreTable> mysqlDBA = new MysqlDBA <InstScoreTable>(FunctionController.CONNSTR);

            try
            {
                if (Session["INSTNO"] == null || string.IsNullOrEmpty(Session["INSTNO"].ToString()))
                {
                    TempData["SessionExipred"] = "true";
                    return(RedirectToAction("Index", "Login", null));
                }
                string         accountNo = Session["INSTNO"].ToString();
                string         year      = (DateTime.Now.Year - 1911).ToString();
                InstScoreTable instScore = new InstScoreTable();
                foreach (var key in formData.AllKeys)
                {
                    if (key.IndexOf("Score") != -1)
                    {
                        string value = formData[key].ToString();
                        if (!string.IsNullOrEmpty(value))
                        {
                            double score = double.Parse(value);
                            instScore           = new InstScoreTable();
                            instScore.EvalYear  = year;
                            instScore.INSTNO    = accountNo;
                            instScore.ItemNo    = key.Replace("Score", "");
                            instScore.SelfScore = score.ToString();
                            instScore.SelfDate  = DateTime.Now.ToString("yyyy-MM-dd");
                            instScore.EvalScore = "0";
                            instScore.EvalDate  = "1900-01-01";
                            mysqlDBA.InsertOrUpdate(instScore);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex + ex.StackTrace);
                TempData["action"] = "Function";
                TempData["error"]  = ex + ex.StackTrace;
                return(RedirectToAction("Index", "SelfRate", null));
            }
            return(RedirectToAction("Index", "Meeting"));
        }