コード例 #1
0
ファイル: CodeFrm.cs プロジェクト: EgyFalseX/Winform
        public CodeFrm(TablesNames CodeName)
        {
            //cDSyndicateTableAdapter.Connection.ConnectionString = SqlDB.SqlConStr;
            //cDEDARETTableAdapter.Connection.ConnectionString = SqlDB.SqlConStr;
            //cDModereaTableAdapter.Connection.ConnectionString = SqlDB.SqlConStr;

            InitializeComponent();
            ViewName = CodeName;
            switch (CodeName)
            {
                case TablesNames.CDSyndicate:
                    gridControlCode.MainView = gridViewCDSyndicate;
                    cDSyndicateTableAdapter.Fill(dSFellowship.CDSyndicate);
                    gridControlCode.DataSource = cDSyndicateBindingSource;
                    Text += " النقابات الفرعية";
                    break;
                case TablesNames.CDEDARET:
                    cDModereaTableAdapter.Fill(dSFellowship.CDModerea);
                    cDSyndicateTableAdapter.Fill(dSFellowship.CDSyndicate);

                    gridControlCode.MainView = gridViewCDEDARET;
                    cDEDARETTableAdapter.Fill(dSFellowship.CDEDARET);
                    gridControlCode.DataSource = cDEDARETBindingSource;
                    Text += " الادارات";
                    break;
                case TablesNames.CDModerea:
                    gridControlCode.MainView = gridViewCDModerea;
                    cDModereaTableAdapter.Fill(dSFellowship.CDModerea);
                    gridControlCode.DataSource = cDModereaBindingSource;
                    Text += " المديريات";
                    break;
                case TablesNames.CDState:
                    gridControlCode.MainView = gridViewCDState;
                    cDStateTableAdapter.Fill(dSFellowship.CDState);
                    gridControlCode.DataSource = cDStateBindingSource;
                    Text += " الانواع";
                    break;
                case TablesNames.CDJob:
                    gridControlCode.MainView = gridViewCDJob;
                    cDJobTableAdapter.Fill(dSFellowship.CDJob);
                    gridControlCode.DataSource = cDJobBindingSource;
                    Text += " الوظائف";
                    break;
                case TablesNames.CDAttach:
                    gridControlCode.MainView = gridViewCDAttach;
                    cDAttachTableAdapter.Fill(dSFellowship.CDAttach);
                    gridControlCode.DataSource = cDAttachBindingSource;
                    Text += " المرفقات";
                    break;
                default:
                    break;
            }
            ((GridView)gridControlCode.MainView).BestFitColumns();
        }
コード例 #2
0
        public Dictionary<string, string> Read(Guid Id, TablesNames tableName)
        {
            TableInform table;
            DbConnection connection;
            DataRow result;

            connection = TableInform.Connection;
            table = new TableInform(tableName.ToString());

            DataRow dr = table.Table.AsEnumerable().SingleOrDefault(r => r.Field<Guid>("ID") == Id);
            var dict = table.ConvertRowToDict(dr);
            return dict;
        }
コード例 #3
0
        public void Insert(Dictionary<string, string> dictionary, TablesNames tableName)
        {
            TableInform table;
            DbConnection connection;
            DataRow result;

            table = new TableInform(tableName.ToString());
            connection = TableInform.Connection;
            result = table.ConvertDictToRow(dictionary);

            table.Table.Rows.Add(result);
            table.Update(new DataRow[] { result });
        }
コード例 #4
0
        public void Delete(Dictionary<string, string> dictionary, TablesNames tableName)
        {
            TableInform table;
            DbConnection connection;
            DataRow row;
            string IdValue;

            IdValue = null;
            table = new TableInform(tableName.ToString());
            table.Table.PrimaryKey = new DataColumn[] { table.Table.Columns["Id"] };
            connection = TableInform.Connection;

            if (dictionary.TryGetValue("Id", out IdValue))
            {
                row = table.Table.Rows.Find(IdValue);
                row.Delete();
                table.Update(new DataRow[] { row });
            }
        }
コード例 #5
0
ファイル: DBManager.cs プロジェクト: Smi1le/Library
        public int GetIdElement(TablesNames tb, string con)
        {
            switch (tb)
            {
            case TablesNames.Books:
                return(context.Lib.First(s => s.Book_title == con).Id);

            case TablesNames.BuyOrders:
                return(context.BuyOrders.First(s => s.Id_book == GetIdElement(TablesNames.Books, con)).Id);

            case TablesNames.Employees:
                return(context.Employees.First(s => s.FIO == con).Id);

            case TablesNames.ReadOrders:
                return(context.ReadingOrders.First(s => s.Id_book == GetIdElement(TablesNames.Books, con)).Id);

            default:
                return(-1);
            }
        }
