コード例 #1
0
        private async void Btn_add_Click(object sender, RoutedEventArgs e)
        { //add
            try
            {
                HelpClass.StartAwait(grid_main);
                //if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "add"))
                //{

                //      if (HelpClass.validate(requiredControlList, this) && HelpClass.IsValidEmail(this))
                {
                    sysEmail.emailId = 0;
                    sysEmail.name    = tb_name.Text;
                    sysEmail.email   = tb_email.Text;
                    // sysEmail.password = pb_password.Password;
                    sysEmail.password = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(pb_password.Password));

                    sysEmail.port  = int.Parse(tb_port.Text);
                    sysEmail.isSSL = tgl_isSSL.IsChecked.Value;
                    //  sysEmail.isMajor = tgl_isMajor.IsChecked.Value;
                    sysEmail.smtpClient = tb_smtpClient.Text;
                    sysEmail.side       = cb_side.SelectedValue.ToString();
                    // sysEmail.branchId = (int)cb_branchId.SelectedValue;
                    sysEmail.notes        = tb_notes.Text;
                    sysEmail.createUserId = MainWindow.userLogin.userId;
                    sysEmail.updateUserId = MainWindow.userLogin.userId;
                    sysEmail.isActive     = 1;

                    int s = await sysEmail.Save(sysEmail);

                    if (s.Equals(-4))
                    {
                        Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trMajorEmaillAlreadyExists"), animation: ToasterAnimation.FadeIn);
                    }
                    else if (!s.Equals(0))
                    {
                        Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopAdd"), animation: ToasterAnimation.FadeIn);

                        Clear();
                        await RefreshUsersList();
                        await Search();
                    }
                    else
                    {
                        Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                    }
                }
                //}
                //else
                //    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);

                HelpClass.EndAwait(grid_main);
            }
            catch (Exception ex)
            {
                HelpClass.EndAwait(grid_main);
                HelpClass.ExceptionMessage(ex, this);
            }
        }
コード例 #2
0
        private async void Btn_add_Click(object sender, RoutedEventArgs e)
        {//add
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "add") || SectionData.isAdminPermision())
                {
                    if (isValid())
                    {
                        sysEmail.emailId = 0;
                        sysEmail.name    = tb_name.Text;
                        sysEmail.email   = tb_email.Text;
                        // sysEmail.password = pb_password.Password;
                        sysEmail.password = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(pb_password.Password));

                        sysEmail.port         = int.Parse(tb_port.Text);
                        sysEmail.isSSL        = tgl_isSSL.IsChecked;
                        sysEmail.isMajor      = tgl_isMajor.IsChecked;
                        sysEmail.smtpClient   = tb_smtpClient.Text;
                        sysEmail.side         = cb_side.SelectedValue.ToString();
                        sysEmail.branchId     = (int)cb_branchId.SelectedValue;
                        sysEmail.notes        = tb_notes.Text;
                        sysEmail.createUserId = MainWindow.userID;
                        sysEmail.updateUserId = MainWindow.userID;
                        sysEmail.isActive     = 1;

                        int s = await sysEmail.Save(sysEmail);

                        if (s.Equals(-4))
                        {
                            Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trMajorEmaillAlreadyExists"), animation: ToasterAnimation.FadeIn);
                        }
                        else if (!s.Equals(0))
                        {
                            Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopAdd"), animation: ToasterAnimation.FadeIn);
                            Btn_clear_Click(null, null);
                        }
                        else
                        {
                            Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                        }

                        await RefreshSysEmailList();

                        Tb_search_TextChanged(null, null);
                    }
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }