private void toolStripButton1_Click(object sender, EventArgs e) { Add_materialForm add_mat = new Add_materialForm("add", ""); add_mat.materialInfoFormChange += new Add_materialForm.MaterialInfoFormChange(add_mat_materialInfoFormChange); add_mat.ShowDialog(); }
private void 修改_Click(object sender, EventArgs e) { if (this.dataGridView1.SelectedRows.Count > 0) { if (this.dataGridView1.SelectedRows[0].Cells["物料编号"].Value == null) { return; } string matSysId = this.dataGridView1.SelectedRows[0].Cells["物料编号"].Value.ToString().Trim(); if (matSysId == "") { return; } Add_materialForm edit_mat = new Add_materialForm("edit", matSysId); edit_mat.materialInfoFormChange += new Add_materialForm.MaterialInfoFormChange(edit_mat_materialInfoFormChange); edit_mat.ShowDialog(); } else { MessageBox.Show("请选中您要修改的行!"); } }
private void 修改_Click(object sender, EventArgs e) { if (this.dataGridView1.SelectedRows.Count > 0) { if (this.dataGridView1.SelectedRows[0].Cells["物料编号"].Value == null) return; string matSysId = this.dataGridView1.SelectedRows[0].Cells["物料编号"].Value.ToString().Trim(); if (matSysId == "") return; Add_materialForm edit_mat = new Add_materialForm("edit", matSysId); edit_mat.materialInfoFormChange += new Add_materialForm.MaterialInfoFormChange(edit_mat_materialInfoFormChange); edit_mat.ShowDialog(); } else MessageBox.Show("请选中您要修改的行!"); }
/// <summary> /// 使DataGridView按Enter键向后移动一个单元格 /// </summary> /// <param name="msg"></param> /// <param name="keyData"></param> /// <returns></returns> protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (this.dgvFocus == false) return false; DataGridViewCell cell = this.dataGridViewReceDetail.CurrentCell; if (keyData == Keys.Enter && cell.OwningColumn.HeaderText == "商品编号") { #region 商品编号 this.dataGridViewReceDetail.EndEdit(); if (cell.Value != null && cell.Value.ToString().Trim() != "") { if (SStorehouseId == "") { MessageBox.Show("请先选择一个仓库!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; ////// } string strMatID = cell.Value.ToString().Trim(); string strSql = "select MatID 商品编号,MatName 商品名称,Specifications 型号规格,Units 计量单位 " + "from T_MatInf where MatID like '%{0}%' or MatName like '%{1}%'"; strSql = string.Format(strSql, strMatID, strMatID); int matType = 0; DataTable dt = (new SqlDBConnect()).Get_Dt(strSql); if (dt == null || dt.Rows.Count <= 0) { DialogResult dialogResult = MessageBox.Show("查找的商品信息不存在,是否新增商品信息?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialogResult == DialogResult.Yes) { Add_materialForm add_mat = new Add_materialForm("add", ""); add_mat.matId = cell.Value.ToString().Trim(); add_mat.ShowDialog(); if (add_mat.DialogResult == DialogResult.OK) cell.Value = add_mat.matId; } else cell.Value = ""; } else if (dt.Rows.Count == 1) { cell.Value = dt.Rows[0]["商品编号"].ToString().Trim(); } else { ReceiptFilterInfoForm form = new ReceiptFilterInfoForm(cell, dt, "商品编号", SStorehouseId, matType); form.StartPosition = FormStartPosition.CenterScreen; form.ShowDialog(); if (form.DialogResult == DialogResult.OK) matType = form.matType; } DataBindMatInf(cell.Value.ToString().Trim(), matType); //if (this.dataGridViewReceDetail.CurrentCell.RowIndex == 0) //{ // SendKeys.Send("{Up}"); // SendKeys.Send("{TAB}"); SendKeys.Send("{TAB}"); SendKeys.Send("{TAB}"); SendKeys.Send("{TAB}"); SendKeys.Send("{ESC}"); //} //else //{ // SendKeys.Send("{TAB}"); SendKeys.Send("{TAB}"); SendKeys.Send("{TAB}"); SendKeys.Send("{TAB}"); SendKeys.Send("{ESC}"); //} //显示当前仓库、当前物料、当前类型的库存 string matId = this.dataGridViewReceDetail.CurrentRow.Cells["商品编号"].Value.ToString().Trim(); if (this.dataGridViewReceDetail.CurrentRow.Cells["n_MatType"].Value != null && this.dataGridViewReceDetail.CurrentRow.Cells["n_MatType"].Value.ToString().Trim() != "") matType = Convert.ToInt32(this.dataGridViewReceDetail.CurrentRow.Cells["n_MatType"].Value.ToString().Trim()); StockStatus stockStatus = ReceiptModCfg.GetStockNum(SStorehouseId, matId, matType); this.tsslCurStockNum.Text = stockStatus.stockNum.ToString(); this.tsslFirstCount.Text = stockStatus.firstCount.ToString(); this.tsslStockInCount.Text = stockStatus.stockInCount.ToString(); this.tsslStockOutCount.Text = stockStatus.stockOutCount.ToString(); if (this.dataGridViewReceDetail.CurrentRow.Cells["商品名称"].Value != null) this.tsslMatName.Text = this.dataGridViewReceDetail.CurrentRow.Cells["商品名称"].Value.ToString().Trim(); } #endregion } //if (keyData == Keys.Enter && this.dataGridViewReceDetail.Focused) //{ // System.Windows.Forms.SendKeys.Send("{tab}"); // return true; //} bool enterkey = false; if (keyData == Keys.Enter) //监听回车事件 { if (this.dataGridViewReceDetail.IsCurrentCellInEditMode) //如果当前单元格处于编辑模式 { enterkey = true; //把是否点击按钮设置为真 //if (btnSetEnter.Text != "竖") if (this.dataGridViewReceDetail.CurrentCell.RowIndex == this.dataGridViewReceDetail.Rows.Count - 1) //最后一行 { if (this.dataGridViewReceDetail.CurrentCell.OwningColumn.HeaderText == "商品编号") { SendKeys.Send("{Tab}"); SendKeys.Send("{Tab}"); SendKeys.Send("{Tab}"); SendKeys.Send("{Tab}"); SendKeys.Send("{ESC}"); SendKeys.Send("{Tab}"); } else SendKeys.Send("{Tab}"); } else { SendKeys.Send("{Up}"); if (this.dataGridViewReceDetail.CurrentCell.OwningColumn.HeaderText == "商品编号") { SendKeys.Send("{Tab}"); SendKeys.Send("{Tab}"); SendKeys.Send("{Tab}"); SendKeys.Send("{Tab}"); SendKeys.Send("{ESC}"); SendKeys.Send("{Tab}"); } else SendKeys.Send("{Tab}"); } } } //继续原来base.ProcessCmdKey中的处理 return base.ProcessCmdKey(ref msg, keyData); }