Example #1
0
        private void CategoriesRadButtonElement_Click(object sender, EventArgs e)
        {
            CategoryRadForm _categoryRadForm = new CategoryRadForm();

            if (!isOpenForm(_categoryRadForm))
            {
                _categoryRadForm.MdiParent = this;
                _categoryRadForm.Show();
            }
        }
        private void GetAndLoadCategoryFromDB()
        {
            CategoryRadForm cat    = this._currentParentForm as CategoryRadForm;
            var             result = (Int32)cat._currentRowSeleted.Cells["CategoryID"].Value;

            _currentCategorySelected = this._serviceCategoryBL.Find(result);
            if (_currentCategorySelected != null)
            {
                CodeCategoryRadTextBox.Text       = _currentCategorySelected.CategoryCode;
                CategoryRadTextBox.Text           = _currentCategorySelected.CategoryName;
                DescriptionRadRichTextEditor.Text = _currentCategorySelected.Description;
            }
        }
        private void RegisterRadButton_Click(object sender, EventArgs e)
        {
            RadButton       currentButton = sender as RadButton;
            CategoryRadForm cat           = this._currentParentForm as CategoryRadForm;

            switch (currentButton.Text)
            {
            case "Registrar":
                #region Register Category
                if (ValidateForm())
                {
                    try
                    {
                        Category _c = new Category()
                        {
                            CategoryCode = CodeCategoryRadTextBox.Text.ToUpper(),
                            CategoryName = CategoryRadTextBox.Text.ToUpper()
                        };
                        if (DescriptionRadRichTextEditor.Text != String.Empty)
                        {
                            _c.Description = DescriptionRadRichTextEditor.Text.ToUpper();
                        }
                        this._serviceCategoryBL.Add(_c);
                        RadMessageBox.Show("Categoría creada satisfactoriamente", "JOSIAS INDUSTRIAL", MessageBoxButtons.OK, RadMessageIcon.Info);
                        cat.FillCategoryRadGridView();
                        this.Close();
                        return;
                    }
                    catch (Exception ex)
                    {
                        StringBuilder sb = new StringBuilder();
                        sb.AppendLine("Message").AppendLine(ex.Message)
                        .AppendLine("StackTrace").AppendLine(ex.StackTrace.ToString());


                        RadMessageBox.Show("Error ocurrido, presione el botón para desplegarlo", "JOSIAS INDUSTRIAL", MessageBoxButtons.OK, RadMessageIcon.Error, sb.ToString());
                        return;
                    }
                }
                #endregion
                break;

            case "Actualizar":
                #region Update Category
                if (ValidateForm())
                {
                    try
                    {
                        _currentCategorySelected.CategoryCode = CodeCategoryRadTextBox.Text.ToUpper();
                        _currentCategorySelected.CategoryName = CategoryRadTextBox.Text.ToUpper();
                        _currentCategorySelected.Description  = DescriptionRadRichTextEditor.Text.ToUpper();

                        this._serviceCategoryBL.Update(_currentCategorySelected);
                        RadMessageBox.Show("Categoría actualizada satisfactoriamente", "JOSIAS INDUSTRIAL", MessageBoxButtons.OK, RadMessageIcon.Info);
                        cat.FillCategoryRadGridView();
                        this.Close();
                        return;
                    }
                    catch (Exception ex)
                    {
                        StringBuilder sb = new StringBuilder();
                        sb.AppendLine("Message").AppendLine(ex.Message)
                        .AppendLine("StackTrace").AppendLine(ex.StackTrace.ToString());
                        RadMessageBox.Show("Error ocurrido, presione el botón para desplegarlo", "JOSIAS INDUSTRIAL", MessageBoxButtons.OK, RadMessageIcon.Error, sb.ToString());
                        return;
                    }
                }
                #endregion
                break;

            case "Aceptar":
                this.Close();
                break;
            }
        }