Example #1
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;
        }
Example #2
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);
     }
 }
Example #3
0
 private void tpTwobtnSerach_Click(object sender, EventArgs e)
 {
     try
     {
         string sql = "SELECT [族编号] ,[工作] ,[姓名] ,[性别] ,[出生日期] ,[年龄] ,[配偶],[父亲],[母亲],[状态],[NiAddress] as '地址'  FROM [Family].[dbo].[vwNumberInfo] where [族编号] >0";
         if (txtName.Text != "")
         {
             sql += " and  [姓名] like '%" + txtName.Text.Trim() + "%'";
         }
         if (txtJobName.Text != "")
         {
             sql += " and [工作] like '%" + txtJobName.Text.Trim() + "%'";
         }
         if (cbxSex.SelectedIndex != 2)
         {
             if (cbxSex.SelectedIndex == 0)
             {
                 sql += " and [性别]='男'";
             }
             else if (cbxSex.SelectedIndex == 1)
             {
                 sql += " and [性别]='女'";
             }
         }
         if (cbxHunyin.SelectedIndex != 2)
         {
             if (cbxHunyin.SelectedIndex == 0)
             {
                 sql += " and [配偶]!='未婚配'";
             }
             else if (cbxHunyin.SelectedIndex == 1)
             {
                 sql += " and [配偶] ='未婚配'";
             }
         }
         if (txtAgeDown.Text != "")
         {
             bool isInt = ValueJudge.IsInt(txtAgeDown.Text);
             if (!isInt)
             {
                 MessageBox.Show("请输入整数", "输入错误");
                 return;
             }
             sql += " and [年龄] >=" + txtAgeDown.Text;
         }
         if (txtAgeUp.Text != "")
         {
             bool isInt = ValueJudge.IsInt(txtAgeUp.Text);
             if (!isInt)
             {
                 MessageBox.Show("请输入整数", "输入错误");
                 return;
             }
             sql += " and [年龄] <=" + txtAgeUp.Text;
         }
         if (cbxDie.SelectedIndex != 2)
         {
             if (cbxDie.SelectedIndex == 0)
             {
                 sql += " and [Nistate]= 40";
             }
             else if (cbxDie.SelectedIndex == 1)
             {
                 sql += " and [Nistate] =30";
             }
         }
         DateTime one = Convert.ToDateTime(DtpOne.Text);
         DateTime tow = Convert.ToDateTime(DtpTow.Text);
         sql += " and [NiBirthDay] > cast('" + one.ToString() + "' as datetime2) ";
         sql += " and [NiBirthDay] < cast('" + tow.ToString() + "' as datetime2) ";
         DataTable    td  = new DataTable();
         dbConnection con = new UserConnection();
         dgviewShow.DataSource = con.CarryOutSqlGeDataTable(sql);
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "错误");
         throw;
     }
 }