Example #1
0
        void Accept()
        {
            try
            {
                if (!CheckValidate_F())
                {
                    return;
                }
                Category_Controller _Category_Controller = new Category_Controller();

                if (c_type == Convert.ToInt16(Form_Type.Insert))
                {
                    MessageBoxResult result = NoteBox.Show("Bạn chắc chắn muốn thêm mới nhà cung cấp hay không?", "Thông báo", NoteBoxLevel.Question);
                    if (MessageBoxResult.Yes == result)
                    {
                        Category_Info _Category_Info = new Category_Info();
                        _Category_Info.Category_Name = txtName.Text;

                        decimal _id = 0;

                        if (_Category_Controller.Category_Insert(_Category_Info, ref _id))
                        {
                            NoteBox.Show("Thêm mới thành công");
                            c_id_insert = _id;
                            this.Close();
                        }
                        else
                        {
                            NoteBox.Show("Có lỗi trong quá trình thêm mới", "", NoteBoxLevel.Error);
                        }
                    }
                }
                else
                {
                    MessageBoxResult result = NoteBox.Show("Bạn chắc chắn muốn cập nhật hay không?", "Thông báo", NoteBoxLevel.Question);
                    if (MessageBoxResult.Yes == result)
                    {
                        Category_Info _Category_Info = new Category_Info();
                        _Category_Info.Category_Name = txtName.Text;

                        if (_Category_Controller.Category_Update(c_Category_Info.Category_Id, _Category_Info))
                        {
                            NoteBox.Show("Cập nhật dữ liệu thành công");
                            c_id_insert = 1;
                            this.Close();
                        }
                        else
                        {
                            NoteBox.Show("Có lỗi trong quá trình cập nhật dữ liệu", "", NoteBoxLevel.Error);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CommonData.log.Error(ex.ToString());
            }
        }