protected void btnAdd_Click(object sender, EventArgs e)
        {
            using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
            {
                Petient petient = new Petient();
                petient.Id = Guid.NewGuid();
                petient.First_Name = txtFirstName.Text;
                petient.Last_Name = txtLastName.Text;
                petient.Sex = ddlSex.Text;
                petient.Age = short.Parse(txtAge.Text);
                petient.Job = txtJob.Text;
                petient.Country = txtCountry.Text;
                petient.City = txtCity.Text;
                petient.City_Location = txtCityLocation.Text;
                petient.Address = txtAddress.Text;
                petient.Mobile = txtMobile.Text;
                petient.Phone = txtPhone.Text;
                petient.Email = txtEmail.Text;
                if (ddlIntro.Text != SharedClass.GetIntroducer(SharedClass.IntroType.Others))
                {
                    petient.Introducer = ddlIntro.Text;
                }
                else
                {
                    petient.Introducer = txtIntro.Text;
                }

                mc.Petients.Add(petient);
                mc.SaveChanges();

                grvPetient.EditIndex = -1;
            }
        }
Пример #2
0
        protected void btnSet_Click(object sender, EventArgs e)
        {
            using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
            {
                var petientId = Guid.Parse(Request["ID"]);

                var selectedService = (ucServicesControl.SelectedService != ucServicesControl.OthersValue) ? ucServicesControl.SelectedService : null;
                var selectedParts = ucServicesControl.SelectedParts;

                var dateToVisit = cal.Date.Value;
                var timeToVisit = TimePickerControl.Time.TimeOfDay;
                var visitingTimeDate = new DateTime(dateToVisit.Year, dateToVisit.Month, dateToVisit.Day, timeToVisit.Hours, timeToVisit.Minutes, 0);
                var allocatedTime = allocateTimeForPetient(visitingTimeDate, ddlDoctor.SelectedValue, ddlTech.SelectedValue, selectedService);
                if (allocatedTime == null)
                {
                    //TODO: Error on allocating time
                    return;
                }

                Petient_Visiting_Financial visitingFile = new Petient_Visiting_Financial();

                visitingFile.TimeVisitStarts = allocatedTime[0]; //Start
                visitingFile.TimeVisitEnds = allocatedTime[1]; //End
                visitingFile.Is_Petient_Returned = false;
                visitingFile.Is_Money_Paid = false;
                visitingFile.Is_Petient_Visited = false;
                visitingFile.Is_Petient_Canceled = false;
                if (ucServicesControl.SelectedService != ucServicesControl.OthersValue)
                {
                    visitingFile.Money_To_Pay = costOfService(ucServicesControl.SelectedService);
                    visitingFile.Reason = null;
                }
                else
                {
                    visitingFile.Money_To_Pay = 0;
                    visitingFile.Reason = ucServicesControl.ReasonValue;
                }
                visitingFile.Money_Changed = 0;
                visitingFile.Money_Paid_Cash = 0;
                visitingFile.Money_Paid_Card = 0;
                visitingFile.POS_Name = null;
                int lastBalance = 0;
                var petientVisitingFiles = mc.Connectors.Where(o => o.PetientId == petientId && o.FinancialId != null
                    && o.Petient_Visiting_Financials.TimeVisitStarts < visitingFile.TimeVisitStarts)
                    .OrderByDescending(o => o.Petient_Visiting_Financials.TimeVisitStarts).ToList();
                if (petientVisitingFiles.Count() != 0)
                {
                    lastBalance = petientVisitingFiles.First().Petient_Visiting_Financials.Balance;
                }
                visitingFile.Balance = lastBalance + visitingFile.Money_To_Pay;

                mc.Petient_Visiting_Financials.Add(visitingFile);

                createConnections(mc, selectedService, petientId, visitingFile.Id, selectedParts);

                mc.SaveChanges();
            }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            makeTree();

            using(Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
            {
                rptService.DataSource = services;
                rptService.DataBind();
            }
        }
Пример #4
0
        protected void btnDeleteFile_Click(object sender, EventArgs e)
        {
            using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
            {
                var btnDelete = (Button)sender;
                long fileId = long.Parse(btnDelete.CommandArgument);
                mc.Petient_Files.Remove(mc.Petient_Files.Where(o => o.Id == fileId).First());

                mc.SaveChanges();
            }
        }
Пример #5
0
 public static void EditConnectorObjectsFileByFinancialId(
     Medical_Clinic_Entities mc,
     long? Financial,
     long? File
     )
 {
     var connectors = mc.Connectors.Where(o => o.FinancialId == Financial).ToList();
     foreach (var connector in connectors)
     {
         connector.FileId = File;
     }
 }
Пример #6
0
 private void makeTree()
 {
     using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
     {
         foreach (var service in mc.BSI__Clinic_Services.Where(o => o.Parent_Id == null).ToList())
         {
             services.Add(service);
             aligmentString.Add(service.Id, "&nbsp&nbsp");
             findChild(service, "&nbsp&nbsp");
         }
     }
 }
Пример #7
0
 protected bool isProvidingService(object obj)
 {
     using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
     {
         var id = Request["ID"];
         var employeeServices = mc.BSI__Clinic_Employees.Where(o => o.Id == id).First().BSI__Employee_Service_Set.ToList();
         if (employeeServices.Where(o => o.Service_Id == (int)obj).Count() != 0)
         {
             return true;
         }
     }
     return false;
 }
Пример #8
0
 public static List<BSI__Clinic_Employee> GetAllEmployees()
 {
     using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
     {
         if (SharedClass.IsUserAdminOrOperator(SharedClass.CurrentUser) == true)
         {
             return mc.BSI__Clinic_Employees.Where( o => o.Is_Active == true).ToList();
         }
         else
         {
             return mc.BSI__Clinic_Employees.Where(o => o.Id == SharedClass.CurrentUser).ToList();
         }
     }
 }
Пример #9
0
 protected string getPersonToVisit(object id, SharedClass.RelationType relation)
 {
     using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
     {
         var visitingFile = mc.Petient_Visiting_Financials.Where(o => o.Id == (long)id).First();
         var persons = visitingFile.Connectors.Where(o => o.RelationType == SharedClass.GetRelationType(relation)).ToList();
         if (persons.Count() != 0)
         {
             return persons.First().BSI__Clinic_Employees.First_Name + " " + persons.First().BSI__Clinic_Employees.Last_Name;
         }
         else
         {
             return nobody;
         }
     }
 }
Пример #10
0
 private void findChild(BSI__Clinic_Service currentService, string alignment)
 {
     using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
     {
         foreach (var service in mc.BSI__Clinic_Services.Where(o => o.Parent_Id == currentService.Id).ToList())
         {
             services.Add(service);
             string currentAlignment = "&nbsp &nbsp &nbsp" + alignment;
             aligmentString.Add(service.Id, currentAlignment);
             if (service.BSI__Clinic_Services_Child.Count() != 0)
             {
                 findChild(service, currentAlignment);
             }
         }
     }
 }
Пример #11
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
            {
                foreach (RepeaterItem item in rptService.Items)
                {
                    var chkService = ((CheckBox)item.FindControl("chkService"));
                    int serviceId = int.Parse(((Label)item.FindControl("lblId")).Text);
                    short minsForService = short.Parse(((TextBox)item.FindControl("txtMinsForService")).Text);
                    var txtPortion = ((TextBox)item.FindControl("txtPortion"));

                    var employeeId = Request["ID"];
                    var currentEmployeeService = mc.BSI__Employee_Service_Set.Where(o => o.Employee_Id == employeeId && o.Service_Id == serviceId).ToList();

                    if (chkService.Checked == true && chkService.Enabled == true)
                    {
                        if (currentEmployeeService.Count() == 0)
                        {
                            BSI__Employee_Service employeeService = new BSI__Employee_Service();
                            employeeService.Service_Id = serviceId;
                            employeeService.Employee_Id = employeeId;
                            employeeService.Mins_For_Service = minsForService;

                            mc.BSI__Employee_Service_Set.Add(employeeService);
                            addPart(employeeService.Service_Id, employeeId);
                        }
                        else
                        {
                            currentEmployeeService.First().Mins_For_Service = minsForService;
                            editPart(currentEmployeeService.First().Service_Id, employeeId);
                        }
                    }
                    else if(chkService.Enabled == true)
                    {
                        if (currentEmployeeService.Count() != 0)
                        {
                            mc.BSI__Employee_Service_Set.Remove(currentEmployeeService.First());
                            deletePart(currentEmployeeService.First().Service_Id, employeeId);
                        }
                    }
                }

                mc.SaveChanges();
            }
        }
Пример #12
0
        protected void btnSignUp_Click(object sender, EventArgs e)
        {
            if (txtPassword.Text != txtVerifyPassword.Text)
            {
                lblErrorSignup.Text = passNotTheSame;
                return;
            }
            else
            {
                lblErrorSignup.Text = "";
            }

            var userStore = new UserStore<IdentityUser>();
            var userManager = new UserManager<IdentityUser>(userStore);
            var user = new IdentityUser() { UserName = txtUsername.Text, Email = txtEmail.Text, EmailConfirmed = true };
            IdentityResult result = userManager.Create(user, txtPassword.Text);

            if (result.Succeeded == true)
            {
                result = userManager.AddToRole(user.Id, ddlRole.Text);
                if (result.Succeeded == true)
                {
                    using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
                    {
                        BSI__Clinic_Employee employee = new BSI__Clinic_Employee();
                        employee.Id = user.Id;
                        employee.First_Name = txtFirstName.Text;
                        employee.Last_Name = txtLastName.Text;
                        employee.Created_Date = DateTime.Now;
                        employee.Last_Login = DateTime.Now;
                        employee.Job_Clinic = ddlJobClinic.Text;

                        mc.BSI__Clinic_Employees.Add(employee);

                        mc.SaveChanges();
                    }
                }

                lblErrorSignup.Text = "";
            }
            else
            {
                lblErrorSignup.Text = result.Errors.First();
            }
        }
Пример #13
0
        protected void btnEditFile_Click(object sender, EventArgs e)
        {
            var fileId = long.Parse(((Button)sender).CommandArgument);

            using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
            {
                var financial = mc.Connectors.Where(o => o.FileId == fileId && o.FinancialId != null).FirstOrDefault();

                if (financial == null)
                {
                    Response.Redirect("~/Operator/File_Petient_Edit.aspx?ID=" + fileId);
                }
                else
                {
                    Response.Redirect("~/Operator/File_Petient_Edit.aspx?ID=" + fileId + "&FinancialID=" + financial.FinancialId);
                }
            }
        }
        protected void btnCancel_Click(object sender, EventArgs e)
        {
            using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
            {
                var financialId = (Request["FinancialID"] != null) ? long.Parse(Request["FinancialID"]) : (long?)null;
                long fileId = long.Parse(Request["ID"]);
                var fileToEdit = mc.Petient_Files.Where(o => o.Id == fileId).First();

                if (financialId == null)
                {
                    Response.Redirect("~/File_Petient.aspx?ID=" + fileToEdit.Connectors.First().Petient.Id);
                }
                else
                {
                    Response.Redirect("~/File_Petient.aspx?ID=" + fileToEdit.Connectors.First().Petient.Id + "&FinancialID=" + financialId);
                }
            }
        }
