コード例 #1
0
        public void AddTabelToDB(string path)
        {
            Deserialization          ds  = new Deserialization();
            List <IncomingDataTable> odd = ds.GetOneTabelData(path, out string tablename);

            for (int i = 0; i < odd.Count; i++)
            {
                CheckExistingRowInTable(odd[i].tabelNumber, odd[i].daynumber.Year, odd[i].daynumber.Month, odd[i].daynumber.Day);
                List <string> znachenies = new List <string>();
                znachenies.Add(odd[i].daynumber.Day.ToString());
                znachenies.Add(odd[i].daynumber.Month.ToString());
                znachenies.Add(odd[i].daynumber.Year.ToString());
                znachenies.Add(odd[i].startday.Hour.ToString());
                znachenies.Add(odd[i].startday.Minute.ToString());
                znachenies.Add(odd[i].endday.Hour.ToString());
                znachenies.Add(odd[i].endday.Minute.ToString());
                znachenies.Add(odd[i].city);
                znachenies.Add(odd[i].specCheck);
                znachenies.Add(odd[i].achiv);
                if (CheckExistingRowInTable(odd[i].tabelNumber, odd[i].daynumber.Year, odd[i].daynumber.Month, odd[i].daynumber.Day))
                {
                    UpdateRow(odd[i].tabelNumber, paramForUsersTable, znachenies);
                }
                else
                {
                    AddRowToTable(odd[i].tabelNumber, paramForUsersTable, znachenies);
                }
            }
        }
コード例 #2
0
        public List <IncomingDataTable> CompareFileTabelWithDatabase(string path, out Employee employee, out bool createNewEmployee)
        {
            Deserialization          ds             = new Deserialization();
            List <IncomingDataTable> odd            = ds.GetOneTabelData(path, out string tablename);
            List <IncomingDataTable> oddRowToUpdate = new List <IncomingDataTable>();

            if (CheckExistingTable(tablename))
            {
                for (int i = 0; i < odd.Count; i++)
                {
                    CheckExistingRowInTable(odd[i].tabelNumber, odd[i].daynumber.Year, odd[i].daynumber.Month, odd[i].daynumber.Day);
                    List <string> znachenies = new List <string>();
                    znachenies.Add(odd[i].daynumber.Day.ToString());
                    znachenies.Add(odd[i].daynumber.Month.ToString());
                    znachenies.Add(odd[i].daynumber.Year.ToString());
                    znachenies.Add(odd[i].startday.Hour.ToString());
                    znachenies.Add(odd[i].startday.Minute.ToString());
                    znachenies.Add(odd[i].endday.Hour.ToString());
                    znachenies.Add(odd[i].endday.Minute.ToString());
                    znachenies.Add(odd[i].city);
                    znachenies.Add(odd[i].specCheck);
                    znachenies.Add(odd[i].achiv);
                    if (CheckExistingRowInTable(odd[i].tabelNumber, odd[i].daynumber.Year, odd[i].daynumber.Month, odd[i].daynumber.Day))
                    {
                        //odd[i].overlap= CheckExistingRowInTableAndContent(odd[i].tabelNumber, odd[i].daynumber.Year, odd[i].daynumber.Month, odd[i].daynumber.Day
                        //     , odd[i].startday.Hour, odd[i].startday.Minute, odd[i].endday.Hour, odd[i].endday.Minute, odd[i].city, odd[i].specCheck, odd[i].achiv);
                        oddRowToUpdate.Add(odd[i]);
                        // UpdateRow(odd[i].tabelNumber, paramForUsersTable, znachenies);
                    }
                    else
                    {
                        AddRowToTable(odd[i].tabelNumber, paramForUsersTable, znachenies);
                    }
                }
                employee = new Employee()
                {
                };
                createNewEmployee = false;

                return(oddRowToUpdate);
            }
            else
            {
                if (odd.Count > 0)
                {
                    employee = new Employee()
                    {
                        TabelNumber = tablename,
                        Name        = odd[0].name,
                        Surname     = odd[0].family,
                        Patronymic  = odd[0].parentName
                    };
                    Model.Loger.SetLog("Работника с табельным номером: " + tablename + " не обнаружено!" + " Файл " + path + " не был добавлен.", true);
                    createNewEmployee = true;
                    return(oddRowToUpdate);
                }
                ;
                createNewEmployee = false;
                employee          = new Employee()
                {
                };
                return(oddRowToUpdate);
                //Create_DataBase_Table(tablename, paramForUsersTable, typeOfDataForTabelUsersTable);
                //List<string> znachenie = new List<string>() { tablename, odd[0].family, odd[0].name, odd[0].parentName, odd[0].mail};
                //AddRowToTable(NameOfTablenamberUserTable, paramForTabelNamberUserTable, znachenie);
            }
        }