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

📄 formspxx.cs

📁 超市进销存管理系统 Visual Studio 2005+SQL Sever2005
💻 CS
📖 第 1 页 / 共 2 页
字号:
                    cm.CommandText +="from spxqBiao where spID like '%" + this.txtspID.Text + "%' ";
                    cm.CommandText +="and spName like '%" + this.txtspName.Text + "%' and spGgxh like '%" + this.txtspGgxh.Text + "%' ";
                    cm.CommandText +="and spJldw like '%" + this.txtspJldw.Text + "%' and spBzsj like '%" + this.txtspBzsj.Text + "%'  ";
                    cm.CommandText +="and spDztj like '%" + this.txtspDztj.Text + "%' and spLbName like '%" + this.txtLbName.Text + "%' ";
                    cm.CommandText +="and spKcsx like '%" + this.txtKcsx.Text + "%' and spKcXX like '%" + this.txtspKcXX.Text + "%' ";
                    cm.CommandText +="and spScrq like '%" + this.txtspScrq.Text + "%' and spBzrq like '%" + this.txtspBcrq.Text + "%' ";
                    da.SelectCommand = cm;
                    da.Fill(dd);
                    this.dataGridView1.DataSource = dd.Tables[0];
                    MessageBox.Show("查询成功!");

                    //温心提示信息

                    cm.Connection = cn;
                    cm.CommandText = "select spID from rkxqBiao where spID = '" + this.dataGridView1.CurrentRow.Cells[1].Value.ToString() + "' ";

                    ddd = cm.ExecuteReader();
                    if (ddd.Read())
                    {
                        this.textBox1.Text = "";
                        if (this.textBox1.Text.Length > 0)
                        {
                            this.textBox1.Text.Remove(0);
                        }
                        ddd.Close();
                        cm.Connection = cn;
                        cm.CommandText = "select sum(shkcsl) from rkxqBiao where spID like '%" + this.dataGridView1.CurrentRow.Cells[0].Value.ToString() + "%' group by spID ";

                        this.textBox1.Text += "\r\n" + this.dataGridView1.CurrentRow.Cells[1].Value.ToString() + ":";
                        this.textBox1.Text += "\r\n\r\n总在库数量为:" + cm.ExecuteScalar().ToString();
                    }
                    else 
                    {
                        ddd.Close();
                        this.textBox1.Text = "";
                        if (this.textBox1.Text.Length > 0)
                        {
                            this.textBox1.Text.Remove(0);
                        }
                        this.textBox1.Text += "\r\n" + this.dataGridView1.CurrentRow.Cells[1].Value.ToString() + ":";
                        this.textBox1.Text += "\r\n\r\n此商品尚未入库!";
 
                    }
                    

                    this.pictureBox1.Hide();
                    this.textBox1.Show();
                    this.label1.Show();

                }
                else
                {
                    ddd.Close();
                    this.pictureBox1.Show();
                    this.textBox1.Hide();
                    this.label1.Hide();
                    MessageBox.Show("系统提示:您的查询的信息不存在!");
                }
            }


        }

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

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

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

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

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

                e.Handled = true;
            }
        }

       


        //允许输入汉字
        

        private void txtLbName_KeyPress(object sender, KeyPressEventArgs e)
        {

            //在标题栏中查看当前输入字符的ASCII值,不能查看Ctrl、Shift、Alt键的ASCII值
            //可以区分大小字母
            //this.Text = Convert.ToString((int)e.KeyChar);

            //用循环的方式禁用全角字符
            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 txtspID_Leave(object sender, EventArgs e)
        {
            if (this.txtspID.Text.Length != 4 && this.txtspID.Text != "")
            {
                MessageBox.Show("编号输入有误,请重新输入!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtspID.Text = "";
                txtspID.Focus();
            }

        }
        //对时间下拉菜单进行操作
        private void txtspScrq1_Enter(object sender, EventArgs e)
        {
            this.txtspScrq.Text = this.txtspScrq1.Value.ToLongDateString();
        }

        private void txtspBcrq1_Enter(object sender, EventArgs e)
        {
            this.txtspBcrq.Text = this.txtspBcrq1.Value.ToLongDateString();
        }

        private void txtspScrq_Enter(object sender, EventArgs e)
        {
            this.txtspScrq1.Show();
        }

        private void txtspBcrq_Enter(object sender, EventArgs e)
        {
            this.txtspBcrq1.Show();
        }

        private void txtspScrq1_Leave(object sender, EventArgs e)
        {
            this.txtspScrq1.Hide();
        }

        private void txtspBcrq1_Leave(object sender, EventArgs e)
        {
            this.txtspBcrq1.Hide();
        }

        private void txtspScrq1_ValueChanged(object sender, EventArgs e)
        {
            this.txtspScrq.Text = this.txtspScrq1.Value.ToLongDateString();
        }

        private void txtspBcrq1_ValueChanged(object sender, EventArgs e)
        {
            this.txtspBcrq.Text = this.txtspBcrq1.Value.ToLongDateString();
        }

        private void txtspScrq_KeyPress(object sender, KeyPressEventArgs e)
        {
            //只能输入退格
            if ((int)e.KeyChar != 8)
            {
                e.Handled = true;
            }
        }


       
       }
    }

⌨️ 快捷键说明

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