private void LoadData() { cbLpuRR.Enabled = (UserLogged.Get().RoleSF == RolesSF.Администратор); cbLpuRR2.Enabled = (UserLogged.Get().RoleSF == RolesSF.Администратор); this.Text = (_parentLPU == null) ? "Карточка Организации \"ЛПУ\"" : "Карточка Организации \"Филиал ЛПУ\""; lbKPP.Text = (_parentLPU == null) ? "КПП:" : "КПП*:"; lbCrmID.Text = (_lpu.CrmID == string.Empty) ? "не присвоен" : _lpu.CrmID; lbNumberLpuID.Text = (_lpu.ID == 0) ? "не присвоен" : _lpu.ID.ToString(); lbLpuRRId.Text = (_lpu.LpuRR == null) ? "не присвоен" : _lpu.LpuRR.ID.ToString(); lbTypeOrg.Text = _lpu.TypeOrg.ToString(); if (_lpu.TypeLPU != null) { cbTypeLpu.SelectedValue = _lpu.TypeLPU.ID; } if (_lpu.Ownership != null) { cbOwnership.SelectedValue = _lpu.Ownership.ID; } if (_lpu.AdmLevel != null) { cbAdmLevel.SelectedValue = _lpu.AdmLevel.ID; } if (_lpu.MainSpec != null) { cbMainSpec.SelectedValue = _lpu.MainSpec.ID; } if (_lpu.TypeFin != null) { cbTypeFin.SelectedValue = _lpu.TypeFin.ID; } tbName.Text = _lpu.Name; tbShortName.Text = _lpu.ShortName; if (_lpu.ShortName == string.Empty) { lbBranchName.Text = string.Empty; lbLPUName.Text = string.Empty; } if (_lpu.LpuRR != null) { cbLpuRR.SelectedValue = _lpu.LpuRR.ID; lbRegionRR.Text = _lpu.LpuRR.RegionRR.Name; } if (_lpu.LpuRR2 != null) { cbLpuRR2.SelectedValue = _lpu.LpuRR2.ID; lbRegionRR2.Text = _lpu.LpuRR2.RegionRR.Name; } tbKPP.Text = _lpu.KPP; tbPostIndex.Text = _lpu.PostIndex; tbEmail.Text = _lpu.Email; tbWebSite.Text = _lpu.Website; tbPhone.Text = _lpu.Phone; tbCity.Text = _lpu.City; if (_lpu.RealRegion != null) { cbRealRegion.SelectedValue = _lpu.RealRegion.ID; } if (_parentLPU == null) { tbINN.Text = _lpu.INN; } else { tbINN.Text = _parentLPU.INN; tbINN.ReadOnly = true; } tbSubRegion.Text = _lpu.SubRegion; tbStreet.Text = _lpu.Street; tbBedsTotal.Text = _lpu.BedsTotal; tbBedsIC.Text = _lpu.BedsIC; tbBedsSurgical.Text = _lpu.BedsSurgical; tbOperating.Text = _lpu.Operating; SetReadOnlyAvitum(); if (_lpu.IsHaveDepartment()) { OrganizationList organizationoList = OrganizationList.GetUniqueInstance(); var childList = from item in organizationoList.GetChildList(_lpu) where item.TypeOrg == TypeOrg.Отделение select new { MachineGD = string.IsNullOrEmpty(item.MachineGD) ? 0 : Convert.ToInt32(item.MachineGD), MachineGDF = string.IsNullOrEmpty(item.MachineGDF) ? 0 : Convert.ToInt32(item.MachineGDF), MachineCRRT = string.IsNullOrEmpty(item.MachineCRRT) ? 0 : Convert.ToInt32(item.MachineCRRT), Shift = string.IsNullOrEmpty(item.Shift) ? 0 : Convert.ToInt32(item.Shift), PatientGD = string.IsNullOrEmpty(item.PatientGD) ? 0 : Convert.ToInt32(item.PatientGD), PatientPD = string.IsNullOrEmpty(item.PatientPD) ? 0 : Convert.ToInt32(item.PatientPD), PatientCRRT = string.IsNullOrEmpty(item.PatientCRRT) ? 0 : Convert.ToInt32(item.PatientCRRT) }; tbMachineGD.Text = childList.Sum(item => item.MachineGD).ToString(); tbMachineGDF.Text = childList.Sum(item => item.MachineGDF).ToString(); tbMachineCRRT.Text = childList.Sum(item => item.MachineCRRT).ToString(); tbShift.Text = childList.Sum(item => item.Shift).ToString(); tbPatientGD.Text = childList.Sum(item => item.PatientGD).ToString(); tbPatientPD.Text = childList.Sum(item => item.PatientPD).ToString(); tbPatientCRRT.Text = childList.Sum(item => item.PatientCRRT).ToString(); } else { tbMachineGD.Text = _lpu.MachineGD; tbMachineGDF.Text = _lpu.MachineGDF; tbMachineCRRT.Text = _lpu.MachineCRRT; tbShift.Text = _lpu.Shift; tbPatientGD.Text = _lpu.PatientGD; tbPatientPD.Text = _lpu.PatientPD; tbPatientCRRT.Text = _lpu.PatientCRRT; } LoadTree(); ShowHistory(); }
private void Export(Language lang) { OrganizationList organizationList = OrganizationList.GetUniqueInstance(); string[] columnNames = (lang == Language.Rus) ? _columnNamesRus : _columnNamesEng; DataTable dt = CreateDataTable(columnNames); HistoryList historyList = HistoryList.GetUniqueInstance(); foreach (var item in organizationList.List) { Organization organization = item.Value; LPU lpu = (organization.TypeOrg == TypeOrg.ЛПУ) ? (organization as LPU) : null; int parentID = (organization.ParentOrganization == null) ? organization.ID : organization.ParentOrganization.ID; string recordType = GetRecordType(organization); string inn = (organization.INN == "") ? "" : "'" + organization.INN; string kpp = (organization.KPP == "") ? "" : "'" + organization.KPP; string realRegionName = (organization.RealRegion == null) ? "" : organization.RealRegion.Name; string postIndex = organization.PostIndex; string pharmacy = ((organization.TypeOrg == TypeOrg.Аптека) && (organization.ParentOrganization == null)) ? (organization as Organization).Pharmacy : string.Empty; string mainSpec = (organization.MainSpec != null) ? organization.MainSpec.GetName(lang) : string.Empty; string typeLPU = string.Empty; string ownership = string.Empty; string adminLevel = string.Empty; string typeFin = string.Empty; if (lpu != null) { typeLPU = lpu.TypeLPU.GetName(lang); ownership = lpu.Ownership.GetName(lang); adminLevel = lpu.AdmLevel.GetName(lang); typeFin = lpu.TypeFin.GetName(lang); } object[] row; if (lang == Language.Rus) { string street = organization.Street; string idLpuRR = string.Empty; string idLpuRR2 = string.Empty; if (lpu != null) { idLpuRR = ((lpu.ParentOrganization == null) || ((lpu.ParentOrganization != null) && (lpu.LpuRR.ID != 0))) ? lpu.LpuRR.ID.ToString() : string.Empty; idLpuRR2 = (lpu.LpuRR2.ID != 0) ? lpu.LpuRR2.ID.ToString() : string.Empty; } History created = historyList.GetItem(organization, HistoryAction.Создал); History modifed = historyList.GetItem(organization, HistoryAction.едактировал); string createdAuthor = (created != null) ? created.Author : string.Empty; string createdDatetime = (created != null) ? created.datetime : string.Empty; string modifedAuthor = (modifed != null) ? modifed.Author : string.Empty; string modifedDatetime = (modifed != null) ? modifed.datetime : string.Empty; row = new object[] { organization.ID, parentID, organization.NumberSF, recordType, GetFormatTypeOrg(organization), GetClientType(organization), organization.Name, organization.ShortName, inn, kpp, realRegionName, organization.City, postIndex, street, organization.Email, organization.Website, organization.Phone, pharmacy, typeLPU, ownership, adminLevel, typeFin, mainSpec, lpu.SubRegion, idLpuRR, idLpuRR2, (lpu != null) ? lpu.BedsTotal : string.Empty, (lpu != null) ? lpu.BedsIC : string.Empty, (lpu != null) ? lpu.BedsSurgical : string.Empty, (lpu != null) ? lpu.Operating : string.Empty, organization.MachineGD, organization.MachineGDF, organization.MachineCRRT, organization.Shift, organization.PatientGD, organization.PatientPD, organization.PatientCRRT, createdAuthor, createdDatetime, modifedAuthor, modifedDatetime }; } else { string MachineGD = string.Empty; string MachineGDF = string.Empty; string MachineCRRT = string.Empty; string Shift = string.Empty; string PatientGD = string.Empty; string PatientPD = string.Empty; string PatientCRRT = string.Empty; if ((lpu != null) && (lpu.IsHaveDepartment())) { OrganizationList organizationoList = OrganizationList.GetUniqueInstance(); var childList = from child in organizationoList.GetChildList(lpu) where child.TypeOrg == TypeOrg.Отделение select new { MachineGD = string.IsNullOrEmpty(child.MachineGD) ? 0 : Convert.ToInt32(child.MachineGD), MachineGDF = string.IsNullOrEmpty(child.MachineGDF) ? 0 : Convert.ToInt32(child.MachineGDF), MachineCRRT = string.IsNullOrEmpty(child.MachineCRRT) ? 0 : Convert.ToInt32(child.MachineCRRT), Shift = string.IsNullOrEmpty(child.Shift) ? 0 : Convert.ToInt32(child.Shift), PatientGD = string.IsNullOrEmpty(child.PatientGD) ? 0 : Convert.ToInt32(child.PatientGD), PatientPD = string.IsNullOrEmpty(child.PatientPD) ? 0 : Convert.ToInt32(child.PatientPD), PatientCRRT = string.IsNullOrEmpty(child.PatientCRRT) ? 0 : Convert.ToInt32(child.PatientCRRT) }; MachineGD = childList.Sum(child => child.MachineGD).ToString(); if (MachineGD == "0") { MachineGD = string.Empty; } MachineGDF = childList.Sum(child => child.MachineGDF).ToString(); if (MachineGDF == "0") { MachineGDF = string.Empty; } MachineCRRT = childList.Sum(child => child.MachineCRRT).ToString(); if (MachineCRRT == "0") { MachineCRRT = string.Empty; } Shift = childList.Sum(child => child.Shift).ToString(); if (Shift == "0") { Shift = string.Empty; } PatientGD = childList.Sum(child => child.PatientGD).ToString(); if (PatientGD == "0") { PatientGD = string.Empty; } PatientPD = childList.Sum(child => child.PatientPD).ToString(); if (PatientPD == "0") { PatientPD = string.Empty; } PatientCRRT = childList.Sum(child => child.PatientCRRT).ToString(); if (PatientCRRT == "0") { PatientCRRT = string.Empty; } } else { MachineGD = organization.MachineGD; MachineGDF = organization.MachineGDF; MachineCRRT = organization.MachineCRRT; Shift = organization.Shift; PatientGD = organization.PatientGD; PatientPD = organization.PatientPD; PatientCRRT = organization.PatientCRRT; } row = new object[] { organization.ID, parentID, recordType, organization.Name, organization.ShortName, inn, kpp, realRegionName, organization.City, postIndex, GetAddressWithDistrict(organization), organization.Email, organization.Website, organization.Phone, pharmacy, GetClientType(organization), typeLPU, ownership, adminLevel, typeFin, mainSpec, lpu.SubRegion, (lpu != null) ? lpu.BedsTotal : string.Empty, (lpu != null) ? lpu.BedsIC : string.Empty, (lpu != null) ? lpu.BedsSurgical : string.Empty, (lpu != null) ? lpu.Operating : string.Empty, MachineGD, MachineGDF, MachineCRRT, Shift, PatientGD, PatientPD, PatientCRRT }; } dt.Rows.Add(row); } CreateExcel excel = new CreateExcel(dt); excel.Show(); }