Exemple #1
0
        void UpdateComp()
        {
            if (lsCompanyList.SelectedIndex > -1)
            {
                string strCompanyCode = lsCompanyList.SelectedItem.ToString();
                //rest of your logic
                //mdlGlobal.systemUsers.CompanyCode = strCompanyCode;
                Global.CompanyCode           = strCompanyCode;
                Global.intUserID             = mdlGlobal.systemUsers.SystemUsersID;
                mdlGlobal.companyInformation = companyManagement.RetrieveCompanyInformationByCode(Global.CompanyCode);
                Global.AllVisionsCS          = mdlGlobal.companyInformation.AllVisionsCS;

                //periksa versi didatabase jika lebih besar maka periksa perubahan script
                var e1 = new Version(mdlGlobal.companyInformation.APPVersion);
                var e2 = new Version(Global.strVersionNo.Trim());
                if (e1.CompareTo(e2) < 0)
                {
                    DataAccess dataAccess = new DataAccess(Global.AllVisionsCS);

                    string[] DirectoryList = Directory.GetDirectories(Directory.GetCurrentDirectory() + @"\Versions\", "*");

                    string sourceDir = Directory.GetCurrentDirectory() + @"\Versions";

                    string[] fileList;
                    foreach (string dl in DirectoryList)
                    {
                        fileList = Directory.GetFiles(dl, "*.*");
                        string DirName = dl.Substring(sourceDir.Length + 1);
                        var    e3      = new Version(DirName.Trim());
                        if (e1.CompareTo(e3) < 0)
                        {
                            foreach (string f in fileList)
                            {
                                string fName = f.Substring(dl.Length + 1);

                                string strError = dataAccess.ProcessDataWithQueryParameter(File.ReadAllText(Directory.GetCurrentDirectory() + @"\Versions\" + e3 + @"\" + fName));

                                if (strError != string.Empty)
                                {
                                    MessageBox.Show(strError, " UPDATE DATABASE ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                                    //updateFailed = true;
                                }
                            }
                        }
                    }
                    mdlGlobal.companyInformation.APPVersion = Global.strVersionNo.Trim();
                    SaveCompanyData();
                }
                this.DialogResult = DialogResult.OK;
            }
        }
Exemple #2
0
        void Login()
        {
            try
            {
                UserManagement userManagement = new UserManagement();
                string         userpass       = dbSecurity.MD5(txtUserPassword.Text);
                mdlGlobal.systemUsers = userManagement.CekUserAuthorize(txtUserID.Text, userpass);
                if (mdlGlobal.systemUsers.SystemUsersID > 0)
                {
                    Global.CompanyCode           = mdlGlobal.systemUsers.CompanyCode;
                    Global.intUserID             = mdlGlobal.systemUsers.SystemUsersID;
                    mdlGlobal.companyInformation = companyManagement.RetrieveCompanyInformationByCode(Global.CompanyCode);
                    Global.AllVisionsCS          = mdlGlobal.companyInformation.AllVisionsCS;

                    //periksa versi didatabase jika lebih besar maka periksa perubahan script
                    var e1 = new Version(mdlGlobal.companyInformation.APPVersion);
                    var e2 = new Version(Global.strVersionNo.Trim());
                    if (e1.CompareTo(e2) < 0)
                    {
                        DataAccess dataAccess = new DataAccess(Global.AllVisionsCS);

                        string[] DirectoryList = Directory.GetDirectories(Directory.GetCurrentDirectory() + @"\Versions\", "*");

                        string sourceDir = Directory.GetCurrentDirectory() + @"\Versions";

                        string[] fileList;
                        foreach (string dl in DirectoryList)
                        {
                            fileList = Directory.GetFiles(dl, "*.*");
                            string DirName = dl.Substring(sourceDir.Length + 1);
                            var    e3      = new Version(DirName.Trim());
                            if (e1.CompareTo(e3) < 0)
                            {
                                foreach (string f in fileList)
                                {
                                    string fName = f.Substring(dl.Length + 1);

                                    string strError = dataAccess.ProcessDataWithQueryParameter(File.ReadAllText(Directory.GetCurrentDirectory() + @"\Versions\" + e3 + @"\" + fName));

                                    if (strError != string.Empty)
                                    {
                                        MessageBox.Show(strError, " UPDATE DATABASE ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                                        //updateFailed = true;
                                    }
                                }
                            }
                        }
                        mdlGlobal.companyInformation.APPVersion = Global.strVersionNo.Trim();
                        SaveCompanyData();
                    }

                    SaveSystemUserRoles();

                    frmMain frmMain = new frmMain();
                    frmMain.Text = mdlGlobal.systemUsers.CompanyName;
                    frmMain.Show();
                    //frmEmployee frmEmployee = new frmEmployee();
                    //frmEmployee.Show();

                    txtUserID.Text       = "";
                    txtUserPassword.Text = "";
                    Hide();
                }
                else
                {
                    MessageBox.Show("User ID and Password not registered");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Global.strProductName);
            }
        }