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

📄 formjhrk.cs

📁 超市进销存管理系统 Visual Studio 2005+SQL Sever2005
💻 CS
📖 第 1 页 / 共 3 页
字号:
            this.tsb_XinZeng.Enabled = true;
            this.lb_spRkzje.Text = "0.00";
            this.lb_spJhsl.Text = null;
            this.lb_spJhje.Text = "0.00";
            this.tb_Bz.Text = null;
            this.tb_Kcsx.Text = null;
            this.tb_spBzsj.Text = null;
            this.lb_spZkzsl.Text = null;
            this.dgv_rkDan.Enabled = false;
        
        }

        //-----------------------------------------------------^^---------网格中的行标头变化----------^^-------------------------------------------------------
        //网格中的行被删除后发生
        private void dgv_rkDan_RowsRemoved(object sender, DataGridViewRowsRemovedEventArgs e)
        {            
            foreach (DataGridViewRow row in this.dgv_rkDan.Rows)
            {
                row.HeaderCell.Value = (row.Index + 1).ToString();
                if (row.Cells[3].Value != null)
                {
                    this.tsb_Baocun.Enabled = true;
                }
                else { this.tsb_Baocun.Enabled = false; }
            }             
        }

        //-------------------------------------^^----------退出功能-----------^^------------------------------------------------
        //实现退出功能
        private void tsb_tuiChu_Click(object sender, EventArgs e)
        {
            this.Close();
        }        

        //------------------------------------^^---------自动识别功能-------^^---------------------------------
        //网格内部选择内容变化事件
        private void dgv_rkDan_SelectionChanged(object sender, EventArgs e)
        {
            this.dgv_Djsh.ClearSelection();

            if (this.dgv_rkDan.SelectedCells.Count == 1)
            {
                //00000000000000000000000000000000------------------------------0000000000000000000000000000
                //给第二列的单元格绑定textbox
                if (this.dgv_rkDan.CurrentCell.OwningColumn.Index == 2 || this.dgv_rkDan.CurrentCell.OwningColumn.Index == 4)
                {
                    if (Convert.IsDBNull(this.dgv_rkDan.CurrentCell.Value) == true)
                    { this.textBox1.Text = "0"; }//对textBox1赋值
                    else { this.textBox1.Text = this.dgv_rkDan.CurrentCell.Value.ToString(); }
                    Rectangle R = this.dgv_rkDan.GetCellDisplayRectangle(this.dgv_rkDan.CurrentCell.ColumnIndex, this.dgv_rkDan.CurrentCell.RowIndex, false);  //获取单元格位置
                    this.textBox1.SetBounds(R.X + this.groupBox6.Location.X + this.dgv_rkDan.Location.X, R.Y + this.groupBox6.Location.Y + this.dgv_rkDan.Location.Y, R.Width, R.Height); //重新定位combobox.中间有坐标位置的转换
                    this.textBox1.Visible = true;
                    this.textBox1.Focus();
                    this.textBox1.SelectAll();
                }
                else { this.textBox1.Visible = false; }
                //0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

                //7777777777777777777777777777777
                //if (this.dgv_rkDan.CurrentCell.OwningColumn.Index == 2 || this.dgv_rkDan.CurrentCell.OwningColumn.Index == 4)//|| this.dgv_rkDan.CurrentCell.OwningColumn.Index == 3
                //{ this.dgv_rkDan.EditMode = DataGridViewEditMode.EditOnEnter; }
                //else { this.dgv_rkDan.EditMode = DataGridViewEditMode.EditOnKeystrokeOrF2; }
                //if (this.dgv_rkDan.CurrentCell.OwningColumn.Index == 3)
                //{ this.dgv_rkDan.EditMode = DataGridViewEditMode.EditOnKeystrokeOrF2; }

                //77777777777777777777777777777777

                //自动显示当前商品编号的总在库数量
                dr = cz.SqlDr("select sum(shKcSl) from rkxqBiao where spID='" + this.dgv_rkDan.CurrentRow.Cells[1].Value + "' group by spID");
                if (dr.Read() == true)
                {
                    this.lb_spZkzsl.Text = cz.sqlComCell("select sum(shKcSl) from rkxqBiao where spID='" + this.dgv_rkDan.CurrentRow.Cells[1].Value + "' group by spID");
                }
                else
                {
                    this.lb_spZkzsl.Text = "0";
                }
                dr.Close();

                //自动显示当前商品的当前进货单的进货数量
                dr = cz.SqlDr("select jhSl from jhxqBiao where jhDjID='" + this.dgv_rkDan.CurrentRow.Cells[0].Value + "' and spID='" + this.dgv_rkDan.CurrentRow.Cells[1].Value + "'");
                if (dr.Read() == true)
                {
                    this.lb_spJhsl.Text = cz.sqlComCell("select jhSl from jhxqBiao where jhDjID='" + this.dgv_rkDan.CurrentRow.Cells[0].Value + "' and spID='" + this.dgv_rkDan.CurrentRow.Cells[1].Value + "'");
                }
                dr.Close();

                //自动显示当前商品的当前进货单的进货价格
                dr = cz.SqlDr("select jhDjia from jhxqBiao where jhDjID='" + this.dgv_rkDan.CurrentRow.Cells[0].Value + "' and spID='" + this.dgv_rkDan.CurrentRow.Cells[1].Value + "'");
                if (dr.Read() == true)
                {
                    this.lb_spJhje.Text = cz.sqlComCell("select jhDjia from jhxqBiao where jhDjID='" + this.dgv_rkDan.CurrentRow.Cells[0].Value + "' and spID='" + this.dgv_rkDan.CurrentRow.Cells[1].Value + "'");
                }
                dr.Close();

                //标准售价
                dr = cz.SqlDr("select spBzsj from spxqBiao where spID='" + this.dgv_rkDan.CurrentRow.Cells[1].Value + "'");
                if (dr.Read() == true)
                {
                    this.tb_spBzsj.Text = cz.sqlComCell("select spBzsj from spxqBiao where spID='" + this.dgv_rkDan.CurrentRow.Cells[1].Value + "'");
                    this.tb_Kcsx.ReadOnly = true;
                }
                else { this.tb_Kcsx.ReadOnly = false; }
                dr.Close();


                ////自动显示当前商品的库存上限
                dr = cz.SqlDr("select spKcsx from spxqBiao where spID='" + this.dgv_rkDan.CurrentRow.Cells[1].Value + "'");
                if (dr.Read() == true)
                {
                    this.tb_Kcsx.Text = cz.sqlComCell("select spKcsx from spxqBiao where spID='" + this.dgv_rkDan.CurrentRow.Cells[1].Value + "'");
                    this.tb_Kcsx.ReadOnly = true;
                }
                else { this.tb_Kcsx.ReadOnly = false; }
                dr.Close();

                //给商品编号字符串付值传给formKcsz窗体
                if (this.dgv_rkDan.Enabled == true)
                {
                    spIDstr = this.dgv_rkDan.CurrentRow.Cells[1].Value.ToString();
                }

                //自动显示当前商品的入库总金额、本张入库单的入库总金额、商品的标准售价            
                if (Convert.IsDBNull(this.dgv_rkDan.CurrentRow.Cells[2].Value) == false && this.lb_spJhje.Text != null)
                {

                    //11111111111111111111111111111111--入库总价格--11111111111111111111111111111111111111
                    if (Convert.IsDBNull(this.dgv_rkDan.CurrentRow.Cells[3].Value) == false)
                    {
                        decimal zongSum = 0;
                        foreach (DataGridViewRow row in this.dgv_rkDan.Rows)
                        {
                            if (Convert.IsDBNull(row.Cells[3].Value) == false)
                                zongSum += Convert.ToDecimal(row.Cells[3].Value);
                        }
                        //当前入库单的
                        this.lb_spRkzje.Text = zongSum.ToString();
                    }
                    //1111111111111111111111111111111111111111111111111111111111111111111111
                }

                //22222222222222222222222222222222222--入库单编号--2222222222222222222222222
                //自动添加入库单据编号
                if (this.lb_Djbh.Text != null)
                {
                    this.dgv_rkDan.CurrentRow.Cells[6].Value = this.lb_Djbh.Text;
                }
                //22222222222222222222222222222222222222222222222222222222222222222222222222

                //```````````````````^^```````空单元格提示条```````````^^`````````````````````````````````````
                if (Convert.IsDBNull(this.dgv_rkDan.CurrentCell.Value) == true)
                {
                    switch (this.dgv_rkDan.CurrentCell.ColumnIndex)
                    {
                        case 0:
                            Rectangle R1 = this.dgv_rkDan.GetCellDisplayRectangle(this.dgv_rkDan.CurrentCell.ColumnIndex, this.dgv_rkDan.CurrentCell.RowIndex, false);  //获取单元格位置
                            this.tp_Tishi.Show("请单击右键,\n查找未审的进货单据编号", this, R1.X + this.groupBox6.Location.X + this.dgv_rkDan.Location.X + R1.Width - 15, R1.Y + this.groupBox6.Location.Y + this.dgv_rkDan.Location.Y + R1.Height + R1.Height, 3000);
                            break;
                        case 1:
                            Rectangle R2 = this.dgv_rkDan.GetCellDisplayRectangle(this.dgv_rkDan.CurrentCell.ColumnIndex, this.dgv_rkDan.CurrentCell.RowIndex, false);  //获取单元格位置
                            this.tp_Tishi.Show("请单击右键,\n查找当前进货单的商品编号", this, R2.X + this.groupBox6.Location.X + this.dgv_rkDan.Location.X + R2.Width - 15, R2.Y + this.groupBox6.Location.Y + this.dgv_rkDan.Location.Y + R2.Height + R2.Height, 3000);
                            break;
                        default:
                            break;
                    }
                }
                //```````````````````````````````````````````````````````````````````````````

            }
            //------^^------库存设置-----^^--------
            ////对库存上限的操作
            if ((this.tb_Kcsx.Text == "" || this.tb_Kcsx.Text == "0" || this.tb_spBzsj.Text == "" || this.tb_spBzsj.Text == "0.00") && this.dgv_rkDan.Enabled == true)
            {
                fkc.Text = spIDstr;
                fkc.ShowDialog();
            }

            //--------------------^^-----右键菜单------^^---------------------
            if (Convert.IsDBNull(this.dgv_rkDan.CurrentCell.Value) == true)
            {
                //8888888888888888888888888888888888--鼠标右键--88888888888888888888888888888888888

                //鼠标右键add items的方法

                //~~~~~~~~~~~~~~~~~~~进货单编号编号~~~~~~~~~~~~~~~~~~
                dr1 = cz.SqlDr(str4 + str);
                if (dr1.Read() == true)
                {
                    if (this.cms_djID.Items.Count >= 0)
                    {
                        this.cms_djID.Items.Clear();
                    }
                    this.cms_djID.Items.Add("查找要入库的单据编号");
                    this.cms_djID.Items[0].Enabled = false;
                    DataTable dt1 = cz.dtShuJuBiao(str4 + str);
                    for (int aa = 0; aa < dt1.Rows.Count; aa++)
                    { this.cms_djID.Items.Add(dt1.Rows[aa].ItemArray[0].ToString()); }
                }
                dr1.Close();

                //~~~~~~~~~~~~~~~~~~~~~进货单据编号~~~~~~~~~~~~~~~~~~~~~~~~
                if (this.dgv_rkDan.CurrentCell.OwningColumn.Index == 0)
                {
                    this.dgv_rkDan.CurrentRow.Cells[0].ContextMenuStrip = this.cms_djID;
                    this.cms_spID.Enabled = false;
                }
                else
                {
                    this.cms_spID.Enabled = true;
                }

                //~~~~~~~~~~~~~~~~~~~~~商品编号~~~~~~~~~~~~~~~~~~~~~~~~
                if (this.dgv_rkDan.CurrentCell.OwningColumn.Index == 1 )
                {                    
                    this.dgv_rkDan.CurrentRow.Cells[1].ContextMenuStrip = this.cms_spID;
                    this.cms_djID.Enabled = false;
                    SqlDataAdapter DA2 = new SqlDataAdapter(str3 + " and jhxqBiao.jhDjID = '" + this.dgv_rkDan.CurrentRow.Cells[0].Value.ToString() + "' ", cz.sqlCon());
                    DataTable dt2 = new DataTable();
                    DA2.Fill(dt2);                   
                    for (int a = 0; a < this.dgv_rkDan.Rows.Count-1; a++)
                    {
                        if (this.dgv_rkDan.CurrentRow.Cells[0].Value.ToString() == this.dgv_rkDan.Rows[a].Cells[0].Value.ToString() )
                        {                               
                            aa11.Add(this.dgv_rkDan.Rows[a].Cells[1].Value.ToString());
                        }
                    }
                    for (int aa = 0; aa < dt2.Rows.Count; aa++)
                    { 
                         if (this.cms_spID.Items.Count >= 0)
                        {
                            this.cms_spID.Items.Clear();
                        }
                        this.cms_spID.Items.Add("查找当前进货单的商品编号");
                        this.cms_spID.Items[0].Enabled = false;
                        if ( aa11.Contains(dt2.Rows[aa].ItemArray[0])==false)
                        {
                            this.cms_spID.Items.Add(dt2.Rows[aa].ItemArray[0].ToString());
                        }                                             
                    }                   

                  }
                  else { this.cms_djID.Enabled = true; }
                    //8888888888888888888888888888888888888888888888888888888888888888888888888888
                }

            
        }
        //---------------------------^^------将右键值付给网格------^^---------------------------------------
        private void cms_djID_ItemClicked(object sender, ToolStripItemClickedEventArgs e1)
        { 
            this.dgv_rkDan.CurrentCell.Value = e1.ClickedItem.Text;
        }

⌨️ 快捷键说明

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