Exemple #1
0
        /// <summary>
        /// 导入历史数据 --- 病种组合维护
        /// </summary>
        /// <auth>Yanqiao.Cai</auth>
        /// <date>2013-01-07</date>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_importData_Click(object sender, EventArgs e)
        {
            try
            {
                if (DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show("您确定要导入历史数据吗?", "导入历史数据", DrectSoft.Common.Ctrs.DLG.MyMessageBoxButtons.OkCancel) == DialogResult.Cancel)
                {
                    return;
                }

                #region 导入原病种组合
                string sqlStr1 = " select id,diseasegroup,name from DiseaseGroup ";
                DS_SqlHelper.CreateSqlHelper();
                DataTable dt1 = DS_SqlHelper.ExecuteDataTable(sqlStr1, CommandType.Text);
                if (null != dt1 && dt1.Rows.Count > 0)
                {
                    foreach (DataRow drow in dt1.Rows)
                    {
                        List <DbParameter> parameters = new List <DbParameter>();
                        SqlParameter       param1     = new SqlParameter("@name", SqlDbType.Char);
                        SqlParameter       param2     = new SqlParameter("@py", SqlDbType.Char);
                        SqlParameter       param3     = new SqlParameter("@wb", SqlDbType.Char);
                        //名称、拼音、五笔
                        string groupName = null == drow["NAME"] ? "" : drow["NAME"].ToString();
                        if (string.IsNullOrEmpty(groupName))
                        {
                            continue;
                        }
                        GenerateShortCode shortCode = new GenerateShortCode(m_app.SqlHelper);
                        string[]          code      = shortCode.GenerateStringShortCode(groupName);
                        param1.Value = groupName;
                        parameters.Add(param1);
                        if (null != code && code.Length >= 2)
                        {
                            param2.Value = null == code[0] ? string.Empty : code[0].ToString();
                            param3.Value = null == code[1] ? string.Empty : code[1].ToString();
                            parameters.Add(param2);
                            parameters.Add(param3);
                        }
                        //病种IDs (Y58.501$白喉疫苗接种反应,E70.301$白化病,E25.001$11-羟化酶缺陷,Y58.601$百日咳疫苗反应)
                        string IDs        = string.Empty;
                        string IDAndNames = null == drow["diseasegroup"] ? "" : drow["diseasegroup"].ToString();
                        if (string.IsNullOrEmpty(IDAndNames))
                        {
                            continue;
                        }
                        string[] IDAndNameArray = IDAndNames.Split(',');
                        if (null != IDAndNameArray && IDAndNameArray.Length > 0)
                        {
                            foreach (string IDAndName in IDAndNameArray)
                            {
                                string[] str = IDAndName.Split('$');
                                if (null != str && str.Length > 0)
                                {
                                    IDs += str[0] + "$";
                                }
                            }
                            if (!string.IsNullOrEmpty(IDs))
                            {
                                IDs = IDs.Substring(0, IDs.Length - 1);
                            }
                        }
                        SqlParameter param4 = new SqlParameter("@diseaseids", SqlDbType.Char);
                        param4.Value = IDs;
                        parameters.Add(param4);
                        //是否有效
                        SqlParameter param5 = new SqlParameter("@valid", SqlDbType.Int);
                        param5.Value = 1;
                        parameters.Add(param5);
                        //创建人
                        SqlParameter param6 = new SqlParameter("@create_user", SqlDbType.Char);
                        param6.Value = DS_Common.currentUser.Id;
                        parameters.Add(param6);
                        //创建时间
                        SqlParameter param7 = new SqlParameter("@create_time", SqlDbType.Char);
                        param7.Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        parameters.Add(param7);
                        DS_SqlService.InsertDiseaseGroup(parameters);
                    }
                    DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show("病种组合历史数据导入成功");
                }
                else
                {
                    DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show("病种组合不存在历史数据");
                }
                #endregion

                #region 导入原用户&病种组合关系
                int    newNum  = 1;
                string sqlStr2 = " select id,name,PY,WB,DEPTID,RELATEDISEASE from attendingphysician ";
                DS_SqlHelper.CreateSqlHelper();
                DataTable dt2 = DS_SqlHelper.ExecuteDataTable(sqlStr2, CommandType.Text);
                if (null != dt2 && dt2.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt2.Rows)
                    {
                        List <DbParameter> pars = new List <DbParameter>();
                        //匹配组合ID (Y58.601$百日咳疫苗反应,A37.905$百日咳脑病,E25.002$17-羟化酶缺陷)
                        string IDs        = string.Empty;
                        string IDAndNames = null == dr["RELATEDISEASE"] ? "" : dr["RELATEDISEASE"].ToString();
                        if (string.IsNullOrEmpty(IDAndNames))
                        {
                            continue;
                        }
                        string[] IDAndNameArray = IDAndNames.Split(',');
                        if (null != IDAndNameArray && IDAndNameArray.Length > 0)
                        {
                            foreach (string IDAndName in IDAndNameArray)
                            {
                                string[] str = IDAndName.Split('$');
                                if (null != str && str.Length > 0)
                                {
                                    IDs += str[0] + "$";
                                }
                            }
                            if (!string.IsNullOrEmpty(IDs))
                            {
                                IDs = IDs.Substring(0, IDs.Length - 1);
                            }
                        }
                        string        sqlStr3   = " select * from DiseasesGroup where diseaseids = @diseaseids ";
                        DbParameter[] sqlParams = new DbParameter[]
                        {
                            new SqlParameter("@diseaseids", SqlDbType.Char)
                        };
                        sqlParams[0].Value = IDs;
                        DS_SqlHelper.CreateSqlHelper();
                        DataTable dt3 = DS_SqlHelper.ExecuteDataTable(sqlStr3, sqlParams, CommandType.Text);

                        SqlParameter par1 = new SqlParameter("@groupids", SqlDbType.Char);
                        if (null != dt3 && dt3.Rows.Count > 0)
                        {//该用户对应组合存在
                            par1.Value = null == dt3.Rows[0]["ID"] ? "" : dt3.Rows[0]["ID"].ToString();
                        }
                        else
                        {//该用户对应组合不存在,此时需新增组合
                            #region 新增组合
                            string newGroupID = AddDiseaseGroupUnknow(newNum, IDs);
                            newNum++;
                            if (!string.IsNullOrEmpty(newGroupID))
                            {
                                par1.Value = newGroupID;
                            }
                            #endregion
                        }
                        pars.Add(par1);

                        SqlParameter par2 = new SqlParameter("@userid", SqlDbType.Char);
                        par2.Value = null == dr["ID"] ? "" : dr["ID"].ToString();
                        if (string.IsNullOrEmpty(par2.Value.ToString()))
                        {
                            continue;
                        }
                        pars.Add(par2);
                        SqlParameter par3 = new SqlParameter("@username", SqlDbType.Char);
                        par3.Value = null == dr["NAME"] ? "" : dr["NAME"].ToString();
                        pars.Add(par3);
                        SqlParameter par4 = new SqlParameter("@valid", SqlDbType.Int);
                        par4.Value = 1;
                        pars.Add(par4);
                        SqlParameter par5 = new SqlParameter("@create_user", SqlDbType.Char);
                        par5.Value = DS_Common.currentUser.Id;
                        pars.Add(par5);
                        SqlParameter par6 = new SqlParameter("@create_time", SqlDbType.Char);
                        par6.Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        pars.Add(par6);

                        DS_SqlService.InsertUserMatchDiseaseGroup(pars);
                    }
                    DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show("用户权限历史数据导入成功");
                }
                else
                {
                    DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show("用户权限不存在历史数据");
                }
                #endregion

                //隐藏导入历史数据按钮
                this.btn_importData.Visible = false;
                string hideSql = " update appcfg set value = '<mainDoc><isnew>1</isnew><btnflag>0</btnflag></mainDoc>' where configkey = 'ImportDiseasesGroupHistoryData' ";
                DS_SqlHelper.CreateSqlHelper();
                DS_SqlHelper.ExecuteNonQuery(hideSql, CommandType.Text);

                RefreashGroupsData();
            }
            catch (Exception ex)
            {
                DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show(1, ex);
            }
        }
