⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 formkhxx.cs

📁 超市进销存管理系统 Visual Studio 2005+SQL Sever2005
💻 CS
📖 第 1 页 / 共 2 页
字号:
                    eee.Close();
                    MessageBox.Show("系统提示:您的查询的信息不存在!");
                }
            }
            
                
            //hylx查询
            else if (txthyID.Text==""&& txthyName.Text==""&& txthyLx.Text!=""&& txthySfzh.Text==""&& txthyDh.Text==""&& txthyDz.Text=="")
            {
                cm.Connection = cn;
                cm.CommandText = "select * from khBiao where hyLx='" + this.txthyLx.Text + "'";
                eee  = cm.ExecuteReader();
                if (eee.Read())
                {
                    ee.Clear();
                    eee.Close();
                    cm.CommandText = "select  hyID as '会员卡号',hyName as '会员姓名',hylx as '会员类型',hySfzh as '会员身份证号',hyDh as '会员电话',hyDz as '会员地址',beiZhu as '备注' from ygBiao where hyLx='" + this.txthyLx.Text + "'";
                    da.SelectCommand = cm;
                    da.Fill(ee);
                    this.dataGridView1.DataSource = ee.Tables[0];
                    MessageBox.Show("查询成功!");

                }
                else
                {
                    eee.Close();
                    MessageBox.Show("系统提示:您的查询的信息不存在!");
                }
            }
            //hySfzh查询
            else if (txthyID.Text == "" && txthyName.Text == "" &&  txthyLx.Text == "" && txthySfzh.Text!= "" && txthyDh.Text == "" && txthyDz.Text == "")
            {
                cm.Connection = cn;
                cm.CommandText = "select * from khBiao where  hySfzh='" + this.txthySfzh.Text + "'";
                eee  = cm.ExecuteReader();
                if (eee.Read())
                {
                    ee.Clear();
                    eee.Close();
                    cm.CommandText = "select  hyID as '会员卡号',hyName as '会员姓名',hylx as '会员类型',hySfzh as '会员身份证号',hyDh as '会员电话',hyDz as '会员地址',beiZhu as '备注' from ygBiao where hySfzh='" + this.txthySfzh.Text + "'";
                    da.SelectCommand = cm;
                    da.Fill(ee);
                    this.dataGridView1.DataSource = ee.Tables[0];
                    MessageBox.Show("查询成功!");


                }
                else
                {
                    eee.Close();
                    MessageBox.Show("系统提示:您的查询的信息不存在!");

                }
            }
           //hyDh查询
            else if (txthyID.Text == "" && txthyName.Text == "" && txthyLx.Text == "" && txthySfzh.Text == "" && txthyDh.Text != "" && txthyDz.Text == "")
            {
                cm.Connection = cn;
                cm.CommandText = "select * from khBiao where hyDh='" + this.txthyDh.Text + "'";
                eee = cm.ExecuteReader();
                if (eee.Read())
                {
                    ee.Clear();
                    eee.Close();
                    cm.CommandText = "select  hyID as '会员卡号',hyName as '会员姓名',hylx as '会员类型',hySfzh as '会员身份证号',hyDh as '会员电话',hyDz as '会员地址',beiZhu as '备注'  from khBiao where hyDh='" + this.txthyDh.Text + "'";
                    da.SelectCommand = cm;
                    da.Fill(ee);
                    this.dataGridView1.DataSource = ee.Tables[0];
                    MessageBox.Show("查询成功!");

                }
                else
                {
                    eee.Close();
                    MessageBox.Show("系统提示:您的查询的信息不存在!");
                }
            }
           
            //hyDz查询
            else if (txthyID.Text == "" && txthyName.Text == "" && txthyLx.Text == "" && txthySfzh.Text == "" && txthyDh.Text == "" && txthyDz.Text != "")
            {
                cm.Connection = cn;
                cm.CommandText = "select * from khBiao where hyDz='" + this.txthyDz.Text + "'";
                eee = cm.ExecuteReader();
                if (eee.Read())
                {
                   ee.Clear();
                   eee.Close();
                   cm.CommandText = "select  hyID as '会员卡号',hyName as '会员姓名',hylx as '会员类型',hySfzh as '会员身份证号',hyDh as '会员电话',hyDz as '会员地址',beiZhu as '备注' from ygBiao where hyDz='" + this.txthyDz.Text + "'";
                    da.SelectCommand = cm;
                    da.Fill(ee);
                    this.dataGridView1.DataSource = ee.Tables[0];
                    MessageBox.Show("查询成功!");

                }
                else
                {
                    eee.Close();
                    MessageBox.Show("系统提示:您的查询的信息不存在!");
                }
            }
        
        }


        private void txthyID_KeyPress(object sender, KeyPressEventArgs e)
        {
            //只能输入数字和退格
            if (!(e.KeyChar >= '0' && e.KeyChar <= '9') && (int)e.KeyChar != 8)
            {
                e.Handled = true;
            }
        }

        private void txthyName_KeyPress(object sender, KeyPressEventArgs e)
        {
            //用循环的方式禁用全角字符
            char[] cc ={ '~', '!', '·', '#', '¥', '%', '…', '—', '*', '(', ')', '《', '》', '?', '。', ',', '“', ':', ';', '‘' };

            foreach (char c in cc)
            {
                if (e.KeyChar == c)
                    e.Handled = true;
            }

            //禁用ASCII表中的所有字符,但是允许删除
            if ((int)e.KeyChar >= 0 && (int)e.KeyChar <= 255 && (int)e.KeyChar != 8)
            {
                e.Handled = true;
            }
        }

        //private void txthylx_KeyPress(object sender, KeyPressEventArgs e)
        //{
        
        //}

        private void txthySfzh_KeyPress(object sender, KeyPressEventArgs e)
        {
             //只能输入数字和退格
            if (!(e.KeyChar >= '0' && e.KeyChar <= '9') && (int)e.KeyChar != 8)
            {
                e.Handled = true;
            }
        }

        private void txthyDh_KeyPress(object sender, KeyPressEventArgs e)
        {
            //只能输入数字和退格
            if (!(e.KeyChar >= '0' && e.KeyChar <= '9') && (int)e.KeyChar != 8)
            {
                e.Handled = true;
            }
        }

        private void txthyDz_KeyPress(object sender, KeyPressEventArgs e)
        {
            //用循环的方式禁用全角字符
            char[] cc ={ '~', '!', '·', '#', '¥', '%', '…', '—', '*', '(', ')', '《', '》', '?', '。', ',', '“', ':', ';', '‘' };

            foreach (char c in cc)
            {
                if (e.KeyChar == c)
                    e.Handled = true;
            }

            //禁用ASCII表中的所有字符,但是允许删除
            if ((int)e.KeyChar >= 0 && (int)e.KeyChar <= 255 && (int)e.KeyChar != 8)
            {
                e.Handled = true;
            }
        }

        private void txthyLx_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!(e.KeyChar >= '0' && e.KeyChar <= '9') && (int)e.KeyChar != 8 && e.KeyChar != '.')
            {
                e.Handled = true;
            }
            else if (e.KeyChar == '.')
            {
                if (this.txthyLx.Text.IndexOf('.') >= 0)  //如果已经有小数点存在,则不能再输入小数点
                    e.Handled = true;
                //如果小数点不存在,但是文本框没有任何字符,则也禁用'.'
                //禁止文本框的第一个字符为'.'
                else if (this.txthyLx.Text.Length == 0)
                    e.Handled = true;
            }
            if (this.txthyLx.Text.Contains("."))
            {
                if (this.txthyLx.Text.Substring(this.txthyLx.Text.IndexOf('.')).Length > 2 && e.KeyChar != 8)
                {
                    e.Handled = true;
                }
            }
        }


        //小数输入会员类型
        private void txthyLx_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyValue != 8)
            {
                if (this.txthyLx.Text.Length == 1 && this.txthyLx.Text != "0")
                {
                    this.txthyLx.Text = @"0." + this.txthyLx.Text;
                    this.txthyLx.SelectionStart = 4;
                }
                if (this.txthyLx.Text == "0")
                {
                    this.txthyLx.Text += ".";
                    this.txthyLx.SelectionStart = 3;
                }
            }
        }
        //判断员工编号的输入位数
        private void txtygID_Leave(object sender, EventArgs e)
        {
            if (this.txthyID.Text.Length != 4 && this.txthyID.Text != "")
            {
                MessageBox.Show("编号输入有误,请重新输入!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txthyID.Text = "";
                txthyID.Focus();
            }

        }
      
        }
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -