private void toolDel_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (DBGrid.CurrentRow == null) { return; } if (MessageBox.Show(clsTranslate.TranslateString("Do you really want to delete it?"), clsTranslate.TranslateString("Confirm"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } modPriceAdjustForm mod = _dal.GetItem(DBGrid.CurrentRow.Cells[0].Value.ToString(), out Util.emsg); if (mod.Status == 1) { MessageBox.Show("该单据已审核,您不能删除!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } bool ret = _dal.Save("DEL", mod, null, out Util.emsg); if (ret) { LoadData(); } else { MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }
public void EditItem(string formid) { try { this.Cursor = Cursors.WaitCursor; _action = "EDIT"; modPriceAdjustForm mod = _dal.GetItem(formid, out Util.emsg); if (mod != null) { txtFormId.Text = formid; dtpFormDate.Value = mod.FormDate; txtRemark.Text = mod.Remark; if (mod.Status == 1) { status4.Image = Properties.Resources.audited; Util.ChangeStatus(this, true); DBGrid.ReadOnly = true; mnuNew.Enabled = false; mnuDelete.Enabled = false; toolSave.Enabled = false; } else { status4.Image = null; toolSave.Visible = true; Util.ChangeStatus(this, false); DBGrid.ReadOnly = false; mnuNew.Enabled = true; mnuDelete.Enabled = true; toolSave.Enabled = true; } DBGrid.Rows.Clear(); LoadDBGrid(); DBGrid2_DoubleClick(null, null); BindingCollection <modPriceAdjustDetail> list = _dal.GetDetail(formid, out Util.emsg); if (list == null && !string.IsNullOrEmpty(Util.emsg)) { MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { foreach (modPriceAdjustDetail modd in list) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Cells[0].Value = modd.ProductId; row.Cells[1].Value = modd.ProductName; row.Cells[2].Value = modd.Qty.ToString(); row.Cells[3].Value = modd.CurrentPrice; row.Cells[4].Value = modd.TruePrice; row.Cells[5].Value = modd.CurrentMny; row.Cells[6].Value = modd.TrueMny; row.Cells[7].Value = modd.Differ; row.Cells[8].Value = modd.Remark; row.Height = 40; DBGrid.Rows.Add(row); row.Dispose(); } GetDetailSum(); } //DBGrid.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }