示例#1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (valid())
            {
                bool flag;
                ProductAddOrEdit.AlbumID     = int.Parse(txtId.Text);
                ProductAddOrEdit.AlbumName   = txtName.Text;
                ProductAddOrEdit.ReleaseYear = int.Parse(txtYear.Text);
                ProductAddOrEdit.Quantity    = int.Parse(txtQuantity.Text);
                ProductAddOrEdit.Status      = int.Parse(txtStatus.Text);
                AlbumDB proData = new AlbumDB();

                if (addorEdit == true)
                {
                    flag = proData.AddNewProduct(ProductAddOrEdit);
                }
                else
                {
                    txtId.Enabled = false;
                    flag          = proData.UpdateProduct(ProductAddOrEdit);
                }
                if (flag == true)
                {
                    MessageBox.Show("Save Success!");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Save Fail!");
                }
            }
            else
            {
                this.DialogResult = System.Windows.Forms.DialogResult.None;
            }
        }