Пример #1
0
        public static void DropDown(DataGridView gv, Int32 intNAVID, tblAppColumns tbl, RexrothData.RexrothEntities db, Int32 intApp, Int32 intAPPID, Int32 intASID)
        {
            DataGridViewComboBoxColumnCredo gvCbo = new DataGridViewComboBoxColumnCredo();

            switch (tbl.APCOID)
            {
                //case 2:

                //    var qry = new Dictionary<int, string>();

                //    try
                //    {
                //        var q = db.p_DropDown(intNAVID, tbl.APC_Desc, "", intASID).ToList();
                //        qry = q.ToDictionary(pl => pl.ID, pl => pl.Display);
                //    }
                //    catch (Exception ex)
                //    {

                //    }
                //    if (qry.Count > 0)
                //    {
                //        gvCbo.DataSource = qry.ToList();
                //    }

                //    break;

                //case 21:

                //    var qry2 = new Dictionary<string, string>();

                //    try
                //    {
                //        List<p_DropDownFilter_Result> q = db.p_DropDownFilter(intNAVID, tbl.APC_Desc, "", tbl.APC_QueryField, intASID).ToList<p_DropDownFilter_Result>();
                //        qry2 = q.ToDictionary(pl => pl.ID, pl => pl.Display);
                //    }
                //    catch (Exception ex)
                //    {

                //    }

                //    if (qry2.Count > 0)
                //    {
                //        gvCbo.DataSource = qry2.ToList();
                //    }

                //    break;

                //case 25:

                //    var qry25 = new Dictionary<string, string>();

                //    try
                //    {
                //        List<p_DropDownFilter_Result> q = db.p_DropDownFilter(intNAVID, tbl.APC_Desc, "", tbl.APC_QueryField, intASID).ToList<p_DropDownFilter_Result>();
                //        qry25 = q.ToDictionary(pl => pl.ID, pl => pl.Display);
                //    }
                //    catch (Exception ex)
                //    {

                //    }

                //    if (qry25.Count > 0)
                //    {
                //        gvCbo.DataSource = qry25.ToList();
                //    }

                //    break;
            }
            string strName = tbl.APC_Desc;

            gvCbo.DisplayMember          = "Value";
            gvCbo.ValueMember            = "Key";
            gvCbo.FlatStyle              = FlatStyle.Flat;
            gvCbo.Name                   = tbl.APC_Desc;
            gvCbo.HeaderText             = tbl.APC_Name;
            gvCbo.DataPropertyFilterName = tbl.APC_QueryField;
            gvCbo.DataPropertyName       = strName;

            gvCbo.Tag      = tbl.APCID.ToString();
            gvCbo.ReadOnly = Convert.ToBoolean(tbl.APC_ReadOnly);

            if (tbl.APC_Width == 0)
            {
                gvCbo.Visible = false;
            }
            else
            {
                gvCbo.Width = tbl.APC_Width;
            }

            gvCbo.AutoComplete = true;
            gv.Columns.Add(gvCbo);
        }
