Exemplo n.º 1
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);
             }
         }
     }
 }
Exemplo n.º 2
0
        private void makeChild(TreeNode currentNode, BSI__Clinic_Service service)
        {
            using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
            {
                TreeNode newNode = new TreeNode(service.Service_Name, service.Id.ToString());

                if (service.Is_Part == true && searchMode == true)
                {
                    return;
                }

                currentNode.ChildNodes.Add(newNode);

                if (managementMode == false)
                {
                    if (SharedClass.IsUserAdminOrOperator(SharedClass.CurrentUser) != true)
                    {
                        var employeeService = mc.BSI__Employee_Service_Set.Where(o => o.Service_Id == service.Id && o.Employee_Id == SharedClass.CurrentUser).ToList();

                        if (employeeService.Count() != 0)
                        {
                            if (service.Is_Part == true)
                            {
                                newNode.SelectAction = TreeNodeSelectAction.None;
                                if (
                                       selectedService != null
                                    && selectedService == currentNode.Value
                                    )
                                {
                                    newNode.ShowCheckBox = true;
                                }
                                else
                                {
                                    newNode.ShowCheckBox = false;
                                }
                            }
                            else
                            {
                                newNode.SelectAction = TreeNodeSelectAction.Select;

                                newNode.Expand();
                                var parent = newNode.Parent;
                                while (parent != null)
                                {
                                    parent.Expand();
                                    parent = parent.Parent;
                                }
                            }
                        }
                        else
                        {
                            newNode.SelectAction = TreeNodeSelectAction.None;
                        }
                    }
                    else
                    {
                        if (service.Is_Part == true)
                        {
                            newNode.SelectAction = TreeNodeSelectAction.None;
                            if (
                                       selectedService != null
                                    && selectedService == currentNode.Value
                                    )
                            {
                                newNode.ShowCheckBox = true;
                            }
                            else
                            {
                                newNode.ShowCheckBox = false;
                            }
                        }
                        else
                        {
                            newNode.SelectAction = TreeNodeSelectAction.Select;
                        }
                        isExpanded = false;
                    }
                }
                else
                {
                    newNode.SelectAction = TreeNodeSelectAction.Select;
                }

                foreach (var child in mc.BSI__Clinic_Services.Where(o => o.Parent_Id == service.Id).ToList())
                {
                    makeChild(newNode, child);
                }
            }
        }
Exemplo n.º 3
0
 private void deleteChild(BSI__Clinic_Service service)
 {
     foreach (var child in service.BSI__Clinic_Services_Child)
     {
         deleteChild(child);
     }
     servicesToDelete.Add(service);
 }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities())
            {
                if (txtServiceName.Text == ucServicesControl.RootName || txtServiceName.Text == ucServicesControl.OthersName)
                {
                    return;
                }
                BSI__Clinic_Service service = new BSI__Clinic_Service();
                service.Service_Name = txtServiceName.Text;
                service.Cost = int.Parse(txtCost.Text);
                service.Doctor_Base = radioDoctor.Checked;
                service.Tech_Base = radioTech.Checked;
                service.Is_Part = chkIsPart.Checked;
                var parentList = mc.BSI__Clinic_Services.Where(o => o.Id == ucServicesControl.SelectedService).ToList();
                if (parentList.Count() != 0)
                {
                    if (parentList.First().Is_Part == true) //ERROR: Part can't be parent.
                    {
                        //TODO: Return error
                        return;
                    }
                    service.BSI__Clinic_Services_Parent = parentList.First();
                }
                else if(parentList.Count() == 0 && chkIsPart.Checked == true) //ERROR: Part can't be in root.
                {
                    //TODO: Return error
                    return;
                }
                else
                {
                    service.BSI__Clinic_Services_Parent = null;
                }

                if(chkIsPart.Checked != true) //A part service inherate its parent's Unit_Name
                {
                    if(service.Unit_Name == "")
                    {
                        service.Unit_Name = null;
                    }
                    else
                    {
                        service.Unit_Name = ddlUnit.Text;
                    }
                }
                else
                {
                    service.Unit_Name = service.BSI__Clinic_Services_Parent.Unit_Name;
                }

                if(service.Unit_Name != null)
                {
                    service.Unit_Standard_Value = short.Parse(txtUnitStandardValue.Text);
                }
                else
                {
                    service.Unit_Standard_Value = null;
                }

                mc.BSI__Clinic_Services.Add(service);

                if (chkIsPart.Checked == true)
                {
                    addNewPartToEmployeesOfService(mc, service.Id, parentList.First().Id);
                }

                mc.SaveChanges();
            }

            pageReset();

            ucServicesControl.MakeTree();
        }