Пример #15
0
        public void getServicesOfFile(long? financialId, out string reason, out  int? service, out List<int> parts)
        {
            using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
            {
                if (financialId != null)
                {
                    var financial = mc.Petient_Visiting_Financials.Where(o => o.Id == financialId).First();

                    parts = new List<int>();

                    if (financial.Reason != null)
                    {
                        reason = financial.Reason;

                        service = null;
                        parts = null;
                    }
                    else
                    {
                        reason = null;

                        service = mc.Connectors.Where(o => o.FinancialId == financialId && o.BSI__Clinic_Services.Is_Part != true).First().BSI__Clinic_Services.Id;
                        parts = mc.Connectors.Where(o => o.FinancialId == financialId && o.BSI__Clinic_Services.Is_Part == true)
                            .GroupBy(o => o.ServiceId).Select(o => o.FirstOrDefault().ServiceId.Value).ToList();
                    }
                }
                else
                {
                    service = (ucServicesControl.SelectedService != ucServicesControl.OthersValue) ? ucServicesControl.SelectedService : null;
                    parts = ucServicesControl.SelectedParts;

                    if (service != null)
                    {
                        reason = null;
                    }
                    else
                    {
                        reason = ucServicesControl.ReasonValue;
                    }
                }
            }
        }
Пример #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
            {
                var currentEmployee = mc.BSI__Clinic_Employees.Where(o => o.Id == SharedClass.CurrentUser).First();
                lblWelcomeUser.Text = currentEmployee.First_Name + " " + currentEmployee.Last_Name + welcome;
            }

            lblCurrentTime.Text = today + FarsiLibrary.Utils.PersianDate.Now.ToString("d");

            //Links Visibility :
            lnkDefault.Visible = SharedClass.HasUserProperAccess(SharedClass.CurrentUser, SharedClass.AccessType.Default);
            lnkPetientManagement.Visible = SharedClass.HasUserProperAccess(SharedClass.CurrentUser, SharedClass.AccessType.Petient_Management);
            lnkUserManagement.Visible = SharedClass.HasUserProperAccess(SharedClass.CurrentUser, SharedClass.AccessType.User_Management);
            lnkServiceManagement.Visible = SharedClass.HasUserProperAccess(SharedClass.CurrentUser, SharedClass.AccessType.Service_Management);
            lnkTimeManagement.Visible = SharedClass.HasUserProperAccess(SharedClass.CurrentUser, SharedClass.AccessType.Time_Management);
            lnkTimeManagement.Visible = SharedClass.HasUserProperAccess(SharedClass.CurrentUser, SharedClass.AccessType.CostList);
            lnkReports.Visible = SharedClass.HasUserProperAccess(SharedClass.CurrentUser, SharedClass.AccessType.Reports);
            lnkStatistics.Visible = SharedClass.HasUserProperAccess(SharedClass.CurrentUser, SharedClass.AccessType.Statistics);
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
            {
                petientsToShow = mc.Petients.ToList();

                if (txtFirstNameSearch.Text != "")
                {
                    petientsToShow = petientsToShow.Where(o => o.First_Name.Contains(txtFirstNameSearch.Text)).ToList();
                }
                if (txtLastNameSearch.Text != "")
                {
                    petientsToShow = petientsToShow.Where(o => o.Last_Name.Contains(txtLastNameSearch.Text)).ToList();
                }
                if (txtMobileSearch.Text != "")
                {
                    petientsToShow = petientsToShow.Where(o => o.Mobile.Contains(txtMobileSearch.Text)).ToList();
                }
            }
            grvPetient.EditIndex = -1;
        }
        protected void btnEdit_Click(object sender, EventArgs e)
        {
            using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
            {
                var financialId = (Request["FinancialID"] != null) ? long.Parse(Request["FinancialID"]) : (long?)null;
                long fileId = long.Parse(Request["ID"]);
                var fileToEdit = mc.Petient_Files.Where(o => o.Id == fileId).First();

                if (fileToEdit.Connectors.Where(o => o.FinancialId != null).Count() != 0)
                {
                    fileToEdit.Details = txtDetailsFinancial.Text;
                }
                else
                {
                    string reason = null;
                    int? selectedService = null;
                    List<int> selectedParts = null;

                    getServicesOfFile(financialId, out reason, out selectedService, out selectedParts);

                    fileToEdit.Details = txtDetails.Text;

                    fileToEdit.Reason = reason;

                    createRemoveConnections(mc, selectedService, fileToEdit.Connectors.First().Petient.Id, fileId, selectedParts);

                }

                mc.SaveChanges();

                if (financialId == null)
                {
                    Response.Redirect("~/File_Petient.aspx?ID=" + fileToEdit.Connectors.First().Petient.Id);
                }
                else
                {
                    Response.Redirect("~/File_Petient.aspx?ID=" + fileToEdit.Connectors.First().Petient.Id + "&FinancialID=" + financialId);
                }
            }
        }
