Example #1
0
        public List <UnitScoreModel> GetUnitScoreModel(DateTime dt)
        {
            dt = this.GetMonthFirstDate(dt);
            List <UnitScoreModel> deptScoreTotal = new List <UnitScoreModel>();
            SqlConnection         sqlConn        = new SqlConnection(FunctionRule.GetConnectionString());

            deptScoreTotal = RS_ScoreManageDAL.GetDeptScoreTotal(dt, sqlConn);
            List <UnitScoreModel> list2 = new List <UnitScoreModel>();

            foreach (UnitScoreModel model2 in deptScoreTotal)
            {
                SqlConnection  connection2 = new SqlConnection(FunctionRule.GetConnectionString());
                UnitScoreModel item        = new UnitScoreModel();
                item.DeptCode = model2.DeptCode;
                item.DeptName = this.GetDeptNameByDeptID(model2.DeptCode);
                item.Score    = model2.Score;
                string text = RS_ScoreManageDAL.GetDeptEmployMarker(dt, model2.DeptCode, connection2);
                if (!string.IsNullOrEmpty(text))
                {
                    item.Marker = this.GetUserNameByUserID(text);
                }
                list2.Add(item);
            }
            return(list2);
        }
Example #2
0
        public static List <UnitScoreModel> GetDeptScoreTotal(DateTime dt, SqlConnection sqlConn)
        {
            List <UnitScoreModel> list = new List <UnitScoreModel>();
            UnitScoreModel        item = new UnitScoreModel();
            string     cmdText         = "SELECT UserCode,Score FROM RS_EmployScore WHERE ManageCode = ( SELECT Code FROM RS_ScoreManage WHERE MarkDate = @MarkDate AND Type=2)";
            SqlCommand command         = new SqlCommand(cmdText, sqlConn);

            command.Parameters.Add("@MarkDate", SqlDbType.DateTime).Value = dt;
            using (SqlConnection connection = sqlConn)
            {
                sqlConn.Open();
                SqlDataReader reader = command.ExecuteReader();
                try
                {
                    try
                    {
                        while (reader.Read())
                        {
                            item = new UnitScoreModel();
                            if (reader.GetValue(0) != DBNull.Value)
                            {
                                item.DeptCode = reader.GetString(0);
                            }
                            if (reader.GetValue(1) != DBNull.Value)
                            {
                                item.Score = reader.GetInt32(1);
                            }
                            list.Add(item);
                        }
                    }
                    catch (Exception exception)
                    {
                        throw exception;
                    }
                    return(list);
                }
                finally
                {
                    if (reader != null)
                    {
                        reader.Close();
                    }
                }
            }
            return(list);
        }