private void DeleteAllDateTSM_Click(object sender, EventArgs e)
 {
     if (IsCan == 20)
     {
         MessageBox.Show("你暂时未有此项权限", "提示");
         return;
     }
     if (System.Windows.Forms.MessageBox.Show("你确定要删除所有数据吗?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
     {
         if (System.Windows.Forms.MessageBox.Show("请你再次慎重考虑是否重建家谱!", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
         {
             dbConnection db = new dbConnection();
             db.CarryOutSqlSentence("  truncate table [Family].[dbo].[tblNumberInfo]");
             MessageBox.Show("已经清空!", "提示");
         }
     }
 }
 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);
     }
 }