예제 #1
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            try
            {
                string EngineName, ConnectionString, FolderLocation;
                bool   AutoCreateDb;

                BaseFramework.UseEventServer       = checkEdit3.Checked;
                BaseFramework.ShowWarningWhenLogin = checkEdit4.Checked &&
                                                     !BaseUtility.IsDebugMode;

                BaseFramework.AutoClearMetaDataVersion = checkEdit1.Checked;
                if (BaseUtility.IsDebugMode)
                {
                    BaseFramework.AutoUpdateMetaData = checkEdit2.Checked;
                }

                Connection.GetConnectionData(comboBoxEdit1.Text,
                                             out EngineName, out ConnectionString,
                                             out AutoCreateDb, out FolderLocation);

                BaseFramework.DefaultDp = BaseFramework
                                          .DpEngine.CreateDataPersistance(
                    EngineName, ConnectionString, AutoCreateDb, FolderLocation);

                if (BaseSecurity.CurrentLogin.Login(
                        comboBoxEdit1.Text, comboBoxEdit2.Text, textEdit1.Text,
                        textEdit2.Text))
                {
                    string Section = BaseFramework.ProductName.Replace(" ", "_") + "_Login";

                    xmlc.WriteString(Section, "ConnectionName", comboBoxEdit1.Text);
                    xmlc.WriteString(Section, "UserName", textEdit1.Text);

                    UserLog.CheckAutoClearLog();

                    if (BaseSecurity.LoginWithRole)
                    {
                        xmlc.WriteString(Section, "RoleName", comboBoxEdit2.Text);
                    }
                    xmlc.Save();
                    if (BaseSecurity.CurrentLogin.CurrentRole.Length == 0 &&
                        !BaseUtility.IsDebugMode)
                    {
                        XtraMessageBox.Show("Anda Login sebagai Admin, dengan hak akses penuh terhadap semua modul yang ada.\n" +
                                            "Buat User dan Peran Baru untuk membatasi hak akses user yang masuk ke aplikasi !",
                                            "Pemberitahuan Login Admin", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    XtraMessageBox.Show("Nama User, Peran dan Password tidak sesuai !",
                                        "Login tidak berhasil", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    DialogResult = DialogResult.None;
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "Error Simpan Koneksi",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
            }
        }