コード例 #6
0
        public void Update(Dictionary<string, string> dictionary, TablesNames tableName)
        {
            TableInform table;
            DbConnection connection;
            string IdValue;
            DataRow row;

            IdValue = null;
            table = new TableInform(tableName.ToString());
            connection = TableInform.Connection;
            table.Table.PrimaryKey = new DataColumn[] { table.Table.Columns["Id"] };

            if (dictionary.TryGetValue("Id", out IdValue))
            {
                row = table.Table.Rows.Find(IdValue);
                foreach (KeyValuePair<string, string> pair in dictionary)
                {
                    row[pair.Key] = pair.Value;
                }

                table.Update(new DataRow[] { row });
            }
        }
コード例 #7
0
        public List<Dictionary<string, string>> ReadAll(TablesNames tableName, Gender gender)
        {
            TableInform table;
            DbConnection connection;
            DataRow[] rows;
            List<Dictionary<string, string>> resultedList;

            connection = TableInform.Connection;
            resultedList = new List<Dictionary<string, string>>();
            table = new TableInform(tableName.ToString());

            if (gender == Gender.NotSpecified)
            {
                rows = table.Table.Select();
            }
            else
            {
                string param = String.Format("LEAGUE = '{0}'", gender.ToString());
                rows = table.Table.Select(param);
            }

            foreach (var row in rows)
            {
                var result = table.ConvertRowToDict(row);
                resultedList.Add(result);
            }
            return resultedList;
        }
コード例 #8
0
        public List<Dictionary<string, string>> FindSerchResults(string serchableName, TablesNames tableName, Gender gender)
        {
            TableInform table;
            DbConnection connection;
            List<Dictionary<string, string>> result;

            result = new List<Dictionary<string, string>>();
            connection = TableInform.Connection;
            table = new TableInform(tableName.ToString());

            var rowList = table.Table.AsEnumerable().Where(r => r.Field<string>("Name").Contains(serchableName.ToUpper())).ToList();

            if (rowList.Count > 0)
            {
                foreach (var row in rowList)
                {
                    if (row.Field<string>("League") == gender.ToString())
                    {
                        result.Add(table.ConvertRowToDict(row));
                    }
                }
                return result;
            }
            return null;
        }
コード例 #9
0
        private List<Dictionary<string, string>> ReadByIds(TablesNames tableName, List<Guid> idList)
        {
            TableInform table;
            List<Dictionary<string, string>> resultedList;

            resultedList = new List<Dictionary<string, string>>();
            table = new TableInform(tableName.ToString());

            if (idList.Count > 0)
            {
                foreach (var id in idList)
                {
                    var row = (from r in table.Table.AsEnumerable()
                               where r.Field<Guid>("Id") == id
                               select r).SingleOrDefault();

                    var result = table.ConvertRowToDict(row);
                    resultedList.Add(result);
                }
                return resultedList;
            }
            return null;
        }
コード例 #10
0
        private List<Guid> GetTeamsByGameId(TablesNames tableName, Guid gameId)
        {
            TableInform table;
            List<Guid> result;

            table = new TableInform(tableName.ToString());

            var res = (from r in table.Table.AsEnumerable()
                       where r.Field<Guid>("Id") == gameId
                       select r).SingleOrDefault();
            result = new List<Guid>();
            result.Add((Guid)res["TeamOneId"]);
            result.Add((Guid)res["TeamTwoId"]);

            return result;
        }
コード例 #11
0
        private List<Guid> GetPlayersByGameId(TablesNames tableName, Guid gameId)
        {
            TableInform table;

            table = new TableInform(tableName.ToString());

            var res = (from r in table.Table.AsEnumerable()
                       where r.Field<Guid>("GameId") == gameId
                       select r.Field<Guid>("PlayerId")).ToList();
            return res;
        }
コード例 #12
0
        private List<Guid> GetGamesByTeamId(TablesNames tableName, Guid teamId)
        {
            TableInform table;
            List<Dictionary<string, string>> resultedList;

            resultedList = new List<Dictionary<string, string>>();
            table = new TableInform(tableName.ToString());

            var res = (from r in table.Table.AsEnumerable()
                       where r.Field<Guid>("TeamOneId") == teamId || r.Field<Guid>("TeamTwoId") == teamId
                       select r.Field<Guid>("Id")).ToList();
            return res;
        }
コード例 #13
0
        private List<Guid> GetInfoByPlayerId(TablesNames tableName, Guid playerId)
        {
            TableInform table;

            table = new TableInform(tableName.ToString());
            string param = (tableName.ToString().Substring(8, 4) + "Id");

            var res = (from r in table.Table.AsEnumerable()
                       where r.Field<Guid>("PlayerId") == playerId
                       select r.Field<Guid>(param)).ToList();
            return res;
        }