Exemplo n.º 1
0
        private void BindChildNode(TreeNode tnTop)
        {
            dbvwNumberInfo  vw    = new dbvwNumberInfo();
            dbtblNumberInfo num   = new dbtblNumberInfo();
            int             i     = Convert.ToInt32(tnTop.Tag.ToString());
            int             t_sex = num.GetPersonSex(i);

            if (t_sex == 1)//女族人
            {
                DataTable db = num.MotherGetChilDataTable(i);
                for (int j = 0; j < db.Rows.Count; j++)
                {
                    TreeNode node = new TreeNode();
                    node.Tag = db.Rows[j]["NiId"];
                    if (num.GetPersonSex(Convert.ToInt32(db.Rows[j]["NiId"])) == 1)
                    {
                        node.Text = "女:" + db.Rows[j]["NiName"].ToString();
                    }
                    else
                    {
                        node.Text = "男:" + db.Rows[j]["NiName"].ToString();
                    }
                    tnTop.Nodes.Add(node);
                    if (num.GetChildCount(i) != 0)
                    {
                        BindChildNode(node);
                    }
                }
            }
            else if (t_sex == 0)//女族人
            {
                DataTable db = num.FatherGetChilDataTable(i);
                for (int j = 0; j < db.Rows.Count; j++)
                {
                    TreeNode node = new TreeNode();
                    node.Tag = db.Rows[j]["NiId"];
                    if (num.GetPersonSex(Convert.ToInt32(db.Rows[j]["NiId"])) == 1)
                    {
                        node.Text = "女:" + db.Rows[j]["NiName"].ToString();
                    }
                    else
                    {
                        node.Text = "男:" + db.Rows[j]["NiName"].ToString();
                    }
                    tnTop.Nodes.Add(node);
                    if (num.GetChildCount(i) != 0)
                    {
                        BindChildNode(node);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void InitMenuTreeView()
        {
            dbvwNumberInfo vw = new dbvwNumberInfo();
            DataTable      db = vw.GetAllDataFrom_vwNumberInfo();

            trvMenu.Nodes.Clear();
            /*加载先祖*/
            DataTable xianzu = vw.GetFirstPerson();

            if (xianzu.Rows.Count == 1)
            {
                /*顶级节点*/
                TreeNode tnTop = new TreeNode();
                tnTop.Text = xianzu.Rows[0]["姓名"].ToString();
                tnTop.Tag  = xianzu.Rows[0]["NiId"];
                trvMenu.Nodes.Add(tnTop);
                BindChildNode(tnTop);
            }
            trvMenu.ExpandAll();
        }
Exemplo n.º 3
0
 private void trvMenu_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     try
     {
         TreeNode node = trvMenu.SelectedNode;
         if (node.Tag != null)
         {
             changeNull();
             trvSon.Nodes.Clear();
             int            i      = Convert.ToInt32(node.Tag);
             dbvwNumberInfo num    = new dbvwNumberInfo();
             DataTable      person = num.GetPersonInfo(Convert.ToInt32(i));
             lblbianhao.Text      = i.ToString();
             txtNumNmae.Text      = person.Rows[0]["姓名"].ToString();
             txtnumSex.Text       = person.Rows[0]["性别"].ToString();
             txtnumAge.Text       = person.Rows[0]["年龄"].ToString();
             txtnumjob.Text       = person.Rows[0]["工作"].ToString();
             txtnumaddress.Text   = person.Rows[0]["NiAddress"].ToString();
             txttimeBirth.Text    = person.Rows[0]["NiBirthDay"].ToString();
             txtfather.Text       = person.Rows[0]["父亲"].ToString();
             txtmother.Text       = person.Rows[0]["母亲"].ToString();
             txtnumpeiou.Text     = person.Rows[0]["配偶"].ToString();
             txtdieDay.Text       = person.Rows[0]["NiDIeDay"].ToString();
             txtnumlifestory.Text = person.Rows[0]["NiLifeStory"].ToString();
             TreeNode tnTop = new TreeNode();
             tnTop.Text = person.Rows[0]["姓名"].ToString();
             tnTop.Tag  = person.Rows[0]["NiId"];
             trvSon.Nodes.Add(tnTop);
             BindChildNode(tnTop);
             trvSon.ExpandAll();
         }
     }
     catch (Exception exception)
     {
         // MessageBox.Show(exception.Message);
     }
 }
Exemplo n.º 4
0
        private void FrmPersonInfo_Load(object sender, EventArgs e)
        {
            try
            {
                this.Text = "添加孩子";
                FontFamily myFontFamily = new FontFamily("幼圆"); //采用哪种字体
                this.Font = new System.Drawing.Font(myFontFamily, 9, FontStyle.Regular);
                dbvwNumberInfo num       = new dbvwNumberInfo();
                DataTable      person    = num.GetPersonInfo(id);
                int            sexparent = num.GetPersonSex(id);

                if (sexparent == 0) //如果是男的
                {
                    fatherId       = Convert.ToInt32(person.Rows[0]["NiId"]);
                    motherId       = Convert.ToInt32(person.Rows[0]["NiSpouseId"]);
                    txtmother.Text = person.Rows[0]["配偶"].ToString();
                    txtfather.Text = person.Rows[0]["姓名"].ToString();
                }
                else
                {
                    motherId       = Convert.ToInt32(person.Rows[0]["NiId"]);
                    fatherId       = Convert.ToInt32(person.Rows[0]["NiSpouseId"]);
                    txtfather.Text = person.Rows[0]["姓名"].ToString();
                    txtmother.Text = person.Rows[0]["配偶"].ToString();
                }
                cbxIsDie.SelectedIndex   = 0;
                cbxSexName.SelectedIndex = 0;
                txtmother.Enabled        = false;
                txtfather.Enabled        = false;
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
                throw;
            }
        }
Exemplo n.º 5
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtNumNmae.Text == "")
         {
             MessageBox.Show("请输入名称", "提示");
             return;
         }
         if (txtnumjob.Text == "")
         {
             MessageBox.Show("请输入职业", "提示");
             return;
         }
         if (dtpOne.IsNull())
         {
             MessageBox.Show("请输入出生日期", "提示");
             return;
         }
         DateTime dtlast = new DateTime();
         DateTime dt     = Convert.ToDateTime(dtpOne.Text);
         Rule     Rle    = new Rule();
         bool     iscan  = Rle.CheckHavePeiOu(dt, GetID);
         if (!iscan)
         {
             MessageBox.Show("配偶出生日期不符合配偶规则!(可查看具体规则)", "不符");
             return;
         }
         string dieday       = "NULL";
         bool   IsHaveDieDay = false;
         if (txtDieDay.Text != "")
         {
             bool isdate = ValueJudge.IsDateTime(txtDieDay.Text);
             if (!isdate)
             {
                 MessageBox.Show("日期格式错诶!", "不符");
                 return;
             }
             dtlast = Convert.ToDateTime(txtDieDay.Text);
             if (dtlast < dt)
             {
                 MessageBox.Show("请输入正确时间", "提示");
                 return;
             }
             IsHaveDieDay = true;
             dieday       = dtlast.ToString();
         }
         else
         {
         }
         if (txtnumaddress.Text == "")
         {
             MessageBox.Show("请输入地址", "提示");
             return;
         }
         if (txtnumlifestory.Text == "")
         {
             MessageBox.Show("请输入生平事迹", "提示");
             return;
         }
         string state = "";
         if (cbxDieNow.SelectedIndex == 1)
         {
             state = "40";
         }
         else
         {
             state = "30";
         }
         if (IsHaveDieDay && cbxDieNow.SelectedIndex == 0)
         {
             MessageBox.Show("此人既有死亡日期!又被标定为健在!逻辑不符合", "错误");
             return;
         }
         string sql = String.Format("insert into [Family].[dbo].[tblNumberInfo] " +
                                    "( [JobID],[NiName],[NiSex],[NiSpouseId] ,[NiBirthDay],[NiDIeDay],[NiFatherId],[NiMotherId],[NiPicture],[NiAddress],[NiLifeStory],[Nistate]) " +
                                    "values('{0}','{1}',{2},{3},cast('{4}' as datetime2),{5},{6},{7},NULL,'{8}','{9}',{10})", txtnumjob.Text, txtNumNmae.Text, PeiOuSex, GetID, dtpOne.Text, dieday, -1, -1, txtnumaddress.Text.Replace("\'", "\'\'"), txtnumlifestory.Text.Replace("\'", "\'\'"), state);
         dbvwNumberInfo vw = new dbvwNumberInfo();
         vw.CarryOutSqlSentence(sql);
         dbConnection db = new dbConnection();
         string       ID = db.CarryOutSqlGetFirstColmun(String.Format(
                                                            "select NiId from [Family].[dbo].[tblNumberInfo] where  JobID ='{0}' and  NiName='{1}' and NiSpouseId={2} and NiFatherId =-1 and NiBirthDay ='{3}'",
                                                            txtnumjob.Text, txtNumNmae.Text, GetID, dtpOne.Text));
         db.CarryOutSqlSentence("update [Family].[dbo].[tblNumberInfo] set NiSpouseId =" + ID + " where  NiId= " + GetID);
         MessageBox.Show("添加成功", "提示");
         changeNull();
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message + exception.StackTrace);
     }
 }
Exemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            dbvwNumberInfo num       = new dbvwNumberInfo();
            DataTable      td        = num.GetAllDataFrom_vwNumberInfo("Nistate = 30");
            int            zero_10   = 0;
            int            shi_20    = 0;
            int            ErShi_30  = 0;
            int            SanShi_40 = 0;
            int            shiwu_50  = 0;
            int            wushi_60  = 0;
            int            liushi_70 = 0;
            int            qishi_80  = 0;
            int            bashi_90  = 0;
            int            jiushi_Up = 0;

            for (int i = 0; i < td.Rows.Count; i++)
            {
                int NianLing = Convert.ToInt32(td.Rows[i]["年龄"]);
                switch (NianLing / 10)
                {
                case 0:
                {
                    zero_10++;
                } break;

                case 1:
                {
                    shi_20++;
                } break;

                case 2:
                {
                    ErShi_30++;
                } break;

                case 3:
                {
                    SanShi_40++;
                } break;

                case 4:
                {
                    shiwu_50++;
                } break;

                case 5:
                {
                    wushi_60++;
                } break;

                case 6:
                {
                    liushi_70++;
                } break;

                case 7:
                {
                    qishi_80++;
                } break;

                case 8:
                {
                    bashi_90++;
                } break;

                default:
                    jiushi_Up++;
                    break;
                }
            }
            //清除默认的series
            CharNainFenBu.Series.Clear();
            //new 一个叫做【Strength】的系列
            Series Strength = new Series("人员数量");

            //设置chart的类型,这里为柱状图
            Strength.ChartType = SeriesChartType.Column;
            //给系列上的点进行赋值,分别对应横坐标和纵坐标的值
            Strength.Points.AddXY("0~10", zero_10);
            Strength.Points.AddXY("10~20", shi_20);
            Strength.Points.AddXY("20~30", ErShi_30);
            Strength.Points.AddXY("30~40", SanShi_40);
            Strength.Points.AddXY("40~50", shiwu_50);
            Strength.Points.AddXY("50~60", wushi_60);
            Strength.Points.AddXY("60~70", liushi_70);
            Strength.Points.AddXY("70~80", qishi_80);
            Strength.Points.AddXY("80~90", bashi_90);
            Strength.Points.AddXY("90~", jiushi_Up);
            //把series添加到chart上
            CharNainFenBu.Series.Add(Strength);
        }
