public static List <HistoryTTN> GetHistoryTTN(DateTime date) { List <HistoryTTN> liHTTN = new List <HistoryTTN>(); using (DBTTNEntities db = new DBTTNEntities()) { var history = db.tbl_Movement_History.Where(x => x.Data_Movement_History.Equals(date)).ToList(); int i = 0; while (history.Count > i) { liHTTN.Add(new HistoryTTN { Date = date, SenderPartNumber = db.tbl_ORM.Where(x => x.ID_ORM == (int)history[i].Kod_Sender_ORM).Select(x => x.Short_Name_ORM).FirstOrDefault(), SenderFIO = db.tbl_Kadrovii_Sostav.Where(x => x.ID_KS == (int)history[i].Kod_Sender_Kadr_Sost).Select(x => x.Familiya_KS + " " + x.Imya_KS.Substring(0, 1) + ". " + x.Otchestvo_KS.Substring(0, 1) + ".").FirstOrDefault(), SenderPermissionFIO = db.tbl_Kadrovii_Sostav.Where(x => x.ID_KS == (int)history[i].Kod_Sender_Permision_Kadr_Sost).Select(x => x.Familiya_KS + " " + x.Imya_KS.Substring(0, 1) + ". " + x.Otchestvo_KS.Substring(0, 1) + ".").FirstOrDefault(), DriverFIO = db.tbl_Kadrovii_Sostav.Where(x => x.ID_KS == (int)history[i].Kod_Driver_Kadr_Sost).Select(x => x.Familiya_KS + " " + x.Imya_KS.Substring(0, 1) + ". " + x.Otchestvo_KS.Substring(0, 1) + ".").FirstOrDefault(), DriverListNumber = (long)history[i].Kod_Driver_Movement_List, DriverCarNumber = "1", NumberTTN = (int)history[i].Movement_History_Number, RequestedFIO = db.tbl_Kadrovii_Sostav.Where(x => x.ID_KS == (int)history[i].Kod_Recever_Request_Kadr_Sost).Select(x => x.Familiya_KS + " " + x.Imya_KS.Substring(0, 1) + ". " + x.Otchestvo_KS.Substring(0, 1) + ".").FirstOrDefault(), RequestedPartNumber = db.tbl_ORM.Where(x => x.ID_ORM == (int)history[i].Kod_Recever_ORM).Select(x => x.Short_Name_ORM).FirstOrDefault() }); i++; } } return(liHTTN); }
public static List <HistoryDetails> GetDetailsHistory(int numberTTN) { List <HistoryDetails> liHDeet = new List <HistoryDetails>(); using (DBTTNEntities db = new DBTTNEntities()) { var hDet = db.tbl_Movement_History_Details.Where(x => x.Kod_Movement_History == numberTTN).ToList(); int i = 0; while (hDet.Count > 0) { string modulName = null; if (db.tbl_Modul_Name.Where(x => x.ID_Modul_Name == (int)hDet[i].Kod_Modul_Name).Count() > 0) { modulName = db.tbl_Modul_Name.Where(x => x.ID_Modul_Name == (int)hDet[i].Kod_Modul_Name).Select(x => x.Short_Name_Modul_Name).FirstOrDefault(); } else { modulName = hDet[i].Modul_Name_IF_Definition_Not_Exist_In_Dictionary; } liHDeet.Add(new HistoryDetails { ModulName = modulName, ZavodInventNumber = hDet[i].Zavod_Invent_Number, Count = (int)hDet[i].Count_Modul, EdIzmer = db.tbl_Spiski.Where(x => x.ID_Spiski == (int)hDet[i].Kod_Ed_Izmer).Select(x => x.Value_Spiski).FirstOrDefault(), Package = db.tbl_Spiski.Where(x => x.ID_Spiski == (int)hDet[i].Kod_Package).Select(x => x.Value_Spiski).FirstOrDefault(), Weight = hDet[i].Weight_Modul.Value, WayToGetWeight = hDet[i].Kod_Way_To_Get_Weight }); i++; } } return(liHDeet); }