Ejemplo n.º 1
0
        /// <summary>
        /// 刷新范围树
        /// </summary>
        public void RefleshTrv()
        {
            try
            {
                //小科室
                string Sql_Section = "select a.*,b.sub_hospital_name from t_sectioninfo a inner join T_SUB_HOSPITALINFO b on a.shid=b.shid  where ISBELONGTOBIGSECTION='N' and ENABLE_FLAG='Y' and a.sid in (select sid from T_SECTION_AREA)";

                //小病区
                string Sql_SickArea = "select a.*,b.sub_hospital_name from t_sickareainfo a inner join T_SUB_HOSPITALINFO b on a.shid=b.shid where ISBELONGTOSECTION='N' and ENABLE_FLAG='Y'";

                //大科室
                string Sql_Big_Section = "select a.*,b.sub_hospital_name from t_sectioninfo a inner join T_SUB_HOSPITALINFO b on a.shid=b.shid where ISBELONGTOBIGSECTION='Y' and ENABLE_FLAG='Y' and a.sid in (select sid from T_SECTION_AREA)";

                //大病区
                string Sql_Big_SickArea = "select a.*,b.sub_hospital_name from t_sickareainfo a inner join T_SUB_HOSPITALINFO b on a.shid=b.shid where ISBELONGTOSECTION='Y' and ENABLE_FLAG='Y'";

                chkListRanges.Items.Clear();
                if (rdbArea.Checked)
                {
                    if (cboSubHospital.Text != "全部科室/病区")
                    {
                        Sql_SickArea = Sql_SickArea + " and a.SHID=" + cboSubHospital.SelectedValue.ToString() + "";
                    }
                    else
                    {
                        Sql_SickArea = Sql_SickArea + " order by a.sick_area_name,a.said";
                    }
                    DataSet ds = App.GetDataSet(Sql_SickArea);
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        Class_Rnage temprage = new Class_Rnage();
                        temprage.Acc_role_id = Acc_Role_Id;
                        temprage.Rnagename   = ds.Tables[0].Rows[i]["sick_area_name"].ToString();
                        temprage.Sickarea_id = ds.Tables[0].Rows[i]["said"].ToString();
                        temprage.Section_id  = "0";
                        temprage.Isbelonge   = "1";
                        chkListRanges.Items.Add(temprage);
                        chkListRanges.DisplayMember = "Rnagename";
                    }
                }
                else if (rdbBigArea.Checked)
                {
                    if (cboSubHospital.Text != "全部科室/病区")
                    {
                        Sql_Big_SickArea = Sql_Big_SickArea + " and a.SHID=" + cboSubHospital.SelectedValue.ToString() + "";
                    }
                    else
                    {
                        Sql_Big_SickArea = Sql_Big_SickArea + " order by a.sick_area_name,a.said";
                    }
                    DataSet ds = App.GetDataSet(Sql_Big_SickArea);
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        Class_Rnage temprage = new Class_Rnage();
                        temprage.Acc_role_id = Acc_Role_Id;
                        temprage.Rnagename   = ds.Tables[0].Rows[i]["sick_area_name"].ToString();
                        temprage.Sickarea_id = ds.Tables[0].Rows[i]["said"].ToString();
                        temprage.Section_id  = "0";
                        temprage.Isbelonge   = "1";
                        chkListRanges.Items.Add(temprage);
                        chkListRanges.DisplayMember = "Rnagename";
                    }
                }
                else if (rdbBigSection.Checked)
                {
                    if (cboSubHospital.Text != "全部科室/病区")
                    {
                        Sql_Big_Section = Sql_Big_Section + " and a.SHID=" + cboSubHospital.SelectedValue.ToString() + "";
                    }
                    else
                    {
                        Sql_Big_Section = Sql_Big_Section + " order by a.section_name,a.sid";
                    }
                    DataSet ds = App.GetDataSet(Sql_Big_Section);
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        Class_Rnage temprage = new Class_Rnage();
                        temprage.Acc_role_id = "0";
                        temprage.Rnagename   = ds.Tables[0].Rows[i]["section_name"].ToString();
                        temprage.Sickarea_id = "0";
                        temprage.Section_id  = ds.Tables[0].Rows[i]["sid"].ToString();
                        temprage.Isbelonge   = "0";
                        chkListRanges.Items.Add(temprage);
                        chkListRanges.DisplayMember = "Rnagename";
                    }
                }
                else
                {
                    if (cboSubHospital.Text == "全部科室/病区")
                    {
                        if (App.UserAccount.UserInfo.User_name == "管理员")
                        {
                            Sql_Section = Sql_Section + " order by a.section_name,a.sid";
                        }
                        else
                        {
                            string sectionIds = "";
                            for (int i = 0; i < App.UserAccount.Roles.Length; i++)
                            {
                                if (App.UserAccount.Roles[i].Role_name == "科主任")
                                {
                                    for (int j = 0; j < App.UserAccount.Roles[i].Rnages.Length; j++)
                                    {
                                        if (sectionIds == "")
                                        {
                                            sectionIds = App.UserAccount.Roles[i].Rnages[j].Section_id;
                                        }
                                        else
                                        {
                                            sectionIds += "," + App.UserAccount.Roles[i].Rnages[j].Section_id;
                                        }
                                    }
                                }
                            }
                            Sql_Section = Sql_Section + " and sid in(" + sectionIds + ") order by a.section_name,a.sid";
                        }
                    }
                    else
                    {
                        Sql_Section = Sql_Section + " and a.SHID=" + cboSubHospital.SelectedValue.ToString() + "";
                    }
                    DataSet ds = App.GetDataSet(Sql_Section);
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        Class_Rnage temprage = new Class_Rnage();
                        temprage.Acc_role_id = "0";
                        temprage.Rnagename   = ds.Tables[0].Rows[i]["section_name"].ToString();
                        temprage.Sickarea_id = "0";
                        temprage.Section_id  = ds.Tables[0].Rows[i]["sid"].ToString();
                        temprage.Isbelonge   = "0";
                        chkListRanges.Items.Add(temprage);
                        chkListRanges.DisplayMember = "Rnagename";
                    }
                }


                for (int i = 0; i < chkListRanges.Items.Count; i++)
                {
                    for (int j = 0; j < CurrentRanges.Count; j++)
                    {
                        Class_Rnage temprage = (Class_Rnage)chkListRanges.Items[i];
                        if (temprage.Rnagename == CurrentRanges[j].ToString())
                        {
                            chkListRanges.SetItemChecked(i, true);
                        }
                    }
                }
            }
            catch
            { }
        }
Ejemplo n.º 2
0
        private void btnSure_Click(object sender, EventArgs e)
        {
            if (App.UserAccount.UserInfo.User_name != "管理员")
            {
                ucSectionkeep.trvTempRoleRange = new TreeView();
            }
            else
            {
                frmAccount.trvTempRoleRange = new TreeView();
            }
            for (int i = 0; i < chkListRanges.CheckedItems.Count; i++)
            {
                TreeNode    tn       = new TreeNode();
                Class_Rnage temprage = (Class_Rnage)chkListRanges.CheckedItems[i];

                if (rdbBigSection.Checked)            //判断是大科室,还是小科室
                {
                    //获得大科室下的所有小科室
                    string  sql = "select * from t_sectioninfo where ISBELONGTOBIGSECTION='N' and BELONGTO_BIGSECTION_ID='" + temprage.Section_id + "'";
                    DataSet ds  = App.GetDataSet(sql);
                    for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                    {
                        TreeNode    tnSmall      = new TreeNode();
                        Class_Rnage smallSection = new Class_Rnage();
                        smallSection.Acc_role_id = "0";
                        smallSection.Rnagename   = ds.Tables[0].Rows[j]["section_name"].ToString();
                        smallSection.Sickarea_id = "0";
                        smallSection.Section_id  = ds.Tables[0].Rows[j]["sid"].ToString();
                        smallSection.Isbelonge   = "0";

                        tnSmall.Tag  = smallSection;
                        tnSmall.Text = smallSection.Rnagename;
                        if (App.UserAccount.UserInfo.User_name != "管理员")
                        {
                            ucSectionkeep.trvTempRoleRange.Nodes.Add(tnSmall);
                        }
                        else
                        {
                            frmAccount.trvTempRoleRange.Nodes.Add(tnSmall);
                        }
                    }
                }
                else if (rdbBigArea.Checked)       //判断是大病区,还是小病区
                {
                    //获得大病区下的所有小病区
                    string  sql = "select * from t_sickareainfo where ISBELONGTOSECTION='N' and BELONGTOSECTION='" + temprage.Sickarea_id + "'";
                    DataSet ds  = App.GetDataSet(sql);
                    for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                    {
                        TreeNode    tnSmall   = new TreeNode();
                        Class_Rnage smallArea = new Class_Rnage();
                        smallArea.Acc_role_id = Acc_Role_Id;
                        smallArea.Rnagename   = ds.Tables[0].Rows[j]["sick_area_name"].ToString();
                        smallArea.Sickarea_id = ds.Tables[0].Rows[j]["said"].ToString();
                        smallArea.Section_id  = "0";
                        smallArea.Isbelonge   = "1";
                        tnSmall.Tag           = smallArea;
                        tnSmall.Text          = smallArea.Rnagename;
                        if (App.UserAccount.UserInfo.User_name != "管理员")
                        {
                            ucSectionkeep.trvTempRoleRange.Nodes.Add(tnSmall);
                        }
                        else
                        {
                            frmAccount.trvTempRoleRange.Nodes.Add(tnSmall);
                        }
                    }
                }
                else
                {
                    tn.Tag  = temprage;
                    tn.Text = temprage.Rnagename;
                    if (App.UserAccount.UserInfo.User_name != "管理员")
                    {
                        ucSectionkeep.trvTempRoleRange.Nodes.Add(tn);
                    }
                    else
                    {
                        frmAccount.trvTempRoleRange.Nodes.Add(tn);
                    }
                }
            }
            this.Close();
        }