Example #1
0
        /* ================ Tab3 ================ */

        /* ################ Tab4 ################ */
        private void AddGroupBtn_Click(object sender, EventArgs e)
        {
            Intent.dict["ADD_OR_CHANGE"] = "ADD";

            GroupEdit ge = new GroupEdit();

            if (ge.ShowDialog() == DialogResult.OK)
            {
                Group g = ge.g;

                sqlString = @"" +
                            " INSERT INTO [Group]" +
                            " VALUES" +
                            " (" +
                            "   " + g.GroupNo + "," +
                            "   '" + g.GroupName + "'," +
                            "   '" + g.DeptNo + "'," +
                            "   " + g.Month + "," +
                            "   " + g.Number + "" +
                            " )";
                db.SetBySQL(sqlString);
            }

            UpdateListView();
        }
Example #2
0
        private void ChangeGroupBtn_Click(object sender, EventArgs e)
        {
            if (listView4.SelectedItems.Count == 0)
            {
                MessageBox.Show("请选择一行");
                return;
            }


            Intent.dict["ADD_OR_CHANGE"] = "CHANGE";

            GroupEdit ge = new GroupEdit();
            Group     g  = new Group();

            g.SetValue(
                listView4.SelectedItems[0].SubItems[0].Text,
                listView4.SelectedItems[0].SubItems[1].Text,
                listView4.SelectedItems[0].SubItems[2].Text,
                listView4.SelectedItems[0].SubItems[3].Text,
                listView4.SelectedItems[0].SubItems[4].Text
                );
            ge.g = g;
            Intent.dict["OLD_ID"] = g.GroupNo;

            if (ge.ShowDialog() == DialogResult.OK)
            {
                sqlString = @"" +
                            " UPDATE [Group]" +
                            " SET" +
                            "   [GroupNo]=" + g.GroupNo + "," +
                            "   [GroupName]='" + g.GroupName + "'," +
                            "   [DeptNo]='" + g.DeptNo + "'," +
                            "   [Month]=" + g.Month + "," +
                            "   [Number]=" + g.Number +
                            " WHERE [GroupNo]=" + Intent.dict["OLD_ID"] + "";
                db.SetBySQL(sqlString);
                UpdateListView();


                // 最多病人和最少病人查询
                sqlString = @"" +
                            " SELECT *" +
                            " FROM [Group]" +
                            " WHERE [GroupNo] NOT IN" +
                            " (" +
                            " 	SELECT g1.[GroupNo]"+
                            " 	FROM [Group] g1, [Group] g2"+
                            " 	WHERE g1.[Number]<g2.[Number]"+
                            " )" +
                            " UNION" +
                            " SELECT *" +
                            " FROM [Group]" +
                            " WHERE [GroupNo] NOT IN" +
                            " (" +
                            " 	SELECT g1.[GroupNo]"+
                            " 	FROM [Group] g1, [Group] g2"+
                            " 	WHERE g1.[Number]>g2.[Number]"+
                            " )";

                table = db.GetBySQL(sqlString);
                listView4.Clear();

                // 设置表头
                listView4.Columns.Add("小科室号", listView4.Width / 5 - 1);
                listView4.Columns.Add("小科室名", listView4.Width / 5 - 1);
                listView4.Columns.Add("所属大科室号", listView4.Width / 5 - 1);
                listView4.Columns.Add("统计月份", listView4.Width / 5 - 1);
                listView4.Columns.Add("病人人数", listView4.Width / 5 - 1);

                FillListView(listView4);
                MessageBox.Show("请查看最多病人和最少病人的小科室!");
            }
        }