Пример #19
0
        public static void CreateConnectorObject(
            Medical_Clinic_Entities mc,
            string Employee,
            int? Service,
            int? EmployeeService,
            Guid Petient,
            long? File,
            long? Financial,
            SharedClass.RelationType RelationType
            )
        {
            var connector = new Connector();
            connector.EmployeeId = Employee;
            connector.ServiceId = Service;
            connector.EmployeeServiceId = EmployeeService;
            connector.PetientId = Petient;
            connector.FileId = File;
            connector.FinancialId = Financial;
            connector.RelationType = SharedClass.GetRelationType(RelationType);
            connector.CreatedDate = DateTime.Now;

            mc.Connectors.Add(connector);
        }
Пример #20
0
        protected void login_Authenticate(object sender, AuthenticateEventArgs e)
        {
            var userStore = new UserStore<IdentityUser>();
            var manager = new UserManager<IdentityUser>(userStore);
            var user = manager.Find(login.UserName, login.Password);

            if (user != null)
            {
                using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
                {
                    var employee = mc.BSI__Clinic_Employees.Where(o => o.Id == user.Id).First();

                    if(employee.Is_Active != true)
                    {
                        return;
                    }

                    employee.Last_Login = DateTime.Now;
                    mc.SaveChanges();
                }
                FormsAuthentication.RedirectFromLoginPage(user.Id, false);
            }
        }
Пример #21
0
 public static void CreateConnectorObject(
     Medical_Clinic_Entities mc,
     string Employee,
     List<int> Parts,
     Guid Petient,
     long? File,
     long? Financial,
     SharedClass.RelationType RelationType
     )
 {
     foreach (var part in Parts)
     {
         ModelClass.CreateConnectorObject(
             mc,
             Employee,
             part,
             mc.BSI__Employee_Service_Set.Where(o => o.Employee_Id == Employee && o.Service_Id == part).First().Id,
             Petient,
             File,
             Financial,
             RelationType
             );
     }
 }
Пример #22
0
        public static List<BSI__Employee_Service> GetEmployeesOfSelectedService(int? selectedServiceId, string specifiedEmployee = null)
        {
            using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
            {
                if (selectedServiceId == null)
                {
                    return null;
                }

                if (SharedClass.IsUserAdminOrOperator(SharedClass.CurrentUser) == true)
                {
                    if (specifiedEmployee == null)
                    {
                        return mc.BSI__Employee_Service_Set.Include("BSI__Clinic_Employees").Where(o => o.Service_Id == selectedServiceId && o.BSI__Clinic_Employees.Is_Active == true).ToList();
                    }
                    else
                    {
                        return mc.BSI__Employee_Service_Set.Include("BSI__Clinic_Employees").Where(o => o.Service_Id == selectedServiceId && o.Employee_Id == specifiedEmployee && o.BSI__Clinic_Employees.Is_Active == true).ToList();
                    }
                }
                else
                {
                    if (specifiedEmployee == null)
                    {
                        return mc.BSI__Employee_Service_Set.Include("BSI__Clinic_Employees").Where(o => o.Service_Id == selectedServiceId && o.Employee_Id == SharedClass.CurrentUser).ToList();
                    }
                    else
                    {
                        return mc.BSI__Employee_Service_Set.Include("BSI__Clinic_Employees").Where(o => o.Service_Id == selectedServiceId && o.Employee_Id == SharedClass.CurrentUser && o.Employee_Id == specifiedEmployee).ToList();
                    }
                }
            }
        }
