Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string sex = "男";  //默认性别为男

            if (this.radioButton2.Checked == true)
            {
                sex = "女";
            }

            //判断用户名,密码,科室,年龄不能为空
            if (this.textBox6.Text.Trim() == "")
            {
                MessageBox.Show("姓名不能为空");
                this.Focus();
                return;
            }
            if (this.textBox1.Text.Trim() == "")
            {
                MessageBox.Show("账号不能为空");
                this.Focus();
                return;
            }
            if (this.radioButton1.Checked == false && this.radioButton2.Checked == false)
            {
                MessageBox.Show("性别不能为空");
                this.Focus();
                return;
            }
            if (this.textBox2.Text.Trim() == "")
            {
                MessageBox.Show("年龄不能为空");
                this.Focus();
                return;
            }
            string        sql = "update dbo.login set uname='" + this.textBox6.Text.Trim() + "',age='" + this.textBox2.Text.Trim() + "',sex='" + sex + "'where uid='" + this.textBox1.Text.Trim() + "'";
            SqlConnection con = DBhelper.Gethelper();     //调用DBhelp类中的方法,连接数据库
            SqlCommand    com = new SqlCommand(sql, con); //创建command对象执行SQL语句

            con.Open();
            int count = com.ExecuteNonQuery();

            con.Close();
            if (count > 0)         //判断数据库中受影响的行数
            {
                string Message = string.Format("修改成功!");
                MessageBox.Show(Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 2
0
        public string Getcount(string sql)
        {
            SqlConnection con = DBhelper.Gethelper();

            sql = "select friend from dbo.Friend where id='" + Login.denglu + "'"; //查询医生有多少病员用的SQL语句
            SqlCommand com = new SqlCommand(sql, con);

            con.Open();
            string reng = com.ExecuteScalar().ToString(); //执行SQL语句返回一行一列的值

            string[] bb   = reng.Split('|');              //以'|'为分割符分割字符串
            int      temp = bb.Length - 1;                //执行一次减少一个病人

            lblCount.Text = Convert.ToString(temp);
            return(sql);
        }
Ejemplo n.º 3
0
        public static bool Getz(string sql1)                      //静态bool型的Getz方法
        {
            SqlConnection con1 = DBhelper.Gethelper();            //创建 SqlConnection对象
            SqlCommand    com2 = new SqlCommand(sql1, con1);

            con1.Open();
            int count = com2.ExecuteNonQuery();                  //接收受影响的行数

            if (count > 0)                                       //如果有影响行数
            {                                                    //返回true
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        //完成增删改查的方法
        public static bool Getzsgc(string sql)
        {
            SqlConnection con = DBhelper.Gethelper();
            SqlCommand    com = new SqlCommand(sql, con);

            con.Open();
            int temp = com.ExecuteNonQuery();

            if (temp != 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (this.textBox3.Text.Trim() == "" | this.textBox7.Text.Trim() == "")                              //判断输入的身份证格式
     {
         MessageBox.Show("输入正确的登录密码或账号");
         this.textBox3.Focus();                                        //重新输入
         return;
     }
     else
     {
         SqlConnection con = DBhelper.Gethelper();                      //打开连接
         try
         {
             ff = this.textBox3.Text;                                  //变量接收身份证验证文本框值
             if (this.textBox4.Text != this.textBox5.Text)
             {
                 MessageBox.Show("新密码不一致", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 this.textBox4.Clear();
                 this.textBox5.Clear(); //值清空
                 this.textBox4.Focus(); //聚焦身份证文本框
             }
             else
             {
                 string     sql = "update dbo.login set pwd='" + this.textBox4.Text.Trim() + "'where uid='" + this.textBox7.Text.Trim() + "'";
                 SqlCommand com = new SqlCommand(sql, con);//创建command对象执行SQL语句
                 con.Open();
                 int count = com.ExecuteNonQuery();
                 con.Close();
                 if (count > 0)         //判断数据库中受影响的行数
                 {
                     string Message = string.Format("保存成功!");
                     MessageBox.Show(Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
         }
         catch (Exception)
         {
             this.textBox1.Clear();
             MessageBox.Show("保存失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }
Ejemplo n.º 6
0
 private void btnregito_Click_2(object sender, EventArgs e)            //挂号按钮
 {
     if (this.txtsfz1.Text.Trim() == "")                               //判断身份证号文本框为空否
     {
         MessageBox.Show("输入身份证号或填写新病历");
         return;
     }
     else
     {
         string        sql = "select psfz from [user] where psfz='" + txtsfz1.Text.Trim() + "'";
         SqlConnection con = DBhelper.Gethelper();                    //验证该身份证有否病史
         SqlCommand    com = new SqlCommand(sql, con);
         con.Open();
         try
         {
             string idcard = com.ExecuteScalar().ToString();              //声明变量查询返回第一行第一列的值
             if (idcard == txtsfz1.Text.Trim())                           //找到记录的记录是否与文本框一致
             {
                 sql = "insert into [user](pname,psex,page,blood,phone,psfz,[money],adds) values('" + this.txtname1.Text.Trim() + "','" + txtsex1.Text.Trim() + "','" + this.txtage1.Text.Trim() + "','" + txtblood.Text + "','" + this.txtphone1.Text.Trim() + "','" + this.txtsfz1.Text.Trim() + "','0','" + this.txtadd1.Text.Trim() + "') ";
                 com = new SqlCommand(sql, con);                           //将有病史的病人的资料重新插入数据库一次
                 int temp = com.ExecuteNonQuery();                         //声明变量获取插入成功的行数,只要不为0就成功
                 if (temp != 0)
                 {
                     sql             = "select top 1 [pid] from [user] order by [pid] desc"; //找到此人本次看病的编号
                     com.CommandText = sql;
                     Num             = Convert.ToInt32(com.ExecuteScalar().ToString());
                     string aa = string.Format("您本次挂号临时编号为{0}", Num);
                     MessageBox.Show(aa, "领取成功!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                     con.Close();
                     Relook obj = new Relook();                                          //挂号窗口打开,此窗体隐藏
                     obj.Show();
                     this.Hide();
                 }
             }
         }
         catch (Exception)
         {
             this.txtsfz1.Clear();
             MessageBox.Show("输入有错,请输入正确的身份证号查询或注册新病历!");
         }
     }
 }
Ejemplo n.º 7
0
 private void btnserch_Click_1(object sender, EventArgs e)            //查询按钮
 {
     if (this.txtsfz1.Text.Trim() == "")                              //判断输入的身份证格式
     {
         MessageBox.Show("输入正确的身份证号");
         this.txtsfz1.Focus();                                        //重新输入
         return;
     }
     else
     {
         SqlConnection con = DBhelper.Gethelper();                      //打开连接
         try
         {
             sfz = this.txtsfz1.Text;                                  //变量接收身份证验证文本框值
             if (sfz.Length < 18 && sfz.Length > 15)
             {
                 MessageBox.Show("身份证格式不正确", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 this.txtsfz1.Clear();                                 //值清空
                 this.txtsfz1.Focus();                                 //聚焦身份证文本框
             }
             else
             {
                 string  sql = "select pname,psex,page,blood,phone,adds from [user] where psfz='" + this.txtsfz1.Text.Trim() + "'";
                 DataSet ds  = getds(sql);                                  //查询有未有过病史判断是否来过调用方法重新创建数据集
                 txtname1.Text  = ds.Tables[0].Rows[0][0].ToString();       //将值赋给各属性文本框
                 txtsex1.Text   = ds.Tables[0].Rows[0][1].ToString();
                 txtage1.Text   = ds.Tables[0].Rows[0][2].ToString();
                 txtblood.Text  = ds.Tables[0].Rows[0][3].ToString();
                 txtphone1.Text = ds.Tables[0].Rows[0][4].ToString();
                 txtadd1.Text   = ds.Tables[0].Rows[0][5].ToString();
                 txtbh.Text     = Num.ToString();
             }
         }
         catch (Exception)
         {
             this.txtsfz1.Clear();
             MessageBox.Show("未找到,请您先挂号", "挂号提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             panel2.Visible = true;                                       //注册病历窗口打开,查询挂号窗口关闭
             panel1.Visible = false;
         }
     }
 }
Ejemplo n.º 8
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (this.textBox1.Text.Trim() == "")                              //判断输入的身份证格式
     {
         MessageBox.Show("输入正确的身份证号");
         this.textBox1.Focus();                                        //重新输入
         return;
     }
     else
     {
         SqlConnection con = DBhelper.Gethelper();                      //打开连接
         try
         {
             sfz = this.textBox1.Text;                                  //变量接收身份证验证文本框值
             if (sfz.Length < 18 && sfz.Length > 15)
             {
                 MessageBox.Show("身份证格式不正确", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 this.textBox1.Clear();                                 //值清空
                 this.textBox1.Focus();                                 //聚焦身份证文本框
             }
             else
             {
                 string         sql = "select bingkuang from [bingkuang] where psfzId='" + this.textBox1.Text.Trim() + "'";
                 SqlCommand     com = new SqlCommand(sql, con);//查询有未有过病史判断是否来过调用方法重新创建数据集
                 SqlDataAdapter da  = new SqlDataAdapter(com);
                 da.Fill(ds);
                 List <String> list = new List <string>();
                 foreach (DataRow row in ds.Tables[0].Rows)
                 {
                     list.Add(row[0].ToString());
                 }
                 richTextBox1.Lines = list.ToArray();        //将值赋给各属性文本框
             }
         }
         catch (Exception)
         {
             this.textBox1.Clear();
             MessageBox.Show("未找到,请您先挂号", "挂号提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }
Ejemplo n.º 9
0
        private void btnok_Click(object sender, EventArgs e)      //确定按钮
        {
            SqlConnection con = DBhelper.Gethelper();

            con.Open();
            string sid  = Convert.ToString(register.Num);           //声明sid变量获取强转String后的register类的Num变量
            string sid1 = sid + "|";                                //声明sid1变量获取sid和"|"
            int    tem  = 0;                                        //声明int型的tem变量

            if (dataGridView1.SelectedCells.Count == 0)             //判断用户有未选择dataGridView的单元格
            {
                MessageBox.Show("请选择一个医生!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else                                                    //获取当前选中的这一行第一个单元格的值,obj型转为String后强转int型用tem接收
            {
                tem = int.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString());
                string     sql1 = "select friend from Friend where id='" + tem + "'"; //查询条件为医生的id
                SqlCommand com  = new SqlCommand(sql1, con);
                try
                {
                    string bianhao = com.ExecuteScalar().ToString();                         //用string型bianhao变量接收返回的值
                    string sidd    = bianhao + sid1;                                         //将bianhao和sid1变量赋给sidd
                    sql1 = "update Friend set friend='" + sidd + "' where id='" + tem + "'"; //将sidd的值更新到条件为该医生id号的行friend的列
                    Getz(sql1);                                                              //调用 Getz方法执行
                    MessageBox.Show("挂号成功!");                                                //成功后返回查询挂号窗体
                    register obj = new register();
                    obj.Show();
                    this.Hide();                                      //该窗体隐藏
                }
                catch (Exception)
                {
                    MessageBox.Show("选择有错", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            con.Close();                                           //关闭连接
        }
Ejemplo n.º 10
0
        private void save_Click(object sender, EventArgs e)
        {
            int    accounts = 0;
            string sex      = "男"; //默认性别为男

            if (this.radiogirl.Checked == true)
            {
                sex = "女";
            }
            string type = "挂号台";

            if (this.DrRadio.Checked == true)
            {
                type = "医生";
            }
            //判断用户名,密码,科室,年龄不能为空
            if (this.trueName.Text.Trim() == "")
            {
                MessageBox.Show("用户名不能为空");
                this.Focus();
                return;
            }
            if (this.code.Text.Trim() == "")
            {
                MessageBox.Show("密码不能为空");
                this.Focus();
                return;
            }
            if (this.DrRadio.Checked == true && this.comboBox1.Text == "")

            {
                MessageBox.Show("科室不能为空");
                this.Focus();
                return;
            }
            if (this.ageAasked.Text.Trim() == "")
            {
                MessageBox.Show("年龄不能为空");
                this.Focus();
                return;
            }
            //向数据库插入注册的SQL语句
            string        sql = "insert into dbo.login values ('" + this.code.Text.Trim() + "','" + this.trueName.Text.Trim() + "','" + sex + "','" + this.ageAasked.Text.Trim() + "','" + type + "','" + this.comboBox1.Text.Trim() + "',0)";
            SqlConnection con = DBhelper.Gethelper();     //调用DBhelp类中的方法,连接数据库
            SqlCommand    com = new SqlCommand(sql, con); //创建command对象执行SQL语句

            con.Open();
            int count = com.ExecuteNonQuery();

            con.Close();
            if (count > 0)         //判断数据库中受影响的行数
            {
                con.Open();
                string sql1 = "select top 1 uid from dbo.login order by uid desc"; //将数据库中的数据按降序排列并查找出第一个
                com.CommandText = sql1;
                accounts        = Convert.ToInt32(com.ExecuteScalar());            //生成帐号
                string Message = string.Format("注册成功!您的帐号是{0}", accounts);
                MessageBox.Show(Message, "注册成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
                con.Close();
            }
            sql = "insert into dbo.Friend(id,kemu,name) values(" + accounts + ",'" + this.comboBox1.Text + "','" + this.trueName.Text + "')";
            Mindoc.Getzsgc(sql);
        }
Ejemplo n.º 11
0
 private void btnUp_Click_1(object sender, EventArgs e)      //提交按钮
 {
     sfz = this.txtsfz.Text;                                 //给变量赋值
     if (this.txtsfz.Text.Trim() == "")                      //判断身份证为不为空
     {
         MessageBox.Show("请输入身份证");
         this.txtsfz.Focus();
     }
     else if (this.txtage.Text.Trim() == "")
     {
         MessageBox.Show("请输入年龄");
         this.txtage.Focus();
     }
     else if (this.txtname.Text.Trim() == "")
     {
         MessageBox.Show("请输入真实姓名");
         this.txtname.Focus();
     }
     else if (this.txtphone.Text.Trim() == "")
     {
         MessageBox.Show("请输入联系方式");
         this.txtphone.Focus();
     }
     else if (this.txtadd.Text.Trim() == "")
     {
         MessageBox.Show("请输入住址");
         this.txtadd.Focus();
     }
     else
     {
         try
         {
             long sfz1 = Convert.ToInt64(this.txtsfz.Text);              //声明身份证的变量接受强转INT型的身份证文本框的值
             int  age7 = Convert.ToInt32(this.txtage.Text);              //声明年龄的变量接受强转INT型的年龄文本框的值
             if (age7 >= 1 && age7 <= 130)                               //判断年龄规范
             {
                 SqlConnection con = DBhelper.Gethelper();               //声明SqlConnection对象
                 string        sex = "男";                                //给变量附初始值=男
                 if (this.radioButton2.Checked == true)                  //用户选择的按钮2被选中的话,变量为 女
                 {
                     sex = "女";
                 }
                 string     sql = "insert into [user](pname,psex,page,blood,phone,psfz,[money],adds) values('" + this.txtname.Text.Trim() + "','" + sex + "','" + this.txtage.Text.Trim() + "','" + this.cbxblood.SelectedItem.ToString() + "','" + this.txtphone.Text.Trim() + "','" + this.txtsfz.Text.Trim() + "','0','" + this.txtadd.Text.Trim() + "') ";
                 SqlCommand com = new SqlCommand(sql, con);              //往[user]表里添加病人信息,声明SqlCommand对象
                 con.Open();                                             //打开连接
                 int temp = com.ExecuteNonQuery();                       //声明变量接收SqlCommand对象的ExecuteNonQuery方法
                 if (temp != 0)
                 {
                     sql             = "select top 1 [pid] from [user] order by [pid] desc"; //降序排列得到[user]表中新注册用户的自动增长列
                     com.CommandText = sql;                                                  //获取SQL语句
                     Num             = Convert.ToInt32(com.ExecuteScalar().ToString());      //用静态变量接收强转INT型的查询所返回的1行1列的值即ID
                     string aa = string.Format("您的电子病历号是{0}", Num);
                     MessageBox.Show(aa, "电子病历注册成功!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                     con.Close();                                                    //声明aa变量接收格式化后的字符串用消息框弹出成功信息
                     Relook obj1 = new Relook();                                     //病历注册后即进入挂号窗口
                     obj1.Show();
                     this.Hide();                                                    //此窗体隐藏
                 }
             }
             else
             {
                 MessageBox.Show("年龄格式不正确", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.txtage.Focus();
             }
         }
         catch (Exception)
         {
             MessageBox.Show("请输入数字", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }