예제 #1
0
        public bool ExemEdit(PlanExemption model)
        {
            StringBuilder sql = new StringBuilder();
            sql.Append(" update Member_PlanExemption set AccountId=@AccountId,Remark=@Remark,Credits=@Credits,PEType=@PEType ");
            sql.Append(" where id=@id ");
            SqlParameter[] para = {
                                    new SqlParameter("@AccountId",SqlDbType.Int),
                                    new SqlParameter("@Remark",SqlDbType.VarChar),
                                    new SqlParameter("@Credits",SqlDbType.Float),
                                    new SqlParameter("@PEType",SqlDbType.Int),
                                    new SqlParameter("@id",SqlDbType.Int)
                                  };
            para[0].Value = model.AccountId;
            para[1].Value = model.Remark;
            para[2].Value = model.Credits;
            para[3].Value = model.PEType;
            para[4].Value = model.Id;

            int i = MSEntLibSqlHelper.ExecuteNonQueryBySql(sql.ToString(), para);
            if (i > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
예제 #2
0
        public ActionResult ExemExeclTemp()
        {
            string msg = "";
            HttpPostedFileBase execl = Request.Files[0];
            string fileName = Server.MapPath(Code.UploadCore.UploadAttach(execl, ref msg));
            int GroupId = Code.SiteCache.Instance.GroupId;
            int OrganId = Code.SiteCache.Instance.ManageOrganId;

            //DataTable dt = ExcelToDataTable(fileName, "sheet1");
            DataTable dt = ReadExcel(fileName);
            if (dt.Columns[0].ColumnName.ToString() != "姓名" || dt.Columns[1].ColumnName.ToString() != "师训编号" || dt.Columns[2].ColumnName.ToString() != "所属学校" || dt.Columns[3].ColumnName.ToString() != "免修依据" || dt.Columns[4].ColumnName.ToString() != "抵扣学分" || dt.Columns[5].ColumnName != "类型")
            {
                return Content("no:导入的格式不正确!!!");
            }
            else
            {
                List<PlanExemption> list = new List<PlanExemption>();
                if (dt.Rows.Count == 0)
                {
                    return Content("no:无导入数据!!!");
                }
                else
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        try
                        {
                            for (int k = 0; k < dt.Columns.Count; k++)
                            {
                                if (string.IsNullOrEmpty(dt.Rows[i][k].ToString()))
                                {
                                    return Content("no:导入的数据有空值!!!");
                                }
                            }

                            PlanExemption model = new PlanExemption();
                            model.PlanId = Code.SiteCache.Instance.PlanId;
                            model.Status = 0;
                            model.Remark = dt.Rows[i][3].ToString();
                            if (Regex.IsMatch(dt.Rows[i][4].ToString(), @"^[+-]?\d*[.]?\d*$"))
                            {
                                model.Credits = Convert.ToDouble(dt.Rows[i][4]);
                            }
                            else
                            {
                                return Content("no:抵扣学分必须是数字类型!!!");
                            }
                            if (dt.Rows[i][4].ToString().Length > 5)
                            {
                                return Content("no:抵扣学分数字长度不能超过五位数!!!");
                            }
                            if (dt.Rows[i][4].ToString() == "0")
                            {
                                return Content("no:第" + (i + 1) + "行的抵扣学分不能为0");
                            }
                            if (GroupId == 2)
                            {
                                if (!bll.GetSchool(dt.Rows[i][2].ToString(), OrganId))
                                {
                                    return Content("no:请导入本区内的学校学员数据!!!");
                                }
                            }
                            else if (GroupId == 3 || GroupId == 4)
                            {
                                if (!bll.GetSchoolTo(dt.Rows[i][2].ToString(), OrganId))
                                {
                                    return Content("no:请导入本学校或本机构内的学员数据!!!");
                                }
                            }

                            model.Creater = Code.SiteCache.Instance.LoginInfo.UserId;
                            model.AccountId = bll.GetAccount(dt.Rows[i][0].ToString(), dt.Rows[i][1].ToString(), dt.Rows[i][2].ToString());
                            if (model.AccountId == 0 || model.AccountId == null)
                            {
                                return Content("no:导入数据的第" + (i + 1) + "行用户数据有误,请检查用户姓名、师训编号与用户所属学校是否正确!!!");
                            }
                            if (dt.Rows[i][5].ToString() != "通识课程" && dt.Rows[i][5].ToString() != "专业课程" && dt.Rows[i][5].ToString() != "实践应用课程")
                            {
                                return Content("no:请选择正确类型!!!");
                            }
                            else
                            {
                                model.PEType = dt.Rows[i][5].ToString() == "通识课程" ? 1 : dt.Rows[i][5].ToString() == "专业课程" ? 2 : dt.Rows[i][5].ToString() == "实践应用课程" ? 3 : 0;
                            }
                            model.Delflag = false;
                            model.CreateDate = DateTime.Now;
                            list.Add(model);
                        }
                        catch (Exception ex)
                        {
                            return Content("no:" + ex);
                        }
                    }

                    int count = bll.AddExem(list);
                    if (count > 0)
                    {
                        return Content("yes:成功导入" + count + "行数据");
                    }
                    else
                    {
                        return Content("no:导入失败");
                    }

                }
            }
        }
