public static void DataInForStudent(string[] arg)//добавление { Dek TB = DataLoadSave.LoadXML(FilePath); //var student = TB.Students.First(x => x.ID == ID); StudentsTable StudentBlok = new StudentsTable ( arg[1] != "" ? GetGroupeIDByGroupeName(TB, arg[1]) : -1, arg[2] != "" ? GetRoomIdByRoomNumber(TB, arg[2]) : -1, arg[3], arg[4], arg[5], arg[6], arg[7], arg[8], arg[9], arg[10] != null ? arg[10] : null ); //StudentBlok.ID = TB.StudID++; TB.Students.Add(StudentBlok); Save(TB); //StudentsInGroupeCount(); //StudentsInRoomCount(); }
public static void CreateIfEx() { if (!FileEx(FilePath)) { Dek TB = new Dek(); Save(TB); } }
public static string GetHostelNameByID(Dek TB, int ID) { foreach (var item in TB.HostelsN) { if (item.ID == ID) { return(item.Frame); } } return(""); }
public static int GetHostelIdByName(Dek TB, string NAME) { foreach (var item in TB.HostelsN) { if (item.Frame == NAME) { return(item.ID); } } return(-1); }
public static string GetRoomNumberByRoomID(Dek TB, int ID) { foreach (var item in TB.Roomes) { if (item.ID == ID) { return(item.RoomNumber); } } return(""); }
public static int GetRoomIdByRoomNumber(Dek TB, string RoomNumber) { foreach (var item in TB.Roomes) { if (item.RoomNumber == RoomNumber) { return(item.ID); } } return(-1); }
public static string GetGroupeNameByID(Dek TB, int ID) { foreach (var item in TB.Groupes) { if (item.ID == ID) { return(item.GroupeNumber); } } return(""); }
public static int GetGroupeIDByGroupeName(Dek TB, string GroupeName) { foreach (var item in TB.Groupes) { if (item.GroupeNumber == GroupeName) { return(item.ID); } } return(-1); }
public static string ReturnPicture(int ID) { Dek TB = DataLoadSave.LoadXML(FilePath); var student = TB.Students.First(x => x.ID == ID); if (student.ImagePath != "") { return(student.ImagePath); } return(null); }
public static void DataInForStudent(string[] arg, int ID)//редактирование за айдишником дата грида { Dek TB = DataLoadSave.LoadXML(); int i = GetTrueItemID(TB, ID, For.Student); StudentsTable StudentBlok = new StudentsTable ( arg[1] != "" ? GetGroupeIDByGroupeName(TB, arg[1]) : -1, arg[2] != "" ? GetRoomIdByRoomNumber(TB, arg[2]) : -1, arg[3], arg[4], arg[5], arg[6], arg[7], arg[8], arg[9], arg[10] != null ? arg[10] : null ); StudentBlok.ID = TB.Students[i].ID; TB.Students[i] = StudentBlok; Save(TB); //Dek TB; //if (FileEx(FilePath)) // TB = DataLoadSave.LoadXML(FilePath); //else TB = new Dek(); //int i = GetTrueItemID(TB, ID, For.Student); //StudentsTable StudentBlok = new StudentsTable //{ // GroupeID = arg[1] != "" ? GetGroupeIDByGroupeName(TB, arg[1]) : -1, // RoomID = arg[2] != "" ? GetRoomIdByRoomNumber(TB, arg[2]) : -1, // ThirdName_1 = arg[3], // Name_2 = arg[4], // SurnameName_3 = arg[5], // TicetNumber = arg[6], // FormStudy = arg[7], // ContractBudget = arg[8], // Description = arg[9], // Bin = arg[10] != null ? File.ReadAllBytes(arg[10]) : TB.Students[i].Bin //}; //StudentBlok.ID = TB.Students[i].ID; //TB.Students[i] = StudentBlok; //Save(TB); //StudentsInGroupeCount(); //StudentsInRoomCount(); }
public static bool GetHostelIDByRoomID(Dek TB, int RoomID, int HostelID) { if (RoomID == -1) { return(false); } if (TB.Roomes[GetTrueItemID(TB, RoomID, For.Room)].HostelID == HostelID) { return(true); } else { return(false); } }
}//удаление за айдишником дата грида(уже нет) //удаление за полем айди в елементе //public static void StudentsInGroupeCount()//инициализировать при добавлении каждого студента и редактировании //{ // Dek TB = DataLoadSave.LoadXML(FilePath); // foreach (var item in TB.Groupes) // { // item.StudentsInGroupe = 0; // } // foreach (var Gitem in TB.Groupes) // { // foreach (var Sitem in TB.Students) // { // if (Gitem.ID == Sitem.GroupeID) // { // Gitem.StudentsInGroupe++; // } // } // } // DataLoadSave.SaveXML(FilePath, TB); //} public static void DataInForGroupes(string[] arg) { Dek TB; if (FileEx(FilePath)) { TB = DataLoadSave.LoadXML(FilePath); } else { TB = new Dek(); } GroupeTable GroupeBlok = new GroupeTable(arg[1], arg[3]); TB.Groupes.Add(GroupeBlok); Save(TB); }
//внесение даных в таблици public static int GetTrueItemID(Dek TableBlok, int ID, For @for) { switch (@for) { case For.Student: for (int i = 0; i < TableBlok.Students.Count; i++) { if (TableBlok.Students[i].ID == ID) { return(i); } } break; case For.Groupe: for (int i = 0; i < TableBlok.Groupes.Count; i++) { if (TableBlok.Groupes[i].ID == ID) { return(i); } } break; case For.Room: for (int i = 0; i < TableBlok.Roomes.Count; i++) { if (TableBlok.Roomes[i].ID == ID) { return(i); } } break; case For.Hostel: for (int i = 0; i < TableBlok.HostelsN.Count; i++) { if (TableBlok.HostelsN[i].ID == ID) { return(i); } } break; } return(-1); }
public static void DataInForGroupes(string[] arg, int ID) { Dek TB; if (FileEx(FilePath)) { TB = DataLoadSave.LoadXML(FilePath); } else { TB = new Dek(); } int i = GetTrueItemID(TB, ID, For.Groupe); GroupeTable GroupeBlok = new GroupeTable(arg[1], arg[3]); GroupeBlok.ID = TB.Students[i].ID; TB.Groupes[i] = GroupeBlok; Save(TB); }
public static void RoomsInHostelCount()//вызывать при добавлении и редакт комнаты { Dek TB = DataLoadSave.LoadXML(FilePath); foreach (var item in TB.HostelsN) { item.RoomsCount = 0; } foreach (var Hitem in TB.HostelsN) { foreach (var Ritem in TB.Roomes) { if (Hitem.ID == Ritem.HostelID) { Hitem.RoomsCount++; } } } DataLoadSave.SaveXML(FilePath, TB); }
public static DataTable OpenDataForEdit(For @for, int ID) { Dek TB = DataLoadSave.LoadXML(FilePath); DataSet Ds = new DataSet("Students"); DataTable StudentTable = InitealDTStudentForEdit(); DataTable GroupesTable = InitealDTSGrope(); DataTable RoomTable = InitealDTRoom(); DataTable HostTable = InitealDTSHostel(); Ds.Tables.Add(StudentTable); Ds.Tables.Add(GroupesTable); Ds.Tables.Add(RoomTable); Ds.Tables.Add(HostTable); if (@for == For.Student) { int SitemID = GetTrueItemID(TB, ID, @for); //if (SitemID < TB.StudID) if (SitemID != -1) { StudentsTable StudentBlok = TB.Students[SitemID]; StudentTable.Rows.Add(new object[] { StudentBlok.ID, GetGroupeNameByID(TB, StudentBlok.GroupeID), GetRoomNumberByRoomID(TB, StudentBlok.RoomID), StudentBlok.ThirdName_1, StudentBlok.Name_2, StudentBlok.SurnameName_3, StudentBlok.TicetNumber, StudentBlok.FormStudy, StudentBlok.ContractBudget, StudentBlok.Description }); return(StudentTable); } } else if (@for == For.Groupe) { int GitemID = GetTrueItemID(TB, ID, @for); if (GitemID != -1) { GroupeTable GroupeBlok = TB.Groupes[GitemID]; GroupesTable.Rows.Add(new object[] { GroupeBlok.ID, GroupeBlok.GroupeNumber, GroupeBlok.StudentsInGroupe, GroupeBlok.Description }); return(GroupesTable); } } else if (@for == For.Room) { int RitemID = GetTrueItemID(TB, ID, @for); if (RitemID != -1) { RoomTable RoomBlok = TB.Roomes[RitemID]; RoomTable.Rows.Add(new object[] { RoomBlok.ID, GetHostelNameByID(TB, RoomBlok.HostelID), RoomBlok.RoomNumber, RoomBlok.AllPlace, RoomBlok.FreePlase, RoomBlok.Description }); return(RoomTable); } } else if (@for == For.Hostel) { int HitemID = GetTrueItemID(TB, ID, @for); if (HitemID != -1) { HostelNewTable HostelBlok = TB.HostelsN[HitemID]; HostTable.Rows.Add(new object[] { HostelBlok.ID, HostelBlok.Frame, HostelBlok.RoomsCount, HostelBlok.Decription }); return(HostTable); } } return(null); }