Beispiel #1
0
        private void SetTypeAhead(string strID, TypeAhead txt, string strDefault, Int32 intVal)
        {
            List <HRLData.p_DropDown_Result> q2 = db
                                                  .p_DropDown(this.APPID, this.tblNav.NAVID, strID, this.Parm1, this.RexAssoc.ASID)
                                                  .ToList <HRLData.p_DropDown_Result>();

            txt.ParentForm  = this;
            txt.DefaultText = strDefault;
            txt.DataSource  = q2.ToDictionary(pl => pl.ID, pl => pl.Display);
            txt.lstWidth    = txt.Width;
            if (intVal > 0)
            {
                txt.SelectedValue = Convert.ToInt32(intVal);
                try
                {
                    var q = (from ct in txt.DataSource
                             where ct.Key == intVal
                             select ct).First();

                    txt.Text = q.Value.ToString();
                }
                catch (Exception ex)
                {
                }
            }
            else
            {
                txt.Text = strDefault;
            }
        }
Beispiel #2
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)
            {
            }
        }