Esempio n. 1
0
        /// <summary>
        ///     添加部门
        /// </summary>
        /// <param name="department"></param>
        /// <returns>
        ///     添加成功: >0
        ///     失败    :  =0
        /// </returns>
        public int AddDepartment(Department department)
        {
            int result = 0;
            try
            {
                var strSql = new StringBuilder();
                strSql.Append(" insert into T_Sys_Dept ( TypeId,DeptName,AddTime,State ) values(");
                strSql.Append(" @TypeId,@DeptName,@AddTime,@State) ");
                strSql.Append(" ;select @@IDENTITY");
                SqlParameter[] para =
                {
                    new SqlParameter("@TypeId", SqlDbType.Int),
                    new SqlParameter("@DeptName", SqlDbType.NVarChar, 50),
                    new SqlParameter("@AddTime", SqlDbType.DateTime),
                    new SqlParameter("@State", SqlDbType.Int)
                };
                para[0].Value = department.TypeId;
                para[1].Value = department.DeptName;
                para[2].Value = department.AddTime;
                para[3].Value = 1; //状态为可用

                var obj = SqlHelper.ExecuteScalar(SqlHelper.connString, CommandType.Text, strSql.ToString(), para);
                if (obj != null)
                {
                    result = Convert.ToInt32(obj);
                }
            }
            catch (Exception e)
            {
                Log4Net.LogWrite("err", "Med_DAL:DAL_Dept//AddDepartment" + e.Message); //发生异常,记录
            }
            return result;
        }
Esempio n. 2
0
 /// <summary>
 /// 更新部门信息
 /// </summary>
 /// <param name="department"></param>
 /// <returns>
 ///     成功:true
 ///     失败:false
 /// </returns>
 public static bool UpdateDepartment(Department department)
 {
     return DalDepartment.UpdateDepartment(department);
 }
Esempio n. 3
0
 /// <summary>
 /// 添加部门
 /// </summary>
 /// <param name="department"></param>
 /// <returns>
 ///     添加成功: >0
 ///     失败    :  =0
 /// </returns>
 public static int AddDpartment(Department department)
 {
     return DalDepartment.AddDepartment(department);
 }
Esempio n. 4
0
        /// <summary>
        /// 批量导入救助对象
        /// </summary>
        /// <param name="table"></param>
        /// <returns>导入失败的救助对象的信息</returns>
        public static DataTable ImportPatientList(DataTable table)
        {
            DataTable dirtyDurgTable = table.Copy(); //脏数据表
            dirtyDurgTable.Clear();

            DataTable patientTable = table.Copy(); //新数据表(等待插入数据库中的)
            patientTable.Clear();

            List<Department> listDept = BLL_Department.GetDepartmentList(" TypeId=2 or TypeId=5 or TypeId=6 ");//找到乡镇 患者类别 救助类别的相关信息
            List<HelpStandard> listHelpStandard = BLL_HelpStandard.GetListHelpStandard("");
            //筛选数据
            for (var count = 0; count < table.Rows.Count; count++)
            {
                if (!Regex.IsMatch(table.Rows[count][2].ToString(),"^[1-9]\\d{5}[1-9]\\d{3}(((0[13578]|1[02])(0[1-9]|[12]\\d|3[0-1]))|((0[469]|11)(0[1-9]|[12]\\d|30))|(02(0[1-9]|[12]\\d)))(\\d{4}|\\d{3}[xX])$"))
                if (!string.IsNullOrEmpty(DalPatient.SelectPatientByIdCard(table.Rows[count][2].ToString()).IdCard))//判断身份证是否已经存在
                {
                    dirtyDurgTable.Rows.Add(table.Rows[count].ItemArray); //存在加入脏数据表
                    table.Rows.Remove(table.Rows[count]);
                    count--;
                    continue;
                }
                //检测用户 所属乡镇 患者类别 救助类别 是否存在
                Department department = new Department();
                //验证乡镇
                department = listDept.Find(dept => dept.TypeId == 2 && dept.DeptName == table.Rows[count][6].ToString());
                if (department != null) //如果添加对象的乡镇存在
                {
                    table.Rows[count][6] = department.Id;
                }
                else
                {
                    dirtyDurgTable.Rows.Add(table.Rows[count].ItemArray); //存在加入脏数据表
                    table.Rows.Remove(table.Rows[count]);
                    count--;
                    continue;
                }
                //验证患者类别
                department = listDept.Find(dept => dept.TypeId == 5 && dept.DeptName == table.Rows[count][7].ToString());
                if (department != null) //如果添加对象的乡镇存在
                {
                    table.Rows[count][7] = department.Id;
                }
                else
                {
                    dirtyDurgTable.Rows.Add(table.Rows[count].ItemArray); //存在加入脏数据表
                    table.Rows.Remove(table.Rows[count]);
                    count--;
                    continue;
                }
                //验证救助类别
                department = listDept.Find(dept => dept.TypeId == 6 && dept.DeptName == table.Rows[count][8].ToString());
                if (department != null) //如果添加对象的乡镇存在
                {
                    table.Rows[count][8] = department.Id;

                    //动态生成救助对象表中的其他数据
                    patientTable.Rows.Add(table.Rows[count].ItemArray);
                }
                else
                {
                    dirtyDurgTable.Rows.Add(table.Rows[count].ItemArray); //存在加入脏数据表
                    table.Rows.Remove(table.Rows[count]);
                    count--;
                }
                HelpStandard helpStandard =
                    listHelpStandard.Find(item => item.HelpTypeId == Convert.ToInt32(table.Rows[count][8]));
                if (helpStandard == null)  //该救助对象标准不存在
                {
                    dirtyDurgTable.Rows.Add(table.Rows[count].ItemArray); //存在加入脏数据表
                    table.Rows.Remove(table.Rows[count]);
                    count--;
                }

            }
            DataTable tempTable = DalPatient.ImportPatientList(table);
            if (tempTable != null)
            {
                foreach (var item in tempTable.Rows)
                {
                    tempTable.Rows.Add(item);
                }
            }
            return dirtyDurgTable;
        }
