private void btnSave_Click(object sender, EventArgs e) { string str = ProductManager.SavePoduct(ProductManager.GetCurProduct()); if (str == "OK") { MsgBox.Show("保存成功!"); } else { MsgBox.Show("保存失败:" + str, ico: MessageBoxIcon.Error); } }
private void btnOK_Click(object sender, EventArgs e) { tbName.Text = tbName.Text.Trim(); tbNote.Text = tbNote.Text.Trim(); Product newProduct = new Product(int.Parse(tbId.Text), tbName.Text.Trim(), tbNote.Text.Trim()); Product oldProduct = null; if (Id == -1) //添加产品,生成 Id { newProduct.Id = ProductManager.GetNextValidId(); } else { oldProduct = ProductManager.GetProductById(Id); } string rs = ProductManager.SavePoduct(newProduct); if (rs == "OK") { string msg = ""; if (Id == -1) { msg = string.Format("添加产品成功:[{0},{1}]", newProduct.Id, newProduct.Name); } else { msg = string.Format("修改产品成功:[{0}] [{1} -> {2}] [{3} -> {4}]", Id, oldProduct.Name, newProduct.Name, oldProduct.Note, newProduct.Note); } MsgBox.Show(msg); Globals.MLog.Info(msg); Close(); } else { MsgBox.Show(rs, ico: MessageBoxIcon.Error); } }