Example #1
0
        public static void LoadFormSetting(Form frm, int intASID, int intNAVID)
        {
            HRLEntities db = clsStart.efdb();

            var q = from ct in db.tblAppNavigationUser
                    where ct.ASID == intASID &&
                    ct.NAVID == intNAVID
                    select ct;

            foreach (var ctl in q)
            {
                try
                {
                    string strControl = ctl.AG_FormItem;

                    var aoControls = frm.Controls.Find(strControl, true);
                    if ((aoControls != null) && (aoControls.Length != 0))
                    {
                        Control foundControl = aoControls[0];
                        foundControl.Width  = Convert.ToInt32(ctl.AG_Width);
                        foundControl.Height = Convert.ToInt32(ctl.AG_Height);
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Example #2
0
        public static void Impersonate(int intAPPID, int intASID)
        {
            try
            {
                HRLEntities db      = clsStart.efdb();
                string      file    = System.Diagnostics.Process.GetCurrentProcess().ProcessName;
                string      app     = System.IO.Path.GetFileNameWithoutExtension(file) + ".exe";
                string      strUser = "";


                try
                {
                    var q = (from ct in db.tblAssociate
                             where ct.ASID == intASID
                             select ct).First();

                    strUser = q.AS_UserID;

                    string strPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
                    strPath = Path.Combine(strPath, app);
                    Process pro = new Process();
                    pro.StartInfo.FileName  = strPath;
                    pro.StartInfo.Arguments = intAPPID.ToString() + " 0 " + strUser;
                    pro.Start();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Could not determine user id.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #3
0
        public static HRLEntities efdb()
        {
            HRLEntities tmp = new HRLEntities();

            tmp.Database.Connection.ConnectionString = clsDAL.GetCon("HRL");
            return(tmp);
        }
Example #4
0
        //public static Dictionary<int, string> AddDropItem(Dictionary<int, string> lst, string strItem)
        //{
        //	Dictionary<int, string> rel = new Dictionary<int, string>();

        //	lst.Add(0, strItem);

        //	return lst;

        //}

        public static Dictionary <int, string> DropDownTBL(Int32 intAPPID, Int32 intNAVID, string strCol, string strCriteria, int intASID)
        {
            var dy = new Dictionary <int, string>();

            try
            {
                string strSQL = "p_DropDown_TBL " + intAPPID.ToString() + ", " + intNAVID.ToString() + ", " + strCol + ", '" + strCriteria + "', " + intASID.ToString();

                DataSet ds = clsDAL.ProcessSQL(strSQL, "HRL");

                if (clsDAL.dsHasData(ds))
                {
                    DataTable dt = ds.Tables[0];
                    dy = dt.AsEnumerable()
                         .ToDictionary <DataRow, int, string>(row => row.Field <int>(0),
                                                              row => row.Field <string>(1));
                }

                else
                {
                    HRLEntities db = clsStart.efdb();
                    var         q  = db.p_DropDown(intAPPID, intNAVID, strCol, "", intASID);

                    var qry = (from ct in q
                               select ct).ToList();
                    dy = qry.ToDictionary(x => x.ID, x => x.Display);
                }
            }
            catch (Exception ex)
            {
            }

            return(dy);
        }
Example #5
0
        public static HRLEntities efdbReadOnly()
        {
            HRLEntities tmp = new HRLEntities();

            tmp.Database.Connection.ConnectionString   = clsDAL.GetCon("HRL");
            tmp.Configuration.AutoDetectChangesEnabled = false;
            return(tmp);
        }
        //保证一次请求,返回一个实例
        public DbContext GetCurrentContextInstence()
        {
            DbContext dbContext = (DbContext)CallContext.GetData(typeof(EFContextFactory).FullName);

            if (dbContext == null)
            {
                dbContext = new HRLEntities();
                CallContext.SetData(typeof(EFContextFactory).FullName, dbContext);
            }
            return(dbContext);
        }
Example #7
0
        public static void SaveFormSettings(int intASID, int intNAVID, string strForm, int intWidth, int intHeight)
        {
            HRLEntities db = clsStart.efdb();

            try
            {
                db.p_tblAppNavigationUser_Add(intNAVID, intASID, strForm, intHeight, intWidth);
            }
            catch (Exception ex)
            {
            }
        }
Example #8
0
        public static void DropDownTBL(Int32 intAPPID, Int32 intNAVID, string strCol, string strCriteria, int intASID, ComboBox ddl, string strBlank)
        {
            var dy = new Dictionary <int, string>();

            try
            {
                string strSQL = "p_DropDown_TBL " + intAPPID.ToString() + ", " + intNAVID.ToString() + ", " + strCol + ", '" + strCriteria + "', " + intASID.ToString();

                DataSet ds = clsDAL.ProcessSQL(strSQL, "HRL");

                if (clsDAL.dsHasData(ds))
                {
                    DataTable dt = ds.Tables[0];
                    dy = dt.AsEnumerable()
                         .ToDictionary <DataRow, int, string>(row => row.Field <int>(0),
                                                              row => row.Field <string>(1));
                }

                else
                {
                    HRLEntities db = clsStart.efdb();
                    var         q  = db.p_DropDown(intAPPID, intNAVID, strCol, "", intASID);

                    var qry = (from ct in q
                               select ct).ToList();
                    dy = qry.ToDictionary(x => x.ID, x => x.Display);
                }

                if (strBlank + "" != "")
                {
                    dy = (new Dictionary <int, string> {
                        { 0, strBlank }
                    }).Concat(dy).ToDictionary(k => k.Key, v => v.Value);
                }

                ddl.DataSource    = new BindingSource(dy.ToList(), null);
                ddl.DisplayMember = "Value";
                ddl.ValueMember   = "Key";
            }
            catch (Exception ex)
            {
            }
        }
Example #9
0
        public void Outlook(int intBut)
        {
            this.lstIcons.Clear();
            this.Cursor = Cursors.WaitCursor;

            HRLEntities db = clsStart.efdb();


            //select from previosly saved query
            var query = from nav in dsIcon
                        where nav.BTID == intBut
                        orderby nav.NAV_Order
                        select nav;


            try
            {
                Int32 i = 0;
                foreach (var r in query)
                {
                    this.lstIcons.Items.Add(r.NAV_Desc);
                    this.lstIcons.Items[i].ImageIndex = r.NAV_Image;
                    this.lstIcons.Items[i].Name       = r.NAVID.ToString();

                    i = i + 1;
                }
            }
            catch (System.ArgumentOutOfRangeException exc)
            {
                Debug.WriteLine("Out of range" + exc.Message);
            }
            if (this.lstIcons.Items.Count > 9)
            {
                this.pnlButtons.Width = 115;
            }
            else
            {
                this.pnlButtons.Width = 88;
            }
            this.Cursor = Cursors.Arrow;
        }
Example #10
0
        public static void DropDownTBL(clsForm frm, TypeAhead txt, Int32 intAPPID, Int32 intNAVID, string strCol, string strCriteria, int intASID, string strDefault, int intVal)
        {
            var dy = new Dictionary <int, string>();

            try
            {
                string strSQL = "p_DropDown_TBL " + intAPPID.ToString() + ", " + intNAVID.ToString() + ", " + strCol + ", '" + strCriteria + "', " + intASID.ToString();

                DataSet ds = clsDAL.ProcessSQL(strSQL, "HRL");

                if (clsDAL.dsHasData(ds))
                {
                    DataTable dt = ds.Tables[0];
                    dy = dt.AsEnumerable()
                         .ToDictionary <DataRow, int, string>(row => row.Field <int>(0),
                                                              row => row.Field <string>(1));
                }

                else
                {
                    HRLEntities db = clsStart.efdb();

                    string strDebug = "p_DropDown " + intAPPID.ToString() + ", " + intNAVID.ToString() + ", " + strCol + ", '', " + intASID.ToString();

                    Debug.Print(strDebug);

                    var q = db.p_DropDown(intAPPID, intNAVID, strCol, "", intASID);

                    var qry = (from ct in q
                               select ct).ToList();
                    dy = qry.ToDictionary(x => x.ID, x => x.Display);
                }

                if (strDefault + "" != "")
                {
                    dy = (new Dictionary <int, string> {
                        { 0, strDefault }
                    }).Concat(dy).ToDictionary(k => k.Key, v => v.Value);
                }


                txt.ParentForm  = frm;
                txt.DefaultText = strDefault;
                txt.Text        = strDefault;
                txt.DataSource  = dy;
                txt.lstWidth    = txt.Width;             // * intVal;
                if (intVal > 0)
                {
                    txt.SelectedValue = intVal;
                    try
                    {
                        var q = (from ct in txt.DataSource
                                 where ct.Key == intVal
                                 select ct).First();

                        txt.Text = q.Value.ToString();
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Example #11
0
        public static void PostMain(Int32 intAPPID, Int32 intLNID, string strUser, int intTSID)
        {
            string          strVer     = "";
            string          strAppBeta = "";
            string          strDEV     = clsUtility.ConfigVal("DEV");
            HRLEntities     db         = efdb();
            RexrothEntities dbRexroth  = efdbRexroth();



            try
            {
                System.Security.Principal.WindowsPrincipal s = new System.Security.Principal.WindowsPrincipal(System.Security.Principal.WindowsIdentity.GetCurrent());

                if (strUser == "")
                {
                    strUser = s.Identity.Name;
                    strUser = strUser.Substring(strUser.IndexOf("\\") + 1);
                }

                //var list = db.tblBISystemUID.Where(w => w.BSU_Active == true && w.BSU_Deleted.HasValue == false).ToList();
                //var systemUIDs = list.Select(uid => uid.BSU_UID).ToList();



                if (strDEV == "1")
                {
                    string strDevUser = clsUtility.ConfigVal("UID");

                    if (strDevUser + "" != "")
                    {
                        strUser = strDevUser;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Credo");
            }

            try
            {
                //Verify the version
                var qryApp = (from ap in db.tblApp
                              where ap.APPID == intAPPID
                              select ap).FirstOrDefault();


                strVer = qryApp.APP_Version;

                Assembly        assembly = Assembly.GetExecutingAssembly();
                FileVersionInfo fvi      = FileVersionInfo.GetVersionInfo(assembly.Location);

                string strVer2 = fvi.FileVersion.ToString().Substring(0, strVer.Length).Trim();


                if (Debugger.IsAttached == false)
                {
                    if (strVer != strVer2)
                    {
                        MessageBox.Show("This App is version " + strVer2 + ", should be " + strVer + ". Be certain you are using the correct shortcut and re-open.", "Credo");
                        return;
                    }
                }


                intAPPID = Convert.ToInt16(qryApp.APP_BetaFor);

                if (intAPPID == 22 || intAPPID == 24)
                {
                    var appUserBIList = (from ap in db.vwAppView2
                                         where ap.APPID == 22 && ap.AB_Level == 2
                                         select ap.AS_User).ToList();

                    var appUserBIAdminList = (from ap in db.vwAppView2
                                              where ap.APPID == 22 && ap.AB_Level > 2
                                              select ap.AS_User).ToList();

                    var removeList = new List <string>();

                    foreach (var user in appUserBIList)
                    {
                        if (appUserBIAdminList.Contains(user))
                        {
                            removeList.Add(user);
                        }
                    }

                    foreach (var user in removeList)
                    {
                        appUserBIList.Remove(user);
                    }
                }



                frmNavigate f     = new frmNavigate();
                Boolean     fOpen = false;

                //if navidation is already open, then close
                try
                {
                    frmNavigate frm = clsFormUtil.ReturnFormInst("frmNavigate");
                    if (frm.Name == "frmNavigate")
                    {
                        f     = frm;
                        fOpen = true;
                    }
                }
                catch (Exception ex)
                {
                }


                f.WindowState = FormWindowState.Maximized;
                f.Text        = qryApp.APP_Desc + "  Version " + strVer2;
                f.Token       = strUser + "_" + DateTime.Now.ToLongTimeString();
                f.Parm1       = qryApp.APP_Color;
                f.AppName     = qryApp.APP_Desc;
                f.LNID        = intLNID;
                f.TSID        = intTSID;
                f.Image       = Convert.ToInt32(qryApp.APP_Image);
                try
                {
                    vwAssociate qry = (from ct in db.vwAssociate
                                       where ct.AS_User == strUser &&
                                       ct.APPID == intAPPID
                                       orderby ct.AB_Level descending
                                       select ct).First();
                    f.Associate = qry;

                    //clsMail.SendPBRoleAssign(1901, 0, qry, true);
                }
                catch (Exception ex)
                {
                    //get default user
                    vwAssociate qry = (from ct in db.vwAssociate
                                       where ct.ASID == 1 &&
                                       ct.APPID == intAPPID
                                       orderby ct.AB_Level descending
                                       select ct).First();

                    try
                    {
                        //supplement the default user with this users info...
                        var qry2 = (from ct in dbRexroth.tblAssociate
                                    where ct.AS_User == strUser
                                    select ct).First();

                        qry.ASID     = qry2.ASID;
                        qry.AS_Email = qry2.AS_Email;
                        qry.AS_First = qry2.AS_First;
                        qry.AS_Last  = qry2.AS_Last;
                        qry.AS_User  = qry2.AS_User;
                        qry.FullName = qry2.AS_Display;
                    }
                    catch (Exception ex2)
                    {
                    }



                    f.Associate = qry;
                    //}
                }
                //try
                //{
                //    var qry5 = (from ct in dbRexroth.tblAssociate
                //                where ct.AS_User == strUser
                //                select ct).First();
                //    f.RexAssoc = qry5;
                //}
                //catch (Exception ex4)
                //{
                //    //throw ex4;
                //}

                f.APPID = intAPPID;

                if (fOpen == false)
                {
                    Application.Run(f);
                }
                else
                {
                    f.SetButtons();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Credo");
            }
        }