Exemple #1
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                int hash = 41;

                // Suitable nullity checks
                hash = hash * 59 + Id.GetHashCode();

                if (OldTable != null)
                {
                    hash = hash * 59 + OldTable.GetHashCode();
                }

                if (NewTable != null)
                {
                    hash = hash * 59 + NewTable.GetHashCode();
                }

                if (OldKey != null)
                {
                    hash = hash * 59 + OldKey.GetHashCode();
                }

                hash = hash * 59 + NewKey.GetHashCode();

                return(hash);
            }
        }
Exemple #2
0
        public static void Task2()
        {
            var query = db.NewEquipment
                        .Join(db.TableEquipmentHistory, i => i.IntEquipmentID, h => h.IntEquipmentID, (i, h) =>
                              new {
                i.IntGarageRoom,
                i.StrSerialNo,
                h.IntTypeHistory,
                h.DStartDate,
                h.DEndDate,
                h.IntDaysCount,
            }).ToList();

            List <NewTable> newtables = new List <NewTable>();

            foreach (var item in query)
            {
                NewTable tab = new NewTable()
                {
                    IntGarageRoom  = item.IntGarageRoom,
                    StrSerialNo    = item.StrSerialNo,
                    IntTypeHistory = item.IntTypeHistory,
                    DStartDate     = item.DStartDate,
                    DEndDate       = item.DEndDate,
                    IntDaysCount   = item.IntDaysCount,
                };
                newtables.Add(tab);
            }
        }
Exemple #3
0
        static void Task2()
        {
            //Пункт 3
            //Из результатов пункта 2, создать таблицу в БД, и результаты первой выборки загрузить во вновь созданную таблицу

            string sqlCmd = "CREATE TABLE NewTable " +
                            "(TableTask2Id INT NOT NULL PRIMARY KEY IDENTITY(1,1)," +
                            "intGarageRoom NVARCHAR(20)," +
                            "strSerialNo NVARCHAR(20)," +
                            "intTypeHistory INT," +
                            "dStartDate DATETIME," +
                            "dEndDate DATETIME," +
                            "intDaysCount INT," +
                            "intStatys INT)";

            db.ExecuteCommand(sqlCmd);
            db.SubmitChanges();

            var data = db.GetTable <TableEquipmentHistory>()
                       .Join(db.GetTable <newEquipment>(),
                             teh => teh.intEquipmentID,
                             ne => ne.intEquipmentID,
                             (teh, ne) => new
            {
                intGarageRoom  = ne.intGarageRoom,
                strSerialNo    = ne.strSerialNo,
                intTypeHistory = teh.intTypeHistory,
                dStartDate     = teh.dStartDate,
                dEndDate       = teh.dEndDate,
                intDaysCount   = teh.intDaysCount,
                intStatys      = teh.intStatys
            });

            List <NewTable> ntList = new List <NewTable>();

            foreach (var item in data.ToList())
            {
                NewTable nt = new NewTable();

                nt.intGarageRoom  = item.intGarageRoom;
                nt.strSerialNo    = item.strSerialNo;
                nt.intTypeHistory = item.intTypeHistory;
                nt.dStartDate     = item.dStartDate;
                nt.dEndDate       = item.dEndDate;
                nt.intDaysCount   = item.intDaysCount;
                nt.intStatys      = item.intStatys;

                ntList.Add(nt);
            }

            db.GetTable <NewTable>().InsertAllOnSubmit(ntList);
            db.SubmitChanges();
            Console.WriteLine("Операция прошла успешно!");

            //Возможно есть более оптимальный вариант, но это то, что у меня получилось)
        }
Exemple #4
0
 private void tableToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (Usermanager.Connection.CurrentUser.Database != null)
     {
         var form = new NewTable(tool, Usermanager);
         form.Show();
     }
     else
     {
         MessageBox.Show("You must Login to a Database", "Error!", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
 }
Exemple #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            NewTable new1 = new NewTable
            {
                Id     = Guid.NewGuid().ToString(),
                Name   = "sanmao",
                Age    = 23,
                Gender = 1,
                Hight  = 157,
                Weight = 50,
                Time   = DateTime.Now
            };

            TestModel.AddItem(new1);
            //   TestModel.DeleteItem(typeof(NewTable), "1");
        }
Exemple #6
0
        public NewBaseControl CreateControl(String controlType, Point position)
        {
            NewBaseControl control = null;

            switch (controlType)
            {
            case "Text":
                control = new NewText();
                break;

            case "ActiveText":
                control = new NewActiveText();
                break;

            case "Image":
                control = new NewImage();
                break;

            case "ActiveImage":
                control = new NewActiveImage();
                break;

            case "BackGroundImage":
                control = new NewBackGroundImage();
                break;

            case "Line":
                control = new NewLine();
                break;

            case "Table":
                control = new NewTable();
                break;
            }
            control.ControlNum      = Config.ElementNodeStartNum;
            control.ControlType     = controlType;
            control.ControlPosition = position;
            control.Create();

            return(control);
        }
Exemple #7
0
        /// <summary>
        /// Returns true if ImportMap instances are equal
        /// </summary>
        /// <param name="other">Instance of ImportMap to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ImportMap other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id.Equals(other.Id)
                     ) &&
                 (
                     OldTable == other.OldTable ||
                     OldTable != null &&
                     OldTable.Equals(other.OldTable)
                 ) &&
                 (
                     NewTable == other.NewTable ||
                     NewTable != null &&
                     NewTable.Equals(other.NewTable)
                 ) &&
                 (
                     OldKey == other.OldKey ||
                     OldKey != null &&
                     OldKey.Equals(other.OldKey)
                 ) &&
                 (
                     NewKey == other.NewKey ||
                     NewKey.Equals(other.NewKey)
                 ));
        }
Exemple #8
0
        public static void Task2AndTask3()
        {
            //2.Используя класс DataContext произвести
            //    выборку данных из таблицы TableEquipmentHistory
            //    и newEquipment используя при этом join выгрузить
            //    следующие данные: intGarageRoom, strSerialNo,
            //intTypeHistory, dStartDate, dEndDate, intDaysCount, intStatys

            Table <TableEquipmentHistory> tabEqHis = db.GetTable <TableEquipmentHistory>();
            Table <newEquipment>          newEq    = db.GetTable <newEquipment>();

            var jtabs = from a in tabEqHis
                        join b in newEq on a.intEquipmentID equals b.intEquipmentID
                        select new
            {
                a.intEquipmentID,
                b.intGarageRoom,
                b.strSerialNo,
                a.intTypeHistory,
                a.dStartDate,
                a.dEndDate,
                a.intDaysCount,
                a.intStatys
            };

            foreach (var item in jtabs)
            {
                Console.WriteLine("EquipmentID - " + item.intEquipmentID);
                Console.WriteLine("GarageRoom - " + item.intGarageRoom);
                Console.WriteLine("SerialNo - " + item.strSerialNo);
                Console.WriteLine("TypeHistory - " + item.intTypeHistory);
                Console.WriteLine("StartDate - " + item.dStartDate);
                Console.WriteLine("EndDate - " + item.dEndDate);
                Console.WriteLine("DaysCount - " + item.intDaysCount);
                Console.WriteLine("Statys - " + item.intStatys);
                Console.WriteLine("****************************************");
                Console.WriteLine();
            }

            //3.Из результатов пункта 2, создать таблицу в БД,
            //и результаты первой выборки загрузить во вновь созданную таблицу

            db.ExecuteCommand(" IF not EXISTS(SELECT * FROM sys.tables WHERE name = 'NewTable') begin create table NewTable (NewTableId int primary key identity(1,1)," +
                              "EquipmentID int, GarageRoom nvarchar(100),SerialNo nvarchar(100)," +
                              "TypeHistory int, StartDate date, EndDate date, DaysCount int, Statys int) end");

            List <NewTable> newTab = new List <NewTable>();

            foreach (var item in jtabs)
            {
                NewTable tab = new NewTable();
                tab.DaysCount   = item.intDaysCount;
                tab.EndDate     = item.dEndDate;
                tab.EquipmentID = item.intEquipmentID;
                tab.GarageRoom  = item.intGarageRoom;
                tab.SerialNo    = item.strSerialNo;
                tab.StartDate   = item.dStartDate;
                tab.Statys      = item.intStatys;
                tab.TypeHistory = item.intTypeHistory;
                newTab.Add(tab);
            }

            Table <NewTable> nt = db.GetTable <NewTable>();

            try
            {
                nt.InsertAllOnSubmit(newTab);
                db.SubmitChanges();
                Console.WriteLine("Данные сохранены в таблицу");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }