示例#1
0
        void Accept()
        {
            try
            {
                if (!CheckValidate_F())
                {
                    return;
                }

                if (c_type == Convert.ToInt16(Form_Type.Insert))
                {
                    MessageBoxResult result = NoteBox.Show("Bạn chắc chắn muốn thêm mới người sử dụng hay không?", "Thông báo", NoteBoxLevel.Question);
                    if (MessageBoxResult.Yes == result)
                    {
                        User_Info _User_Info = new User_Info();
                        _User_Info.FullName  = txtFullName.Text;
                        _User_Info.User_Name = txtUserName.Text;
                        _User_Info.Phone     = txtPhone.Text;
                        _User_Info.Pass      = txtPass.Text;
                        _User_Info.User_Type = 1;
                        _User_Info.Group_Id  = Convert.ToInt16(cbo_Group_User.SelectedValue);
                        _User_Info.Status    = Convert.ToInt16(User_Status_Type.Active);

                        decimal _id = 0;

                        if (c_User_Controller.User_Insert(_User_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)
                    {
                        User_Info _User_Info = new User_Info();
                        _User_Info.FullName  = txtFullName.Text;
                        _User_Info.User_Name = txtUserName.Text;
                        _User_Info.Phone     = txtPhone.Text;
                        _User_Info.Pass      = txtPass.Text;
                        _User_Info.User_Type = 1;
                        _User_Info.Group_Id  = Convert.ToInt16(cbo_Group_User.SelectedValue.ToString());
                        _User_Info.Status    = c_User_Info.Status;

                        if (c_User_Controller.User_Update(c_User_Info.User_Id, _User_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());
            }
        }