Exemplo n.º 7
0
        private void ShowData()
        {
            dbConnection con            = new dbConnection();
            string       AllPeople      = con.CarryOutSqlGetFirstColmun("select count(*) from  [Family].[dbo].[tblNumberInfo]");
            double       countAllPeople = Convert.ToDouble(AllPeople);

            RsAllPeopleCount.Height = 200;
            RsAllPeopleCount.Width  = 25;
            lblAll.Text             = "总人数:" + countAllPeople;
            dbvwNumberInfo num                = new dbvwNumberInfo();
            DataTable      td                 = num.GetAllDataFrom_vwNumberInfo();
            int            sexCountGirl       = 0;
            int            sexCountBoy        = 0;
            int            weichengnian       = 0;
            int            lblLifeCount       = 0; //当前健在人口
            int            lblTillNowDieCount = 0; /*目前为止先祖人口*/
            int            lblNowDanCount     = 0; /*当前单身人数*/
            int            lblJiaZuJiCount    = 0; /*未记载*/
            int            BoyNowStillLfe     = 0;
            int            GirlNowLifeStill   = 0;
            int            JianZiaWeicheng    = 0;

            for (int i = 0; i < td.Rows.Count; i++)
            {
                if (td.Rows[i]["NiSex"].ToString() == "True")
                {
                    sexCountGirl++;
                }
                else
                {
                    sexCountBoy++;
                }
                if (Convert.ToInt32(td.Rows[i]["年龄"]) < 18)
                {
                    weichengnian++;
                }

                /*统计健在人口*/
                if (td.Rows[i]["Nistate"].ToString() == "30")
                {
                    lblLifeCount++;
                }
                /*统计死亡人口*/
                if (td.Rows[i]["Nistate"].ToString() == "40")
                {
                    lblTillNowDieCount++;
                }
                if (td.Rows[i]["配偶"].ToString() == "未记载" && td.Rows[i]["Nistate"].ToString() == "30")
                {
                    lblNowDanCount++;
                }
                if (td.Rows[i]["NiLifeStory"].ToString() == "" || td.Rows[i]["NiLifeStory"].ToString().Length < 50)
                {
                    lblJiaZuJiCount++;
                }
                if (td.Rows[i]["Nistate"].ToString() == "30" && td.Rows[i]["性别"].ToString() == "男")
                {
                    BoyNowStillLfe++;
                }
                if (td.Rows[i]["Nistate"].ToString() == "30" && td.Rows[i]["性别"].ToString() == "女")
                {
                    GirlNowLifeStill++;
                }
                if (Convert.ToInt32(td.Rows[i]["年龄"]) < 18 && td.Rows[i]["Nistate"].ToString() == "30")
                {
                    JianZiaWeicheng++;
                }
            }
            lblLifeCountNow.Text       = lblLifeCount.ToString();       /*显示健在总人口*/
            lblTillNowDieCountNow.Text = lblTillNowDieCount.ToString(); //显示死亡人口
            lblNowDanCountNow.Text     = lblNowDanCount.ToString();     /*单身人数*/
            lblJiZaiWithOut.Text       = lblJiaZuJiCount.ToString();    /*记载*/
            lblLifeGrilNow.Text        = GirlNowLifeStill.ToString();
            lblLifeBoyNow.Text         = BoyNowStillLfe.ToString();
            lblWhouChengNian.Text      = JianZiaWeicheng.ToString();
            lblWEichengnian.Text       = "未成年:" + weichengnian;
            lblGirl.Text          = "女生:" + sexCountGirl;
            lblBoy.Text           = "男生:" + sexCountBoy;
            RSGrilCount.Height    = Convert.ToInt32((sexCountGirl / countAllPeople) * 200);
            RSBoyCount.Height     = Convert.ToInt32((sexCountBoy / countAllPeople) * 200);
            CRWeichengNain.Height = Convert.ToInt32((weichengnian / countAllPeople) * 200);
            GetDate();
        }