예제 #3
0
 public ActionResult ExemEdit(int id, string TeacherNo, string Remark, double Credits, int PEType)
 {
     PlanExemption model = new PlanExemption();
     model.Id = id;
     model.AccountId = bll.GetTeacherNo(TeacherNo);
     if (model.AccountId == 0 || model.AccountId == null)
     {
         return Content("no:师训编号不存在!!!");
     }
     model.Remark = Remark;
     model.Credits = Credits;
     model.PEType = PEType;
     if (bll.ExemEdit(model))
     {
         return Content("yes:修改成功!!!");
     }
     else
     {
         return Content("no:修改失败!!!");
     }
 }
예제 #4
0
        private void ConvertToModel(IDataReader reader, PlanExemption model)
        {
            if (reader["Id"] != DBNull.Value)
                model.Id = Convert.ToInt32(reader["Id"]);

            if (reader["PlanId"] != DBNull.Value)
                model.PlanId = Convert.ToInt32(reader["PlanId"].ToString());

            if (reader["Status"] != DBNull.Value)
                model.Status = Convert.ToInt32(reader["Status"].ToString());

            if (reader["Remark"] != DBNull.Value)
                model.Remark = reader["Remark"].ToString();

            if (reader["Credits"] != DBNull.Value)
                model.Credits = Convert.ToDouble(reader["Credits"]);

            if (reader["PEType"] != DBNull.Value)
                model.PEType = Convert.ToInt32(reader["PEType"]);

            if (reader["Creater"] != DBNull.Value)
                model.Creater = Convert.ToInt32(reader["Creater"]);

            if (reader["AccountId"] != DBNull.Value)
                model.AccountId = Convert.ToInt32(reader["AccountId"]);

            if (reader["Delflag"] != DBNull.Value)
                model.Delflag = Convert.ToBoolean(reader["Delflag"]);

            if (reader["CreateDate"] != DBNull.Value)
                model.CreateDate = Convert.ToDateTime(reader["CreateDate"]);

            if (reader["TeacherNo"] != DBNull.Value)
                model.TeacherNo = reader["TeacherNo"].ToString();

            if (reader["RealName"] != DBNull.Value)
                model.RealName = reader["RealName"].ToString();

            if (reader["Organid"] != DBNull.Value)
                model.Organid = Convert.ToInt32(reader["Organid"]);

            if (reader["OrganTitle"] != DBNull.Value)
                model.OrganTitle = reader["OrganTitle"].ToString();
        }
예제 #5
0
 public PlanExemption GetModel(int id)
 {
     PlanExemption model = new PlanExemption();
     StringBuilder sql = new StringBuilder();
     sql.Append(" select b.TeacherNo,a.Remark,a.Credits,a.PEType from Member_PlanExemption a  ");
     sql.Append(" left join Member_BaseInfo b on a.AccountId = b.AccountId where a.id=@id ");
     SqlParameter[] para ={
                             new SqlParameter("@id",id)
                          };
     IDataReader dr = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql.ToString(), para);
     if (dr.Read())
     {
         model.TeacherNo = dr["TeacherNo"].ToString();
         model.Remark = dr["Remark"].ToString();
         model.Credits = Convert.ToDouble(dr["Credits"]);
         model.PEType = Convert.ToInt32(dr["PEType"]);
     }
     return model;
 }
예제 #6
0
 public List<PlanExemption> GetList(int pageSize, int pageIndex, string where, string orderBy, out int recordCount)
 {
     if (string.IsNullOrEmpty(orderBy))
         throw new ArgumentNullException();
     StringBuilder sb = new StringBuilder();
     sb.Append("select count(1) from dbo.Member_PlanExemption a left join Member_BaseInfo b on a.AccountId = b.AccountId left join Organ_Detail c on b.Organid = c.Id left join Member_Account d on a.AccountId = d.Id where a.Delflag = 0 ");
     if (!string.IsNullOrEmpty(where))
         sb.Append(where);
     recordCount = Convert.ToInt32(MSEntLibSqlHelper.ExecuteScalarBySql(sb.ToString()));
     int start = (pageIndex - 1) * pageSize + 1;
     int end = pageIndex * pageSize;
     StringBuilder sql = new StringBuilder();
     sql.Append("select * from (select a.*,b.TeacherNo,b.RealName,c.Id as Organid,c.Title as OrganTitle,ROW_NUMBER() over (order by " + orderBy + ") as RowNum from dbo.Member_PlanExemption a left join Member_BaseInfo b on a.AccountId = b.AccountId  left join Member_Account d on a.AccountId = d.Id left join Organ_Detail c on d.Organid = c.Id where a.Delflag = 0 ");
     if (!string.IsNullOrEmpty(where))
         sql.Append(where);
     sql.Append(")as T where RowNum between @start and @end");
     SqlParameter[] para ={
                             new SqlParameter("@start",start),
                             new SqlParameter("@end",end)
                          };
     List<PlanExemption> list = new List<PlanExemption>();
     using (IDataReader reader = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql.ToString(),para))
     {
         while (reader.Read())
         {
             PlanExemption model = new PlanExemption();
             ConvertToModel(reader, model);
             list.Add(model);
         }
     }
     return list;
 }
예제 #7
0
 public bool ExemEdit(PlanExemption model)
 {
     return dal.ExemEdit(model);
 }