コード例 #1
0
ファイル: CatalogueValue.cs プロジェクト: suhasrake/CSLERP
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                cataloguevalue   catval   = new cataloguevalue();
                CatalogueValueDB catvalDB = new CatalogueValueDB();

                catval.catalogueValueID = txtID.Text;
                catval.description      = txtDescription.Text;
                catval.catalogueID      = selectedCatalogueID;
                catval.status           = ComboFIll.getStatusCode(cmbStatus.SelectedItem.ToString());
                System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button;
                string btnText = btn.Text;


                if (catvalDB.validateCatalogue(catval))
                {
                    if (btnText.Equals("Update"))
                    {
                        if (catvalDB.updateCatalogueValue(catval))
                        {
                            MessageBox.Show("Catalogue Value updated");
                            closeAllPanels();
                            ListCatalogueValues(selectedCatalogueID);
                        }
                        else
                        {
                            MessageBox.Show("Failed to update Catalogue Value Status");
                        }
                    }
                    else if (btnText.Equals("Save"))
                    {
                        if (catvalDB.insertCatalogueValue(catval))
                        {
                            MessageBox.Show("Catalogue Value Added");
                            closeAllPanels();
                            ListCatalogueValues(selectedCatalogueID);
                        }
                        else
                        {
                            MessageBox.Show("Failed to Insert Catalogue Value");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Catalogue Value Data Validation failed");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Failed Adding / Editing User Data");
            }
        }