Exemple #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            btnLogin.Enabled  = false;
            btnCancel.Enabled = false;

            Cursor.Current = Cursors.WaitCursor;

            if (Program.OPLogin(txtUserName.Text.ToString(), txtPassword.Text.ToString()) == true)
            {
                NSCUtils.ADUser aduser = new NSCUtils.ADUser(txtUserName.Text.ToString());
                OPGlobals.PreviousUser = OPGlobals.CurrentUser;

                Program.LoadUser(aduser, "P");

                Cursor.Current = Cursors.AppStarting;
                frmOperationPlan frm = frmOperationPlan.getInstance();
                frm.ArrangeMenu();
                MessageBox.Show("Hi " + OPGlobals.CurrentUser.UserName + ", Welcome to the NSC Operational Plan !", "Operation Plan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Dispose();
            }
            else
            {
                Cursor.Current = Cursors.AppStarting;
                MessageBox.Show("You are not Authorise to run this program", "Operational Plan", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            btnLogin.Enabled  = true;
            btnCancel.Enabled = true;
        }
 public static frmOperationPlan getInstance()
 {
     if (Instance == null)
     {
         Instance = new frmOperationPlan();
     }
     return(Instance);
 }
        private frmOperationPlan()
        {
            Instance = this;
            InitializeComponent();

            frmtop = this.menuStrip1.Bottom + this.menuStrip1.Height + toolStrip1.Height;


            //OpenFrmMonthlyProgressNEW(new object(),new EventArgs());
        }
Exemple #4
0
        static void Main()
        {
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                //----------Check if another instance of this application is already running---
                //if (Process.GetProcessesByName("NSCOperationalPlan").Length > 0)
                //{
                //    throw new Exception("Another Instance of this Program is already running");
                //}

                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.AppStarting;

                OPGlobals.dbProvider = "MySql.Data.MySqlClient";
                OPGlobals.db         = MyDLLs.MyDBFactory.GetDatabase(OPGlobals.dbProvider);
                //OPGlobals.connString = "SERVER = nscutil; DATABASE = nsc_operation_plan_17_to_21; UID = sudinthap; PASSWORD = NSCv90cisc0;";
                OPGlobals.connString = "SERVER = nscutil; DATABASE = nsc_operation_plan_17_to_21; UID = opuser; PASSWORD = NSC@2390;";
                string exeFolder = Path.GetDirectoryName(Application.ExecutablePath);
                OPGlobals.reportParth = Path.Combine(exeFolder, @"Reports\");

                //=========================================
                if (AD_INTERGRATE)
                {
                    //NSCUtils.ADUser u = new NSCUtils.ADUser("masonli");
                    //NSCUtils.ADUser u = new NSCUtils.ADUser("saundzo");
                    //mccleti
                    NSCUtils.ADUser u = new ADUser();
                    if (string.IsNullOrEmpty(u.UserName))
                    {
                        throw new Exception("Sorry, You don't have enough permission to run this Program");
                    }
                    if (!LoadUser(u, "C"))
                    {
                        throw new Exception("Sorry, You don't have enough permission to run this Program");
                    }
                }
                else
                {
                }

                //Application.Run(new frmCPWMonthly());
                //Application.Run(new frmCPWQBR());

                Database     db     = null;
                string       strsql = "";
                DbConnection conn   = null;
                DataTable    tb     = null;

                db = MyDLLs.MyDBFactory.GetDatabase(OPGlobals.dbProvider);
                //DBConnect db = new DBConnect();
                strsql = "SELECT * FROM tbl_params ORDER BY ID DESC;";
                conn   = db.CreateDbConnection(Database.ConnectionType.ConnectionString, OPGlobals.connString);
                tb     = db.GetDataTable(conn, strsql);

                OPGlobals.currentYear  = tb.Rows[0][1].ToString();
                OPGlobals.currentMonth = int.Parse(tb.Rows[0][2].ToString());

                //--- TODO ---
                //---  Remove this in production---
                //OPGlobals.currentMonth = OPGlobals.GetPreviousMonth(OPGlobals.currentMonth, OPGlobals.currentYear);
                //=================================



                OPGlobals.FinancialYearStarts = new DateTime(int.Parse(OPGlobals.currentYear.Substring(0, 2)), 7, 1);
                OPGlobals.CurrentQuarter      = OPGlobals.GetQuarter(OPGlobals.currentMonth);

                if (tb.Rows.Count > 1)
                {
                    OPGlobals.prevoiusYear  = tb.Rows[1][1].ToString();
                    OPGlobals.previousMonth = int.Parse(tb.Rows[1][2].ToString());
                }
                else
                {
                    OPGlobals.previousMonth = OPGlobals.GetPreviousMonth(OPGlobals.currentMonth, OPGlobals.currentYear);
                    OPGlobals.prevoiusYear  = OPGlobals.GetPreviousYear(OPGlobals.currentMonth, OPGlobals.currentYear);
                }

                //string exeFolder = Path.GetDirectoryName(Application.ExecutablePath);

                OPGlobals.reportParth = Path.Combine(exeFolder, @"Reports\");
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                //frmOperationPlan frmMDI = new frmOperationPlan();
                frmOperationPlan frmMDI = frmOperationPlan.getInstance();
                Application.Run(frmMDI);
            }
            catch (Exception ex)
            {
                CloseApplication(ex.Message, false);
            }
        }