Пример #23
0
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
            {
                var grvUsersDataSource = mc.AspNetUsers.Join(mc.BSI__Clinic_Employees, oOutter => oOutter.Id, oInner => oInner.Id, (user, employee) => new
                {
                    Id = user.Id,
                    User_Name = user.UserName,
                    First_Name = employee.First_Name,
                    Last_Name = employee.Last_Name,
                    Email = user.Email,
                    Created_Date = employee.Created_Date,
                    Last_Login = employee.Last_Login,
                    Job_Clinic = employee.Job_Clinic,
                    Is_Active = employee.Is_Active
                }).OrderBy(o => o.Last_Name).ToList();

                grvUsers.DataSource = grvUsersDataSource;
                grvUsers.DataBind();
            }

            ddlJobClinic.DataSource = SharedClass.JobClinic;
            ddlJobClinic.DataBind();
        }
Пример #24
0
        public static short? GetParentServiceStandardValue(long? FinancialId)
        {
            //We only calculate parent services values as a unit for "cost per unit" not parts !

            using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
            {
                var financial = mc.Petient_Visiting_Financials.Where(o => o.Id == FinancialId).First();

                if (financial.Reason == null)
                {
                    var service = financial.Connectors.Where(o => o.BSI__Clinic_Services.Is_Part != true).First().BSI__Clinic_Services;

                    return service.Unit_Standard_Value;
                }
                else
                {
                    return null;
                }
            }
        }
Пример #25
0
 public static void RemoveConnectorObjectUsingFinancialId(
     long? Financial,
     SharedClass.RelationType RelationType
     )
 {
     using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
     {
         string relation = SharedClass.GetRelationType(RelationType);
         var connectorToRemove = mc.Connectors.Where(o => o.FinancialId == Financial && o.RelationType == relation).ToList();
         if (connectorToRemove.Count() != 0)
         {
             mc.Connectors.RemoveRange(connectorToRemove);
             mc.SaveChanges();
         }
     }
 }
Пример #26
0
        public static string GetUnitName(long? FinancialId)
        {
            using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
            {
                var financial = mc.Petient_Visiting_Financials.Where(o => o.Id == FinancialId).First();

                if (financial.Reason == null)
                {
                    var service = financial.Connectors.Where(o => o.BSI__Clinic_Services.Is_Part != true).First().BSI__Clinic_Services;

                    return service.Unit_Name;
                }
                else
                {
                    return null;
                }
            }
        }