Exemple #2
0
        /// <summary>
        /// 新增病种组合 --- 导入历史数据专用
        /// </summary>
        /// <param name="newNum">未知组合序号</param>
        /// <param name="IDs">病种ID集合</param>
        /// <returns></returns>
        private string AddDiseaseGroupUnknow(int newNum, string IDs)
        {
            try
            {
                if (string.IsNullOrEmpty(IDs))
                {
                    return(string.Empty);
                }
                List <DbParameter> paramets = new List <DbParameter>();
                SqlParameter       pa1      = new SqlParameter("@name", SqlDbType.Char);
                SqlParameter       pa2      = new SqlParameter("@py", SqlDbType.Char);
                SqlParameter       pa3      = new SqlParameter("@wb", SqlDbType.Char);
                //名称、拼音、五笔
                string            groupNameNew = "未知组合" + newNum.ToString();
                GenerateShortCode shortCode    = new GenerateShortCode(m_app.SqlHelper);
                string[]          code         = shortCode.GenerateStringShortCode(groupNameNew);
                pa1.Value = groupNameNew;
                paramets.Add(pa1);
                if (null != code && code.Length >= 2)
                {
                    pa2.Value = null == code[0] ? string.Empty : code[0].ToString();
                    pa3.Value = null == code[1] ? string.Empty : code[1].ToString();
                    paramets.Add(pa2);
                    paramets.Add(pa3);
                }
                //病种IDs
                SqlParameter param4 = new SqlParameter("@diseaseids", SqlDbType.Char);
                param4.Value = IDs;
                paramets.Add(param4);
                //是否有效
                SqlParameter param5 = new SqlParameter("@valid", SqlDbType.Int);
                param5.Value = 1;
                paramets.Add(param5);
                //创建人
                SqlParameter param6 = new SqlParameter("@create_user", SqlDbType.Char);
                param6.Value = DS_Common.currentUser.Id;
                paramets.Add(param6);
                //创建时间
                SqlParameter param7 = new SqlParameter("@create_time", SqlDbType.Char);
                param7.Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                paramets.Add(param7);
                DS_SqlService.InsertDiseaseGroup(paramets);

                string        newGroupID = string.Empty;
                string        sqlStr     = " select * from DiseasesGroup where diseaseids = @diseaseids ";
                DbParameter[] sqlParams  = new DbParameter[]
                {
                    new SqlParameter("@diseaseids", SqlDbType.Char)
                };
                sqlParams[0].Value = IDs;
                DS_SqlHelper.CreateSqlHelper();
                DataTable dt = DS_SqlHelper.ExecuteDataTable(sqlStr, sqlParams, CommandType.Text);
                if (null != dt && dt.Rows.Count > 0)
                {
                    newGroupID = dt.Rows[0]["ID"].ToString();
                }

                return(newGroupID);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemple #3
0
        /// <summary>
        /// 保存事件
        /// </summary>
        /// <auth>Yanqiao.Cai</auth>
        /// <date>2013-01-04</date>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string errorStr = CheckItem();
                if (!string.IsNullOrEmpty(errorStr))
                {
                    DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show(errorStr);
                    return;
                }

                List <DbParameter> parameters = new List <DbParameter>();
                //名称、拼音、五笔
                string groupName = this.txt_groupName.Text;
                if (string.IsNullOrEmpty(groupName))
                {
                    DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show("组合名称不能为空");
                    return;
                }
                GenerateShortCode shortCode = new GenerateShortCode(m_app.SqlHelper);
                string[]          code      = shortCode.GenerateStringShortCode(groupName);
                SqlParameter      param1    = new SqlParameter("@name", SqlDbType.Char);
                SqlParameter      param2    = new SqlParameter("@py", SqlDbType.Char);
                SqlParameter      param3    = new SqlParameter("@wb", SqlDbType.Char);
                param1.Value = groupName;
                parameters.Add(param1);
                if (null != code && code.Length >= 2)
                {
                    param2.Value = null == code[0] ? string.Empty : code[0].ToString();
                    param3.Value = null == code[1] ? string.Empty : code[1].ToString();
                    parameters.Add(param2);
                    parameters.Add(param3);
                }
                //病种IDs
                string IDs = string.Join("$", checkedList.Select(p => p["ICD"].ToString()).ToArray());
                if (string.IsNullOrEmpty(IDs))
                {
                    DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show("请在列表中勾选组合病种");
                    return;
                }
                SqlParameter param4 = new SqlParameter("@diseaseids", SqlDbType.Char);
                param4.Value = IDs;
                parameters.Add(param4);
                //是否有效
                SqlParameter param5 = new SqlParameter("@valid", SqlDbType.Int);
                param5.Value = 1;
                parameters.Add(param5);
                if (groupID == -1)
                {//新增
                    //创建人
                    SqlParameter param6 = new SqlParameter("@create_user", SqlDbType.Char);
                    param6.Value = DS_Common.currentUser.Id;
                    parameters.Add(param6);
                    //创建时间
                    SqlParameter param7 = new SqlParameter("@create_time", SqlDbType.Char);
                    param7.Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    parameters.Add(param7);
                }
                else
                {//编辑
                    //更新人
                    SqlParameter param8 = new SqlParameter("@updateuser", SqlDbType.Char);
                    param8.Value = DS_Common.currentUser.Id;
                    parameters.Add(param8);
                    //更新时间
                    SqlParameter param9 = new SqlParameter("@updatetime", SqlDbType.Char);
                    param9.Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    parameters.Add(param9);
                }
                //备注
                if (!string.IsNullOrEmpty(this.txt_memo.Text.Trim()))
                {
                    SqlParameter param10 = new SqlParameter("@memo", SqlDbType.Char);
                    param10.Value = this.txt_memo.Text;
                    parameters.Add(param10);
                }

                //保存(插入、更新)组合记录
                if (groupID == -1)
                {
                    int result = DS_SqlService.InsertDiseaseGroup(parameters);
                    if (result == 1)
                    {
                        DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show("新增成功");
                    }
                }
                else
                {
                    SqlParameter param10 = new SqlParameter("@id", SqlDbType.Int);
                    param10.Value = groupID;
                    parameters.Add(param10);
                    int result = DS_SqlService.UpdateDiseaseGroup(parameters);
                    if (result == 1)
                    {
                        DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show("编辑成功");
                    }
                }

                if (this.chb_continue.Checked)
                {//连续新增
                    groupID = -1;
                    ClearPage();
                }
                else
                {
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show(1, ex);
            }
        }