Пример #1
0
        private void btnCaAdd_Click(object sender, EventArgs e)
        {
            Category newCat = new Category();
            newCat.CategoryID = -1;
            newCat.CategoryName = txtCatName.Text;
            newCat.Description = rtxtDescription.Text;

            int check = newCat.isValid();

            if (check < -1)
            {
                MessageBox.Show(newCat.getErrorMessage(check));
            }
            else {
                this.dataModel.insertNewRow(newCat);
                //this.datamodel.resetControl();
                MessageBox.Show("Completed");
            }
        }
Пример #2
0
        protected void doAdd_Update()
        {
            this.errorProvider.Clear();

            Category dataObj = new Category();
            dataObj.CategoryID = -1;
            dataObj.CategoryName = this.txtCatName.Text;
            dataObj.Description = this.rtxtDescription.Text;

            int check = dataObj.isValid();

            if (check < 0)
            {
                this.showErrors();
                return;
            }

            try
            {
                if (this.AddNewMode == true)
                {
                    this.dataModel.insertNewRow(dataObj);
                }
                else
                {
                    dataObj.CategoryID = int.Parse(this.txtCatID.Text);
                    this.dataModel.updateRow(dataObj);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                this.clearForm();
                this.Close();
            }
        }