Exemplo n.º 8
0
        private void btnsave_Click(object sender, EventArgs e)
        {
            int bianhao = Convert.ToInt32(lblbianhao.Text);

            if (txtNumNmae.Text == "")
            {
                MessageBox.Show("请输入名称", "提示");
                return;
            }
            if (txtnumjob.Text == "")
            {
                MessageBox.Show("请输入职业", "提示");
                return;
            }
            if (txtnumaddress.Text == "")
            {
                MessageBox.Show("请输入常住地址", "提示");
                return;
            }
            if (txtnumlifestory.Text == "")
            {
                MessageBox.Show("请输入生平事迹", "提示");
                return;
            }
            if (txttimeBirth.Text == "")
            {
                MessageBox.Show("请输入出生日期", "提示");
                return;
            }

            if (!ValueJudge.IsDateTime(txttimeBirth.Text))
            {
                MessageBox.Show("请输入正确格式的出生日期", "提示");
                return;
            }
            DateTime one = new DateTime();

            if (txtdieDay.Text != "")
            {
                if (!ValueJudge.IsDateTime(txtdieDay.Text))
                {
                    MessageBox.Show("请输入正确格式的死亡日期", "提示");
                    return;
                }
                one = Convert.ToDateTime(txttimeBirth.Text);
                DateTime tcTwo = Convert.ToDateTime(txtdieDay.Text);
                if (tcTwo <= one)
                {
                    MessageBox.Show("日期错误!死亡日期与出生日期不符合常理", "警告");
                    return;
                }
            }
            string sql =
                String.Format("update Family.dbo.tblNumberInfo set  [JobID]='{0}' ,NiName ='{1}' ,[NiBirthDay] ='{2}',NiDIeDay='{3}' ,NiAddress='{4}',[NiLifeStory]='{5}' where NiId ={6}",
                              txtnumjob.Text, txtNumNmae.Text, txttimeBirth.Text, txtdieDay.Text, txtnumaddress.Text, txtnumlifestory.Text, bianhao.ToString()
                              );

            if (txtdieDay.Text != "")
            {
                sql =
                    String.Format("update Family.dbo.tblNumberInfo set  [JobID]='{0}' ,NiName ='{1}' ,[NiBirthDay] ='{2}',NiDIeDay='{3}' ,NiAddress='{4}',[NiLifeStory]='{5}' , Nistate =40  where NiId ={6}",
                                  txtnumjob.Text, txtNumNmae.Text, txttimeBirth.Text, txtdieDay.Text, txtnumaddress.Text, txtnumlifestory.Text, bianhao.ToString()
                                  );
            }
            dbConnection db = new dbvwNumberInfo();

            db.CarryOutSqlSentence(sql);
            MessageBox.Show("修改成功", "成功");
            EnableFalse();
            btnsave.Visible           = false;
            button2.Visible           = false;
            lblDieDescription.Visible = false;
        }