Пример #2
0
        public static void DropDown(DataGridView gv, Int32 intNAVID, tblAppColumns tbl, HRLData.HRLEntities db, Int32 intApp, Int32 intAPPID, Int32 intASID, Boolean fShowArrow)
        {
            DataGridViewComboBoxColumnCredo gvCbo = new DataGridViewComboBoxColumnCredo();

            switch (tbl.APCOID)
            {
            case 2:

                var qry = new Dictionary <int, string>();

                try
                {
                    List <p_DropDown_Result> q = db.p_DropDown(intAPPID, intNAVID, tbl.APC_Desc, "", intASID).ToList <p_DropDown_Result>();
                    qry = q.ToDictionary(pl => pl.ID, pl => pl.Display);
                }
                catch (Exception ex)
                {
                }
                if (qry.Count > 0)
                {
                    gvCbo.DataSource = qry.ToList();
                }

                break;

            case 21:

                var qry2 = new Dictionary <string, string>();

                try
                {
                    List <p_DropDownFilter_Result> q = db.p_DropDownFilter(intNAVID, tbl.APC_Desc, "", tbl.APC_QueryField, intASID).ToList <p_DropDownFilter_Result>();
                    qry2 = q.ToDictionary(pl => pl.ID, pl => pl.Display);
                }
                catch (Exception ex)
                {
                }

                if (qry2.Count > 0)
                {
                    gvCbo.DataSource = qry2.ToList();
                }

                break;

            case 25:

                var qry25 = new Dictionary <string, string>();

                try
                {
                    string strSQL = "p_DropDownFilter " + intNAVID.ToString() + ", '" + tbl.APC_Desc + "', '','" + tbl.APC_QueryField + "', " + intASID.ToString();

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

                    //var q = (from myRow in ds.Tables[0].AsEnumerable()
                    //               select new {ID = myRow.Field<Int32>("ID"), Display = myRow.Field<string>("Display")}).ToList();

                    var q = (from myRow in ds.Tables[0].AsEnumerable()
                             select new { ID = myRow.Field <string>("ID"), Display = myRow.Field <string>("Display") }).ToList();


                    qry25 = q.ToDictionary(pl => pl.ID.ToString(), pl => pl.Display);
                }
                catch (Exception ex)
                {
                }

                if (qry25.Count > 0)
                {
                    gvCbo.DataSource = qry25.ToList();
                }

                break;

            case 28:

                var qry28 = new Dictionary <int, string>();

                try
                {
                    qry28 = DropDownTBL(intAPPID, intNAVID, tbl.APC_Desc, "", intASID);

                    //List<p_DropDown_Result> q = db.p_DropDown(intAPPID, intNAVID, tbl.APC_Desc, "", intASID).ToList<p_DropDown_Result>();
                    //qry28 = q.ToDictionary(pl => pl.ID, pl => pl.Display);
                }
                catch (Exception ex)
                {
                }
                if (qry28.Count > 0)
                {
                    gvCbo.DataSource = qry28.ToList();
                }

                break;

            case 31:

                var qry31 = new Dictionary <int, string>();

                try
                {
                    List <p_DropDown_Result> q31 = db.p_DropDown(intAPPID, intNAVID, tbl.APC_Desc, "", intASID).ToList <p_DropDown_Result>();
                    try
                    {
                        q31 = clsDropDownUtil.AddDropItem(q31, "-");
                    }
                    catch (Exception ex2)
                    {
                    }

                    qry31 = q31.ToDictionary(pl => pl.ID, pl => pl.Display);
                }
                catch (Exception ex)
                {
                }
                if (qry31.Count > 0)
                {
                    gvCbo.DataSource = qry31.ToList();
                }

                break;

            case 37:

                var qry37 = new Dictionary <int, string>();

                try
                {
                    List <p_DropDown_Result> q = db.p_DropDown(intAPPID, intNAVID, tbl.APC_Desc, "", intASID).ToList <p_DropDown_Result>();
                    qry37 = q.ToDictionary(pl => pl.ID, pl => pl.Display);
                }
                catch (Exception ex)
                {
                }
                if (qry37.Count > 0)
                {
                    gvCbo.DataSource = qry37.ToList();
                }

                break;
            }
            string strName = tbl.APC_Desc;

            gvCbo.DisplayMember          = "Value";
            gvCbo.ValueMember            = "Key";
            gvCbo.FlatStyle              = FlatStyle.Flat;
            gvCbo.Name                   = tbl.APC_Desc;
            gvCbo.HeaderText             = tbl.APC_Name;
            gvCbo.DataPropertyFilterName = tbl.APC_QueryField;
            gvCbo.DataPropertyName       = strName;

            gvCbo.Tag      = tbl.APCID.ToString();
            gvCbo.ReadOnly = Convert.ToBoolean(tbl.APC_ReadOnly);

            if (fShowArrow == false)
            {
                gvCbo.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
            }

            if (tbl.APC_Width == 0)
            {
                gvCbo.Visible = false;
            }
            else
            {
                gvCbo.Width = tbl.APC_Width;
            }

            gvCbo.SortMode     = DataGridViewColumnSortMode.Automatic;
            gvCbo.AutoComplete = true;
            gv.Columns.Add(gvCbo);
        }