Esempio n. 5
0
 /// <summary>
 ///     更新部门信息
 /// </summary>
 /// <param name="department"></param>
 /// <returns>
 ///     成功:true
 ///     失败:false
 /// </returns>
 public bool UpdateDepartment(Department department)
 {
     bool result = false;
     try
     {
         var strSql = new StringBuilder();
         strSql.Append(" update T_Sys_Dept set");
         strSql.Append(" TypeId=@TypeId ,");
         strSql.Append(" DeptName=@DeptName");
         strSql.Append(" where Id=@Id ");
         SqlParameter[] parameters =
         {
              new SqlParameter("@TypeId", SqlDbType.Int),
             new SqlParameter("@DeptName", SqlDbType.NVarChar, 50),
             new SqlParameter("@Id", SqlDbType.Int),
         };
         parameters[0].Value = department.TypeId;
         parameters[1].Value = department.DeptName;
         parameters[2].Value = department.Id;
         if (SqlHelper.ExecuteNonQuery(SqlHelper.connString, CommandType.Text, strSql.ToString(), parameters) ==
             1) //更改成功 影响条数为1
         {
             result = true; //更新成功设置为true
         }
     }
     catch (Exception e)
     {
         Log4Net.LogWrite("err", "Med_DAL:DAL_Dept//UpdateManagerRole" + e.Message); //发生异常,记录
     }
     return result;
 }
Esempio n. 6
0
        /// <summary>
        ///     根据部门编号获得部门信息
        /// </summary>
        /// <param name="id">部门编号</param>
        /// <returns></returns>
        public Department SelectDepartmentById(int id)
        {
            var dept = new Department();
            try
            {
                var strSql = new StringBuilder();
                strSql.Append("select Id,TypeId,DeptName,AddTime from T_Sys_Dept");
                strSql.Append(" where Id=@id");

                SqlParameter[] parameters =
                {
                    new SqlParameter("@id", SqlDbType.Int)
                };
                parameters[0].Value = id;

                // manager = LoadEntity(SqlHelper.ExecuteDataset(SqlHelper.connString, CommandType.Text, strSql.ToString(), parameters).Tables[0]);
                dept =
                    SqlHelper.ExecuteDataset(SqlHelper.connString, CommandType.Text, strSql.ToString(), parameters)
                        .Tables[0].ToList<Department>()[0];
            }
            catch (Exception e)
            {
                Log4Net.LogWrite("err", "Med_DAL:DAL_Dept//SelectDepartmentById" + e.Message); //发生异常,记录
            }
            return dept;
        }
        /// <summary>
        /// 判断当前救助类别是否已经存在救助标准
        /// </summary>
        /// <returns></returns>
        private bool ContainItmes(Department depart)
        {
            List<HelpStandard> listHelpStandard = BLL_HelpStandard.GetListHelpStandard("");//得到所有的救助标准

            return listHelpStandard.FindAll(item => item.HelpTypeId == depart.Id).Count != 0; //如果存在救助标准数据了,返回true
        }