Exemplo n.º 9
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtNumNmae.Text == "")
                {
                    MessageBox.Show("请输入名称", "提示");
                    return;
                }
                if (txtnumjob.Text == "")
                {
                    MessageBox.Show("请输入职业", "提示");
                    return;
                }
                DateTime dt      = Convert.ToDateTime(dtpOne.Text);
                Rule     esrRule = new Rule();
                bool     canhave = esrRule.CheckCanHaveSon(dt, id);
                if (!canhave)
                {
                    MessageBox.Show("孩子出生日期不符合孩子规则!(可查看具体规则)", "不符");
                    return;
                }
                DateTime dtlast;
                if (txtDieDay.Text != "")
                {
                    dtlast = Convert.ToDateTime(txtDieDay.Text);
                    if (dtlast < dt)
                    {
                        MessageBox.Show("请输入正确时间格式", "提示");
                        return;
                    }
                }
                else
                {
                    txtDieDay.Text = "NULL";
                }

                if (cbxIsDie.SelectedIndex == 1 && txtDieDay.Text != "")
                {
                    MessageBox.Show("此人健在无法添加死亡日期", "提示");
                    return;
                }

                if (txtnumaddress.Text == "")
                {
                    MessageBox.Show("请输入地址", "提示");
                    return;
                }
                if (txtnumlifestory.Text == "")
                {
                    MessageBox.Show("请输入生平事迹", "提示");
                    return;
                }
                string state = "";
                if (cbxIsDie.SelectedIndex == 1)
                {
                    state = "40";
                }
                else
                {
                    state = "30";
                }
                string codesex = cbxSexName.SelectedIndex.ToString();
                string strTime = dt.ToString();
                string sql     = "";
                if (txtDieDay.Text != "")
                {
                    sql = String.Format("insert into [Family].[dbo].[tblNumberInfo] " +
                                        "( [JobID],[NiName],[NiSex],[NiSpouseId] ,[NiBirthDay],[NiDIeDay],[NiFatherId],[NiMotherId],[NiPicture],[NiAddress],[NiLifeStory],[Nistate]) " +
                                        "values('{0}','{1}',{2},NULL,cast('{3}' as datetime2),{4},{5},{6},NULL,'{7}','{8}',{9})", txtnumjob.Text, txtNumNmae.Text, codesex, strTime, txtDieDay.Text, fatherId, motherId, txtnumaddress.Text, txtnumlifestory.Text, state);
                }
                else
                {
                    sql = String.Format("insert into [Family].[dbo].[tblNumberInfo] " +
                                        "( [JobID],[NiName],[NiSex],[NiSpouseId] ,[NiBirthDay],[NiDIeDay],[NiFatherId],[NiMotherId],[NiPicture],[NiAddress],[NiLifeStory],[Nistate]) " +
                                        "values('{0}','{1}',{2},NULL,cast('{3}' as datetime2),cast('{4}' as datetime2),{5},{6},NULL,'{7}','{8}',{9})", txtnumjob.Text, txtNumNmae.Text, codesex, strTime, txtDieDay.Text, fatherId, motherId, txtnumaddress.Text, txtnumlifestory.Text, state);
                }
                dbvwNumberInfo vw = new dbvwNumberInfo();
                vw.CarryOutSqlSentence(sql);
                MessageBox.Show("添加成功", "提示");
                ChengNull();
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                throw;
            }
        }