private CompanyAndBtcFile GetTrueCompanyAndBtcFile(long CurrentOrderID, string SendUserName, string CurrentUserName) { CompanyAndBtcFile lCompanyAndBtcFile = new CompanyAndBtcFile(); lCompanyAndBtcFile.Company = _BOCWebDBContext.Companys.Where(e => e.LoginUserName == SendUserName).FirstOrDefault(); lCompanyAndBtcFile.CompanyBtcFile = _BOCWebDBContext.CompanyBtcFiles.Where(e => e.CompanyName == SendUserName).FirstOrDefault(); List<BOC.Entities.CompanyBtcFileTraded> lCompanyBtcFileTradeds = _BOCWebDBContext.CompanyBtcFileTradeds .Where(e => e.CompanyName == SendUserName) .OrderByDescending(e => e.TradeYear).ThenBy(e => e.FromCountry).ThenBy(e => e.ImportExport).ThenBy(e => e.BeefSource) .ToList(); int lLastTradeYear = -1; decimal lTotalTradeQuantity = 0; foreach (BOC.Entities.CompanyBtcFileTraded CompanyBtcFileTraded in lCompanyBtcFileTradeds) { if (lLastTradeYear == -1) { lLastTradeYear = CompanyBtcFileTraded.TradeYear; } if (lLastTradeYear > CompanyBtcFileTraded.TradeYear) { lLastTradeYear = CompanyBtcFileTraded.TradeYear; } lTotalTradeQuantity += CompanyBtcFileTraded.Quantity; } lCompanyAndBtcFile.LastTradeYear = lLastTradeYear; lCompanyAndBtcFile.TotalTradeQuantity = lTotalTradeQuantity; lCompanyAndBtcFile.CompanyBtcFileTradedList = lCompanyBtcFileTradeds; lCompanyAndBtcFile.IsTrueBtcFile = true; if (!(lCompanyAndBtcFile.Company.CompanyName != null && lCompanyAndBtcFile.Company.CompanyName != "")) { lCompanyAndBtcFile.Company.CompanyName = "_none"; } if (!(lCompanyAndBtcFile.Company.CompanyLocalName != null && lCompanyAndBtcFile.Company.CompanyLocalName != "")) { lCompanyAndBtcFile.Company.CompanyLocalName = "_none"; } if (!(lCompanyAndBtcFile.Company.CompanyEmail != null && lCompanyAndBtcFile.Company.CompanyEmail != "")) { lCompanyAndBtcFile.Company.CompanyEmail = "_none"; } if (!(lCompanyAndBtcFile.Company.CompanyType != null && lCompanyAndBtcFile.Company.CompanyType != "")) { lCompanyAndBtcFile.Company.CompanyType = "_none"; } if (!(lCompanyAndBtcFile.Company.CompanyPhoneNumber != null && lCompanyAndBtcFile.Company.CompanyPhoneNumber != "")) { lCompanyAndBtcFile.Company.CompanyPhoneNumber = "_none"; } if (!(lCompanyAndBtcFile.Company.CompanyFaxNumber != null && lCompanyAndBtcFile.Company.CompanyFaxNumber != "")) { lCompanyAndBtcFile.Company.CompanyFaxNumber = "_none"; } if (!(lCompanyAndBtcFile.Company.CompanyWebSite != null && lCompanyAndBtcFile.Company.CompanyWebSite != "")) { lCompanyAndBtcFile.Company.CompanyWebSite = "_none"; } if (!(lCompanyAndBtcFile.Company.CompanyCountry != null && lCompanyAndBtcFile.Company.CompanyCountry != "")) { lCompanyAndBtcFile.Company.CompanyCountry = "_none"; } if (!(lCompanyAndBtcFile.Company.CompanyProvince != null && lCompanyAndBtcFile.Company.CompanyProvince != "")) { lCompanyAndBtcFile.Company.CompanyProvince = "_none"; } if (!(lCompanyAndBtcFile.Company.CompanyAddress != null && lCompanyAndBtcFile.Company.CompanyAddress != "")) { lCompanyAndBtcFile.Company.CompanyAddress = "_none"; } BOC.Entities.ContactPerson TempContactPerson = lCompanyAndBtcFile.Company.ContactPersons.FirstOrDefault(); if(TempContactPerson != null) { if(!(TempContactPerson.ContactPersonCellPhoneNumber != null && TempContactPerson.ContactPersonCellPhoneNumber != "")) { TempContactPerson.ContactPersonCellPhoneNumber = "_none"; } if (!(TempContactPerson.ContactPersonEnglishName != null && TempContactPerson.ContactPersonEnglishName != "")) { TempContactPerson.ContactPersonEnglishName = "_none"; } if (!(TempContactPerson.ContactPersonName != null && TempContactPerson.ContactPersonName != "")) { TempContactPerson.ContactPersonName = "_none"; } } return lCompanyAndBtcFile; }
private CompanyAndBtcFile GetFackCompanyAndBtcFile(long CurrentOrderID, string SendUserName, string CurrentUserName) { CompanyAndBtcFile lCompanyAndBtcFile = new CompanyAndBtcFile(); BOC.Entities.Company TempCompany = _BOCWebDBContext.Companys.Where(e => e.LoginUserName == SendUserName).FirstOrDefault(); lCompanyAndBtcFile.Company = new BOC.Entities.Company(); if (TempCompany != null) { if (TempCompany.CompanyName != null && TempCompany.CompanyName != "") { lCompanyAndBtcFile.Company.CompanyName = "******"; } else { lCompanyAndBtcFile.Company.CompanyName = "_none"; } if (TempCompany.CompanyLocalName != null && TempCompany.CompanyLocalName != "") { lCompanyAndBtcFile.Company.CompanyLocalName = "******"; } else { lCompanyAndBtcFile.Company.CompanyLocalName = "_none"; } if (TempCompany.CompanyEmail != null && TempCompany.CompanyEmail != "") { lCompanyAndBtcFile.Company.CompanyEmail = "******"; } else { lCompanyAndBtcFile.Company.CompanyEmail = "_none"; } if (TempCompany.CompanyType != null && TempCompany.CompanyType != "") { lCompanyAndBtcFile.Company.CompanyType = "******"; } else { lCompanyAndBtcFile.Company.CompanyType = "_none"; } if (TempCompany.CompanyPhoneNumber != null && TempCompany.CompanyPhoneNumber != "") { lCompanyAndBtcFile.Company.CompanyPhoneNumber = "******"; } else { lCompanyAndBtcFile.Company.CompanyPhoneNumber = "_none"; } if (TempCompany.CompanyFaxNumber != null && TempCompany.CompanyFaxNumber != "") { lCompanyAndBtcFile.Company.CompanyFaxNumber = "******"; } else { lCompanyAndBtcFile.Company.CompanyFaxNumber = "_none"; } if (TempCompany.CompanyWebSite != null && TempCompany.CompanyWebSite != "") { lCompanyAndBtcFile.Company.CompanyWebSite = "******"; } else { lCompanyAndBtcFile.Company.CompanyWebSite = "_none"; } if (TempCompany.CompanyCountry != null && TempCompany.CompanyCountry != "") { lCompanyAndBtcFile.Company.CompanyCountry = TempCompany.CompanyCountry; } else { lCompanyAndBtcFile.Company.CompanyCountry = "_none"; } if (TempCompany.CompanyProvince != null && TempCompany.CompanyProvince != "") { if (lCompanyAndBtcFile.Company.CompanyCountry != "_china") { lCompanyAndBtcFile.Company.CompanyProvince = "******"; } else { lCompanyAndBtcFile.Company.CompanyProvince = TempCompany.CompanyProvince; } //lCompanyAndBtcFile.Company.CompanyProvince = TempCompany.CompanyProvince; } else { lCompanyAndBtcFile.Company.CompanyProvince = "_none"; } if (TempCompany.CompanyAddress != null && TempCompany.CompanyAddress != "") { lCompanyAndBtcFile.Company.CompanyAddress = "******"; } else { lCompanyAndBtcFile.Company.CompanyAddress = "_none"; } BOC.Entities.ContactPerson TempContactPerson = TempCompany.ContactPersons.FirstOrDefault(); lCompanyAndBtcFile.Company.ContactPersons = new List<BOC.Entities.ContactPerson>(); BOC.Entities.ContactPerson lContactPerson = new BOC.Entities.ContactPerson(); if (TempContactPerson != null) { if (TempContactPerson.ContactPersonName != null && TempContactPerson.ContactPersonName != "") { lContactPerson.ContactPersonName = "******"; } else { lContactPerson.ContactPersonName = "_none"; } if(TempContactPerson.ContactPersonEnglishName != null && TempContactPerson.ContactPersonEnglishName != "") { lContactPerson.ContactPersonEnglishName = "******"; } else { lContactPerson.ContactPersonEnglishName = "_none"; } if (TempContactPerson.ContactPersonCellPhoneNumber != null && TempContactPerson.ContactPersonCellPhoneNumber != "") { lContactPerson.ContactPersonCellPhoneNumber = "******"; } else { lContactPerson.ContactPersonCellPhoneNumber = "_none"; } } lCompanyAndBtcFile.Company.ContactPersons.Add(lContactPerson); } BOC.Entities.CompanyBtcFile lCompanyBtcFile = _BOCWebDBContext.CompanyBtcFiles.Where(e => e.CompanyName == SendUserName).FirstOrDefault(); lCompanyAndBtcFile.CompanyBtcFile = new BOC.Entities.CompanyBtcFile(); if (lCompanyBtcFile != null) { if (lCompanyBtcFile.CompanyName != null && lCompanyBtcFile.CompanyName != "") { lCompanyAndBtcFile.CompanyBtcFile.CompanyName = "******"; } else { lCompanyAndBtcFile.CompanyBtcFile.CompanyName = "_none"; } if (lCompanyBtcFile.CompanyBtCFile != null && lCompanyBtcFile.CompanyBtCFile != "") { lCompanyAndBtcFile.CompanyBtcFile.CompanyBtCFile = "******"; } else { lCompanyAndBtcFile.CompanyBtcFile.CompanyBtCFile = "_none"; } if (lCompanyBtcFile.CompanyLocalName != null && lCompanyBtcFile.CompanyLocalName != "") { lCompanyAndBtcFile.CompanyBtcFile.CompanyLocalName = "******"; } else { lCompanyAndBtcFile.CompanyBtcFile.CompanyLocalName = "_none"; } if (lCompanyBtcFile.CompanyType != null && lCompanyBtcFile.CompanyType != "") { lCompanyAndBtcFile.CompanyBtcFile.CompanyType = lCompanyBtcFile.CompanyType; } else { lCompanyAndBtcFile.CompanyBtcFile.CompanyType = "_none"; } if (lCompanyBtcFile.CompanyYearFounded != null && lCompanyBtcFile.CompanyYearFounded != "") { lCompanyAndBtcFile.CompanyBtcFile.CompanyYearFounded = "******"; } else { lCompanyAndBtcFile.CompanyBtcFile.CompanyYearFounded = "_none"; } lCompanyAndBtcFile.CompanyBtcFile.CompanyLocalNameCeritificate = lCompanyBtcFile.CompanyLocalNameCeritificate; lCompanyAndBtcFile.CompanyBtcFile.CompanyNameCeritificate = lCompanyBtcFile.CompanyNameCeritificate; lCompanyAndBtcFile.CompanyBtcFile.CompanyTypeCeritificate = lCompanyBtcFile.CompanyTypeCeritificate; lCompanyAndBtcFile.CompanyBtcFile.CompanyYearFoundedCeritificate = lCompanyBtcFile.CompanyYearFoundedCeritificate; } else { lCompanyAndBtcFile.CompanyBtcFile.CompanyName = "_none"; lCompanyAndBtcFile.CompanyBtcFile.CompanyBtCFile = "_none"; lCompanyAndBtcFile.CompanyBtcFile.CompanyLocalName = "_none"; lCompanyAndBtcFile.CompanyBtcFile.CompanyType = "_none"; lCompanyAndBtcFile.CompanyBtcFile.CompanyYearFounded = "_none"; } lCompanyAndBtcFile.CompanyBtcFileTradedList = new List<BOC.Entities.CompanyBtcFileTraded>(); List<BOC.Entities.CompanyBtcFileTraded> lCompanyBtcFileTradeds = _BOCWebDBContext.CompanyBtcFileTradeds .Where(e => e.CompanyName == SendUserName) .OrderByDescending(e => e.TradeYear) .ToList(); int lLastTradeYear = -1; decimal lTotalTradeQuantity = 0; foreach (BOC.Entities.CompanyBtcFileTraded CompanyBtcFileTraded in lCompanyBtcFileTradeds) { if (lLastTradeYear == -1) { lLastTradeYear = CompanyBtcFileTraded.TradeYear; } if (lLastTradeYear > CompanyBtcFileTraded.TradeYear) { lLastTradeYear = CompanyBtcFileTraded.TradeYear; } lTotalTradeQuantity += CompanyBtcFileTraded.Quantity; BOC.Entities.CompanyBtcFileTraded lCompanyBtcFileTraded = new BOC.Entities.CompanyBtcFileTraded(); lCompanyBtcFileTraded.IsCertificate = CompanyBtcFileTraded.IsCertificate; lCompanyAndBtcFile.CompanyBtcFileTradedList.Add(lCompanyBtcFileTraded); } lCompanyAndBtcFile.LastTradeYear = lLastTradeYear; lCompanyAndBtcFile.TotalTradeQuantity = lTotalTradeQuantity; lCompanyAndBtcFile.IsTrueBtcFile = false; return lCompanyAndBtcFile; }