Пример #27
0
        public static string GetTitleOfFile(
            long? FileId,
            long? FinancialId
            )
        {
            using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
            {
                if (FinancialId != null)
                {
                    var financial = mc.Petient_Visiting_Financials.Where(o => o.Id == FinancialId).First();

                    if (financial.Reason == null)
                    {
                        var service = financial.Connectors.Where(o => o.BSI__Clinic_Services.Is_Part != true).First();
                        var parts = financial.Connectors.Where(o => o.BSI__Clinic_Services != null && o.BSI__Clinic_Services.Is_Part == true)
                            .GroupBy(o => o.BSI__Clinic_Services.Service_Name).Select(o => o.First()).ToList();

                        var serviceName = service.BSI__Clinic_Services.Service_Name;

                        if (parts.Count() != 0)
                        {
                            serviceName += " : ";
                            foreach (var part in parts)
                            {
                                serviceName += part.BSI__Clinic_Services.Service_Name;
                                serviceName += "، ";
                            }
                        }
                        return serviceName;
                    }
                    else
                    {
                        return financial.Reason;
                    }
                }
                else if (FileId != null)
                {
                    var file = mc.Petient_Files.Where(o => o.Id == FileId).First();

                    if (file.Reason == null)
                    {
                        var service = file.Connectors.Where(o => o.BSI__Clinic_Services != null && o.BSI__Clinic_Services.Is_Part != true).FirstOrDefault();
                        var parts = file.Connectors.Where(o => o.BSI__Clinic_Services != null && o.BSI__Clinic_Services.Is_Part == true)
                            .GroupBy(o => o.BSI__Clinic_Services.Service_Name).Select(o => o.First()).ToList();

                        var serviceName = service.BSI__Clinic_Services.Service_Name;

                        if (parts.Count() != 0)
                        {
                            serviceName += " : ";
                            foreach (var part in parts)
                            {
                                serviceName += part.BSI__Clinic_Services.Service_Name;
                                serviceName += "، ";
                            }
                        }
                        return serviceName;
                    }
                    else
                    {
                        return file.Reason;
                    }
                }
            }
            return "";
        }
Пример #28
0
        public static List<BSI__Clinic_Service> GetServicesOfFinancial(long? FinancialId)
        {
            using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
            {
                var services = new List<BSI__Clinic_Service>();

                var financial = mc.Petient_Visiting_Financials.Where(o => o.Id == FinancialId).First();

                if (financial.Reason == null)
                {
                    var service = financial.Connectors.Where(o => o.BSI__Clinic_Services.Is_Part != true).First().BSI__Clinic_Services;
                    var parts = financial.Connectors.Where(o => o.BSI__Clinic_Services != null && o.BSI__Clinic_Services.Is_Part == true)
                        .GroupBy(o => o.BSI__Clinic_Services.Service_Name).Select(o => o.First().BSI__Clinic_Services).ToList();
                    services.Add(service);
                    services.AddRange(parts);

                    return services;
                }
                else
                {
                    return null;
                }
            }
        }
Пример #29
0
        public static int? GetSelectedServiceEmployee(int? serviceId, string employeeId)
        {
            int othersValue = -1;

            using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
            {
                if (serviceId == null || serviceId == othersValue)
                {
                    return null;
                }
                else
                {
                    var employee = mc.BSI__Employee_Service_Set.Where(o => o.Service_Id == serviceId && o.Employee_Id == employeeId && o.BSI__Clinic_Employees.Is_Active == true);

                    if (employee.Count() != 0)
                    {
                        return employee.First().Id;
                    }
                    else
                    {
                        return null;
                    }
                }
            }
        }
Пример #30
0
        public static List<Petient_File> GetPetientFiles(
            Guid PetientId,
            long? FinancialId,
            out bool HasFinancialOneFile
            )
        {
            HasFinancialOneFile = false;

            using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
            {
                List<Connector> connectors = mc.Petients.Where(o => o.Id == PetientId).First().Connectors.ToList(); ;
                if (FinancialId != null)
                {
                    if (connectors.Where(o => o.FinancialId == FinancialId && o.PetientId == PetientId && o.FileId != null).Count() != 0)
                    {
                        HasFinancialOneFile = true;
                    }

                    var currentFinancialFile = mc.Petient_Visiting_Financials.Where(o => o.Id == FinancialId).First();
                    connectors = connectors.Where(o => o.Petient_Visiting_Financials != null)
                        .Where(o => o.Petient_Visiting_Financials.TimeVisitStarts <= currentFinancialFile.TimeVisitStarts).ToList();
                }
                return connectors.Where(o => o.PetientId == PetientId && o.FileId != null).Select(o => o.Petient_Files).Distinct().ToList();
            }
        }