Пример #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;
        }
Пример #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);
     }
 }
Пример #3
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;
            }
        }