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

📄 formjhrk.cs

📁 超市进销存管理系统 Visual Studio 2005+SQL Sever2005
💻 CS
📖 第 1 页 / 共 3 页
字号:
        private void cms_spID_ItemClicked(object sender, ToolStripItemClickedEventArgs e2)
        {
            this.dgv_rkDan.CurrentCell.Value = e2.ClickedItem.Text;
        }
        
        //------------------------------------^^-----------按扭添加功能------------^^---------------------------
        private void bt_Tj_Click(object sender, EventArgs e)
        { 
            rkTable2.Rows.Add();
            aa11.Clear();
        }

        //行增加事件
        private void dgv_rkDan_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
        {
            foreach (DataGridViewRow row in this.dgv_rkDan.Rows)
            {
                row.HeaderCell.Value = (row.Index + 1).ToString();
            }             
        }

        //-----------------------------------------------------^^---------修改功能------------^^-----------------------------
        private void tsb_XiuGai_Click_1(object sender, EventArgs e)
        {
            ++xiugai;
            this.tb_djName.Show();
            this.groupBox1.Show();
            this.groupBox4.Show();
            this.crystalReportViewer1.Visible = false;
            this.dgv_rkDan.DataSource = rkTable1;
            this.dgv_rkDan.Enabled = true;            
        }
        //----------------------------------------------^^-------入库数量键盘字母禁用--------^^-------------------------------
        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (this.dgv_rkDan.CurrentCell.ColumnIndex == 2)
            {
                if (e.KeyChar >= '0' && e.KeyChar <= '9' || ((int)e.KeyChar) == 8 || ((int)e.KeyChar) == 13)
                {
                    e.Handled = false;
                }
                else { e.Handled = true; }
                if (((int)e.KeyChar) == 13)
                {
                    this.dgv_rkDan.EditMode = DataGridViewEditMode.EditOnKeystrokeOrF2;
                    this.textBox1.Visible = false;
                    this.dgv_rkDan.CurrentCell.Value = this.textBox1.Text;
                }
            }
            else
            {
                e.Handled = false; 
            }
          
        }
        //-----------^^----编辑入库数量------^^-------------------------------
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (this.dgv_rkDan.CurrentCell.ColumnIndex == 2)
            {
                // 限制入库数量
                if (dgv_rkDan.Enabled == true && this.tb_Kcsx.Text != "" && this.lb_spZkzsl.Text != "" && this.textBox1.Text != "")
                {
                    if (Convert.ToInt32(this.textBox1.Text) > (Convert.ToInt32(this.tb_Kcsx.Text) - Convert.ToInt32(this.lb_spZkzsl.Text)))
                    {
                        MessageBox.Show("您入库商品数量超出库存上限,请重新调整!");
                        this.textBox1.Text = "0";
                        this.textBox1.SelectAll();
                    }
                }

                //入库数量编辑结束
                if (this.textBox1.Text != null && this.textBox1.Text != "")
                {
                    int rksl = Convert.ToInt32(this.textBox1.Text);
                    this.dgv_rkDan.CurrentCell.Value = rksl;

                }

                //自动添加商品在库数量
                if (Convert.IsDBNull(this.dgv_rkDan.CurrentRow.Cells[2].Value) == false)
                {
                    this.dgv_rkDan.CurrentRow.Cells[5].Value = this.dgv_rkDan.CurrentRow.Cells[2].Value;
                }
            }
            else
            {
                if (this.textBox1.Text != null && this.textBox1.Text != "")
                {

                    this.dgv_rkDan.CurrentCell.Value = this.textBox1.Text;

                }
            }

        }

        //-----------------------------^^-----给入库数量单元格付值-----^^----------------------------
        private void dgv_rkDan_CellLeave(object sender, DataGridViewCellEventArgs e)
        {
            if (this.textBox1.Text != null && (this.dgv_rkDan.CurrentCell.ColumnIndex == 2 || this.dgv_rkDan.CurrentCell.ColumnIndex == 4))
            {
                if (this.dgv_rkDan.CurrentCell.ColumnIndex == 2)
                {
                    int rksl = Convert.ToInt32(this.textBox1.Text);
                    this.dgv_rkDan.CurrentCell.Value = rksl;
                    return;
                }
                else
                {
                    this.dgv_rkDan.CurrentCell.Value = this.textBox1.Text;
                    return;
                }
            }

            if (Convert.IsDBNull(this.dgv_rkDan.CurrentRow.Cells[2].Value) == false && this.lb_spJhje.Text != null)
            {
                //000000000000000000000000000000000--商品的总价格--00000000000000000000000000000000000000      
                int j;
                i = Convert.ToDecimal(this.lb_spJhje.Text);
                j = Convert.ToInt32(this.dgv_rkDan.CurrentRow.Cells[2].Value);
                danSum = i * j;
                //当前商品的
                this.dgv_rkDan.CurrentRow.Cells[3].Value = danSum;
                //0000000000000000000000000000000000000000000000000000000000000000000000000
            }

        }

        //调未审核单据
        private void button1_Click(object sender, EventArgs e)
        {

            //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            this.dgv_Djsh.Columns.Clear();
            rkadp3 = new SqlDataAdapter("select djID as '进货单据编号',shZt as '审核状态', shrName,shTime from djczBiao where djID like'JH%' and shZt=(0) order by zdRq ", cz.sqlCon());
            rkTable3 = new DataTable();
            rkadp3.Fill(rkTable3);
            this.dgv_Djsh.DataSource = rkTable3;
            this.dgv_Djsh.Columns[0].Width = 120;
            this.dgv_Djsh.Columns[1].Width = 70;
            this.dgv_Djsh.Columns[2].Visible = false;
            this.dgv_Djsh.Columns[3].Visible = false;

            //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        }
        
        //审核却认
        private void button2_Click(object sender, EventArgs e)
        {
            if (dgv_Djsh.Rows.Count > 0)
            {
                rksqlcb2 = new SqlCommandBuilder(rkadp3);
                this.rkadp3.Update(rkTable3);
                this.dgv_Djsh.ClearSelection();
                this.rkTable3.Clear();
                //;;;;;;;;;;;;;;;;;;;;;-----判断是否可以新增-----;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                dr1 = cz.SqlDr(selectstr);
                if (dr1.Read() == true) { this.tsb_XinZeng.Enabled = true; }
                else { this.tsb_XinZeng.Enabled = false; }
                dr1.Close();
                //;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
            }
        }
        //审核网格
        private void dgv_Djsh_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (this.dgv_Djsh.SelectedCells.Count > 0)
            {
                if (Convert.ToBoolean(this.dgv_Djsh.CurrentRow.Cells[1].Value) == true)
                {
                    this.dgv_Djsh.CurrentRow.Cells[2].Value = "usName";
                    this.dgv_Djsh.CurrentRow.Cells[3].Value = dqrq;
                    this.labe11.Focus();
                }
                else
                {
                    this.dgv_Djsh.CurrentRow.Cells[2].Value = "";
                    this.dgv_Djsh.CurrentRow.Cells[3].Value = "";
                }
            }
            this.dgv_rkDan.ClearSelection();
        }
        //------------------------------审核-----------------------------------
        private void dgv_Djsh_SelectionChanged(object sender, EventArgs e)
        {
            if (this.dgv_Djsh.CurrentCell.ColumnIndex == 1)
            { this.bt_Qrsh.Enabled = false; }
            else
            { this.bt_Qrsh.Enabled = true; } 
        }
        //-----------------------^^-----------打印功能-----------^^------------------
        private void tsb_Dayin_Click(object sender, EventArgs e)
        {
            this.tsJhrkGjl.Dock = DockStyle.Top;
            this.tb_djName.Hide();
            this.groupBox1.Hide();
            this.groupBox4.Hide();

            this.button1.Visible = false;
            this.bt_Qrsh.Visible = false;
            this.groupBox7.Visible = false;
            _10901BS.cr_rkBiao crbiao = new cr_rkBiao();
            crbiao.SetDataSource(cz.dtShuJuBiao("select * from rkxqBiao where rkdjID='"+this.lb_Djbh.Text+"' "));
            this.crystalReportViewer1.ReportSource = crbiao;            
            this.crystalReportViewer1.Visible = true;
            this.crystalReportViewer1.Dock = DockStyle.Fill;
            
        }
        //-------------------^^---判断入库数量----^^------------------
        private void textBox1_Leave(object sender, EventArgs e)
        {
            if (this.dgv_rkDan.CurrentCell.ColumnIndex == 2)
            {
                if (Convert.ToInt32(this.textBox1.Text) > Convert.ToInt32(this.lb_spJhsl.Text))
                {
                    MessageBox.Show("进货数量不足,请重新输入!");
                    //this.textBox1.Text = "0";
                    this.textBox1.SelectAll();
                    this.textBox1.Focus();
                }
                if (Convert.ToInt32(this.textBox1.Text) < Convert.ToInt32(this.lb_spJhsl.Text))
                {
                    DialogResult a = MessageBox.Show("您的入库数量与进货数量不符!!\r\n(如果您确定此数量无误,请点 OK )\r\n(否则,请点 Cancel  重新输入 )", "温馨提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (a != DialogResult.OK)
                    {
                        this.textBox1.SelectAll();
                        this.textBox1.Focus();
                    }
                    else
                    {
                        this.dgv_rkDan.CurrentCell = this.dgv_rkDan.CurrentRow.Cells[2];
                    }
                }
            }
        }

        //当网格单元割的值发生改变时发生
        private void dgv_rkDan_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            // 使保存功能可用
            if (this.dgv_rkDan.Rows.Count > 0)
            {
                this.tsb_Baocun.Enabled = true;
            }
        }

        //-------------------------------------------------------------

    }
}

⌨️ 快捷键说明

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