Beispiel #1
0
        public async Task <ActionResult <Visiting> > PostVisiting(Visiting visiting)
        {
            _context.Visitings.Add(visiting);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetVisiting), new { id = visiting.VisitingID }, visiting));
        }
        public ActionResult AddVisiting(int id, Visiting visiting)
        {
            try
            {
                //var str = "01.01.0001 0:00:00";
                //DateTime date;
                //DateTime.TryParse(str, out date);
                //if (visiting.date == date)
                //{
                //    ModelState.AddModelError("classesTotal", "Введите кол-во занятий");
                //}

                visiting.idSeasonTicket = id;
                if (ModelState.IsValid)
                {
                    db.Visiting.Add(visiting);
                    db.SaveChanges();
                    return(RedirectToAction("EditSeasonTicket", new { id }));
                }
                else
                {
                    return(View(visiting));
                }
            }
            catch (Exception)
            {
                return(View());
            }
        }
Beispiel #3
0
        void Visit(Action <List <Node>, Node> incrementor, Func <Node, bool> nodeSelector, Func <Edge, bool> edgeSelector)
        {
            List <Node> _entitiesToVisit = new List <Node>(graph.Roots(nodeSelector, edgeSelector));

            while (_entitiesToVisit.Any( ))
            {
                Node _current = _entitiesToVisit.First( );
                _entitiesToVisit.Remove(_current);
                if (nodeSelector(_current))
                {
                    if (GetTouchCountOf(_current) == 0)
                    {
                        ShowUp.Raise(this, new EventArgs <Node>(_current));
                    }
                    if (GetTouchCountOf(_current) == 1)
                    {
                        PassOff.Raise(this, new EventArgs <Node>(_current));
                    }
                    if (GetTouchCountOf(_current) == 0)
                    {
                        incrementor(_entitiesToVisit, _current);
                    }
                    Visiting.Raise(this, new EventArgs <Node>(_current));
                }
            }
        }
Beispiel #4
0
        public async Task <IActionResult> PutVisiting(int id, Visiting visiting)
        {
            if (id != visiting.VisitingID)
            {
                return(BadRequest());
            }

            _context.Entry(visiting).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VisitingExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var visitingRepository = new SqlVisitingRepository(frmGymManager.connectionString);
            var visit = new Visiting();

            if (dgvAddVisit.CurrentRow.Cells[0].Value != null && dgvAddVisit.CurrentRow.Cells[1].Value != null)
            {
                visit.CardNumber = Convert.ToInt32(dgvAddVisit.CurrentRow.Cells[0].Value);
                visit.KeyNumber  = Convert.ToInt32(dgvAddVisit.CurrentRow.Cells[1].Value);

                if (visitingRepository.InsertNewVisit(visit) > 0)
                {
                    MessageBox.Show("Successfull operation", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Try Again", "Allert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("Enter data!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #6
0
        public int Evaluate(Individual individual, bool print = false)
        {
            IEnumerable <Visiting> sortedVisitings = individual.Visitings.OrderBy(v => v.Weight);
            int      total         = 0;
            Visiting previousVisit = null;

            foreach (Visiting currentVisit in sortedVisitings)
            {
                if (previousVisit != null)
                {
                    int v1 = previousVisit.Vertex;
                    int v2 = currentVisit.Vertex;
                    total += this.GetEdge(v1, v2).Weight;
                }
                previousVisit = currentVisit;
            }

            if (print)
            {
                IEnumerable <string> sortedNames = sortedVisitings
                                                   .Select(visiting => this.NameOf(visiting.Vertex));
                Console.WriteLine(String.Join(" => ", sortedNames) + $": {total}");
            }

            return(total);
        }
Beispiel #7
0
        /// <summary>
        /// Visits a single node.
        /// </summary>
        /// <param name="node">The node being visited.</param>
        /// <remarks>This method is in charge of pursuing the visit with the children and references of the given node, as well as raising the <see cref="Visiting"/> event.</remarks>
        protected virtual void VisitNode([NotNull] IGraphNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }
            visitedNodes.Add(node);
            if (node != RootNode || !SkipRootNode)
            {
                Visiting?.Invoke(node, CurrentPath);
            }
            var objectNode = node as IObjectNode;

            if (objectNode != null)
            {
                VisitChildren(objectNode);
                VisitItemTargets(objectNode);
            }
            var memberNode = node as IMemberNode;

            if (memberNode != null)
            {
                VisitMemberTarget(memberNode);
            }
            visitedNodes.Remove(node);
        }
Beispiel #8
0
 /// <summary>
 /// Visits a single node.
 /// </summary>
 /// <param name="node">The node being visited.</param>
 /// <param name="currentPath">The path of the node being visited.</param>
 /// <remarks>This method is in charge of pursuing the visit with the children and references of the given node, as well as raising the <see cref="Visiting"/> event.</remarks>
 protected virtual void VisitNode(IGraphNode node, GraphNodePath currentPath)
 {
     visitedNodes.Add(node);
     if (node != RootNode || !SkipRootNode)
     {
         Visiting?.Invoke(node, currentPath);
     }
     VisitChildren(node, currentPath);
     VisitSingleTarget(node, currentPath);
     VisitEnumerableTargets(node, currentPath);
     visitedNodes.Remove(node);
 }
Beispiel #9
0
        public async Task <JsonResult> AddVisiting(Visiting Visiting)
        {
            int result = 0;

            if (Visiting.Id > 0)
            {
                result = await _service.UpdateVisit(Visiting);
            }
            else if (Visiting.Id == 0)
            {
                result = await _service.AddVisit(Visiting);
            }
            return(Json(result));
        }
Beispiel #10
0
        public async Task<int> AddVisit(Visiting Visiting)
        {
            var rowsAffected = 0;
            try
            {
                using (_context)
                {
                    rowsAffected = await _context.Database.ExecuteSqlInterpolatedAsync($"EXEC SpAddVisiting @Description={Visiting.Description}, @VisitDate={Visiting.VisitDate}, @NotifyByEmail={Visiting.NotifyByEmail}, @CustomerId={Visiting.CustomerId}");
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return rowsAffected;
        }
        /// <summary>
        /// Insert information about new visit, user identify by his Card Number.
        /// In Date visit write today date auto.
        /// </summary>
        public int InsertNewVisit(Visiting obj)
        {
            using (var connection = new SqlConnection(ConnectionString))
            {
                connection.Open();

                using (var command = new SqlCommand("spAddNewVisit", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@CardNumber", obj.CardNumber);
                    command.Parameters.AddWithValue("@KeyNumber", obj.KeyNumber);
                    var resultValue = command.Parameters.Add("@Result", SqlDbType.Int);
                    resultValue.Direction = ParameterDirection.ReturnValue;
                    command.ExecuteNonQuery();
                    return((int)command.Parameters["@Result"].Value);
                }
            }
        }
Beispiel #12
0
        /// <summary>
        /// 确定增加来访信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            //来访时间
            DateTime dtAccommodationtime = new DateTime(1900, 1, 1);

            if (txtVisitingTime.Text.Trim() != "")
            {
                if (!DateTime.TryParse(txtVisitingTime.Text.Trim(), out dtAccommodationtime))
                {
                    CommonFuncs.ShowMsg(this.Page, "来访时间格式不正确,请改正");
                    txtVisitingTime.Focus();
                    return;
                }
            }

            //离开时间
            DateTime dtleavetime = new DateTime(1900, 1, 1);

            if (txtLikaiTime.Text.Trim() != "")
            {
                if (!DateTime.TryParse(txtLikaiTime.Text.Trim(), out dtleavetime))
                {
                    CommonFuncs.ShowMsg(this.Page, "离开时间格式不正确,请改正");
                    txtLikaiTime.Focus();
                    return;
                }
            }

            Visiting vi = new Visiting();

            vi.dormitoryID  = int.Parse(drtxtVist.SelectedItem.Value);
            vi.VisitingName = txtVisitingName.Text.Trim();
            vi.VisitingTime = DateTime.Parse(txtVisitingTime.Text.Trim());
            vi.LikaiTime    = DateTime.Parse(txtLikaiTime.Text.Trim());

            if (new VisitingBLL().InsertVisitingBLL(vi) == 1)
            {
                CommonFuncs.ShowMsg(this.Page, "添加来访信息成功");
            }
            else
            {
                CommonFuncs.ShowMsg(this.Page, "添加来访信息失败!\\n\\n请检查各个输入是否合法,\\n来访信息ID是否已经存在,\\n或者请管理员查看系统日志。");
            }
        }
Beispiel #13
0
 public void Edit(Visiting visiting)
 {
     if (visiting != null)
     {
         using (var transaction = _db.Database.BeginTransaction())
         {
             try
             {
                 _db.Entry(visiting).State = EntityState.Modified;
                 _db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception)
             {
                 transaction.Rollback();
                 throw;
             }
         }
     }
 }
Beispiel #14
0
        public async Task <IActionResult> MarkVisiting([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var client = context.Clients.Find(id);

            if (client == null)
            {
                return(NotFound());
            }

            var lastVisiting = client.Visitings.LastOrDefault();

            if (lastVisiting != null && lastVisiting.FinishTime == null)
            {
                client.Visitings.LastOrDefault().FinishTime = client.Visitings.LastOrDefault().StartTime.Date.AddHours(23);
            }

            Visiting visiting = new Visiting
            {
                StartTime  = DateTime.Now,
                FinishTime = null
            };


            client.Visitings.Add(visiting);

            context.Update(client);
            try
            {
                await context.SaveChangesAsync();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(Ok());
        }
    static void Main()
    {
        List <CanGreet> greeters = new List <CanGreet>();

        greeters.Add(new Teacher("MH", new DateTime(1971, 12, 7), "Programming Languages"));
        greeters.Add(new Teacher("JY", new DateTime(1975, 9, 21), "Forbidden Archeology"));
        greeters.Add(new Student("YK", new DateTime(1999, 3, 16), 2051));
        greeters.Add(new Student("SH", new DateTime(2000, 10, 5), 4968));

        CanGreet Alice = new Visiting("Alice", new DateTime(1995, 7, 14), 9595,
                                      new DateTime(2019, 12, 25));
        CanGreet Vanessa = new Visiting("Vanessa", new DateTime(1998, 3, 27), 9598,
                                        new DateTime(2019, 2, 28));

        greeters.Add(Alice);
        greeters.Add(Vanessa);

        Console.WriteLine("A few CAU members...");
        foreach (CanGreet greeter in greeters)
        {
            Console.WriteLine(greeter.Greet());
        }
        Console.WriteLine();

        greeters.Sort(new AgeSorter());
        Console.WriteLine("Members sorted on age...");
        foreach (CanGreet greeter in greeters)
        {
            Console.WriteLine(greeter.Greet());
        }
        Console.WriteLine();

        greeters.Sort(new ReverseNameSorter());
        Console.WriteLine("Members reverse sorted on name...");
        foreach (CanGreet greeter in greeters)
        {
            Console.WriteLine(greeter.Greet());
        }
    }
        /// <summary>
        /// Get information about visits what use the selected Key.
        /// </summary>
        public IEnumerable <Visiting> GetVisitsByKeyNumber(Visiting obj)
        {
            using (var connection = new SqlConnection(ConnectionString))
            {
                connection.Open();

                using (var command = new SqlCommand("spGetVisitsByKeyNumber", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@KeyNumber", obj.KeyNumber);

                    var visitsList = new List <Visiting>();

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            visitsList.Add(new Visiting
                            {
                                CardNumber = reader["CardNumber"] is DBNull
                            ? 0
                            : (int)reader["CardNumber"],

                                KeyNumber = reader["KeyNumber"] is DBNull
                            ? 0
                            : (int)reader["KeyNumber"],

                                DateVisit = reader["DateVisit"] is DBNull
                            ? "01/01/1753"
                            : reader["DateVisit"].ToString().Remove(10)
                            });
                        }
                    }
                    return(visitsList);
                }
            }
        }
Beispiel #17
0
 public void Add(Visiting visiting)
 {
     _db.Visiting.Add(visiting);
     _db.SaveChanges();
 }
Beispiel #18
0
        public MedRecordOpenViewModel(MedRecord medRecord, Employee employee)
        {
            currentMedRecord = medRecord;
            currentEmployee  = employee;

            DownloadXrays(medRecord);
            DownloadVisiting(medRecord);
            Diagnosings = DiagnosisViewModel.DiagnosisTake();
            Medicaments = MedicamentViewModel.MedicamentsTake();

            EditXrays = new DelegateCommand(() =>
            {
                editoradd = false;

                selectedXrays?.BeginEdit();
                var w         = new XraysEdit();
                w.DataContext = this;
                w.ShowDialog();
            }, () => selectedXrays != null);


            AddXrays = new DelegateCommand(() =>
            {
                editoradd = true;

                Xrays xrays   = new Xrays();
                SelectedXrays = xrays;

                var w         = new XraysEdit();
                w.DataContext = this;
                w.Show();
            });

            SaveXrays = new DelegateCommand(() =>
            {
                if (editoradd == true)
                {
                    selectedXrays.IdMedRecord = currentMedRecord.Id;

                    context.Xrays.Add(selectedXrays);

                    context.SaveChanges();

                    Photos.Add(SelectedXrays);
                }
                else
                {
                    context.Entry(selectedXrays).State = EntityState.Modified;
                    context.SaveChanges();
                }
            }, () => selectedXrays.Photo != null);

            RemoveXrays = new DelegateCommand(() =>
            {
                if (MessageBox.Show("Удалить?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    context.Entry(selectedXrays).State = EntityState.Deleted;
                    Photos.Remove(selectedXrays);
                    context.SaveChanges();
                }
                else
                {
                    return;
                }
            }, () => selectedXrays != null);

            CanselXrays = new DelegateCommand(() =>
            {
                if (editoradd == false)
                {
                    if (selectedXrays == null)
                    {
                        return;
                    }
                    SelectedXrays.CancelEdit();
                }
                else
                {
                    return;
                }
            });

            AddImage = new DelegateCommand(() =>
            {
                OpenFileDialog dlg   = new OpenFileDialog();
                dlg.InitialDirectory = "";
                dlg.Filter           = "Image files (*.jpg,*.png,*.bmp)|*.jpg;*.png;*.bmp|All Files (*.*)|*.*";
                if (dlg.ShowDialog() == true)
                {
                    string selectedFileName = dlg.FileName;
                    selectedXrays.Photo     = ConvertImageToByteArray(selectedFileName);
                    SaveXrays.RaiseCanExecuteChanged();
                }
            });

            #region Visiting

            EditVisiting = new DelegateCommand(() =>
            {
                editoradd = false;

                var w         = new VisitingEdit();
                w.DataContext = this;
                w.ShowDialog();
            }, () => selectedVisiting != null);


            AddVisiting = new DelegateCommand(() =>
            {
                editoradd = true;

                Visiting visiting = new Visiting();
                SelectedVisiting  = visiting;

                var w         = new VisitingEdit();
                w.DataContext = this;
                w.Show();
            });

            SaveVisiting = new DelegateCommand(() =>
            {
                if (editoradd == true)
                {
                    selectedVisiting.IDEmployee  = currentEmployee.Id;
                    selectedVisiting.IDMedRecord = currentMedRecord.Id;

                    currentMedRecord  = context.MedRecord.Find(currentMedRecord.Id);
                    currentEmployee   = context.Employee.Find(currentEmployee.Id);
                    currentMedicament = context.Medicament.Find(selectedVisiting.IDMedicament);
                    currentDiagnosis  = context.Diagnosis.Find(selectedVisiting.IDDiagnosis);
                    //Diagnosings = DiagnosisViewModel.DiagnosisTake();
                    //Medicaments = MedicamentViewModel.MedicamentsTake();

                    context.Visiting.Add(selectedVisiting);

                    context.SaveChanges();

                    Visitings.Add(SelectedVisiting);
                }
                else
                {
                    currentMedRecord  = context.MedRecord.Find(currentMedRecord.Id);
                    currentEmployee   = context.Employee.Find(currentEmployee.Id);
                    currentMedicament = context.Medicament.Find(selectedVisiting.IDMedicament);
                    currentDiagnosis  = context.Diagnosis.Find(selectedVisiting.IDDiagnosis);

                    context.Entry(selectedVisiting).State = EntityState.Modified;
                    context.SaveChanges();
                }
            });


            RemoveVisiting = new DelegateCommand(() =>
            {
                if (MessageBox.Show("Удалить?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    context.Entry(selectedVisiting).State = EntityState.Deleted;
                    Visitings.Remove(selectedVisiting);
                    context.SaveChanges();
                }
                else
                {
                    return;
                }
            }, () => selectedVisiting != null);

            CanselVisiting = new DelegateCommand(() =>
            {
                if (editoradd == false)
                {
                    if (selectedVisiting == null)
                    {
                        return;
                    }
                    SelectedVisiting.CancelEdit();
                }
                else
                {
                    return;
                }
            });

            ExportVisiting = new DelegateCommand(() =>
            {
                try
                {
                    Microsoft.Office.Interop.Excel.Application exApp = new Microsoft.Office.Interop.Excel.Application();

                    Workbook workbook = exApp.Workbooks.Add(Type.Missing);

                    Worksheet workSheet = (Worksheet)exApp.ActiveSheet;

                    workSheet.Cells[1, 1] = "ФИО пациента";
                    workSheet.Cells[1, 2] = "ФИО врача";
                    workSheet.Cells[1, 3] = "Дата";
                    workSheet.Cells[1, 4] = "Жалобы";
                    workSheet.Cells[1, 5] = "Начало болезни";
                    workSheet.Cells[1, 6] = "Текущее состояние";
                    workSheet.Cells[1, 7] = "Дополнительно";
                    workSheet.Cells[1, 8] = "Медикамент";
                    workSheet.Cells[1, 9] = "Диагноз";

                    int rowExcel = 2;

                    foreach (var item in Visitings)
                    {
                        workSheet.Cells[rowExcel, "A"] = item.MedRecord.Surname + item.MedRecord.Name + item.MedRecord.Patronymic;
                        workSheet.Cells[rowExcel, "B"] = item.Employee.Surname + item.Employee.Name + item.Employee.Patronymic;
                        workSheet.Cells[rowExcel, "C"] = item.Date;
                        workSheet.Cells[rowExcel, "D"] = item.Complaints;
                        workSheet.Cells[rowExcel, "E"] = item.StartDisease;
                        workSheet.Cells[rowExcel, "F"] = item.StatePraesens;
                        workSheet.Cells[rowExcel, "G"] = item.Additionally;
                        workSheet.Cells[rowExcel, "H"] = item.Medicament.Name;
                        workSheet.Cells[rowExcel, "I"] = item.Diagnosis.Name;

                        ++rowExcel;
                    }

                    //workbook.Close();
                    exApp.Quit();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(exApp);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Ошибка записи в Excel");
                }
            });
            #endregion
        }
Beispiel #19
0
        private int TraverseForwardCalculatingPeriodIterative2(
            DelayGraphVertex startingVertex, out bool foundCycle)
        {
            Stack <PeriodTraverseState> stack = new Stack <PeriodTraverseState>();

            stack.Push(new PeriodTraverseState(startingVertex));

            PeriodTraverseState currentState = null;

            foundCycle = false;
            while (stack.Any())
            {
                currentState = stack.Peek();

                int alreadyComputedDelay = 0;
                if (ComputedDelays.TryGetValue(currentState.Vertex, out alreadyComputedDelay)) // put in for reconvergent paths
                {
                    currentState.DelayReturned = alreadyComputedDelay;
                    stack.Pop();
                    continue;
                }
                if (currentState.StateWaitingOn == null)        // this state is used here just to tell if we are coming along here b/c we need to attend to unfinished business where we might have already set 'visited'
                {
                    if (Visiting.Contains(currentState.Vertex)) // stop recursing if we're going along a loop, but still add up the delays of the loop
                    {
                        currentState.DelayReturned = 0;
                        foundCycle = true;
                        stack.Pop();
                        continue;
                    }
                    Visiting.Add(currentState.Vertex);
                }
                if (currentState.UnfinishedEdges == null)
                {
                    IEnumerable <DelayGraphEdge> foundOutgoingEdges;
                    if (Graph.TryGetOutEdges(currentState.Vertex, out foundOutgoingEdges))
                    {
                        currentState.UnfinishedEdges = new Queue <DelayGraphEdge>(foundOutgoingEdges);
                    }
                }
                bool done = true;
                while (currentState.UnfinishedEdges != null && currentState.UnfinishedEdges.Any())
                {
                    var outEdge = currentState.UnfinishedEdges.Peek();
                    int delayOnThisPath;
                    if (Registered(outEdge.Target)) // stop recursing when we hit a register
                    {
                        delayOnThisPath = outEdge.Delay;
                    }
                    else if (Visiting.Contains(outEdge.Target))
                    {
                        // found a cycle
                        foundCycle      = true;
                        delayOnThisPath = outEdge.Delay;
                    }
                    else
                    {
                        if (currentState.StateWaitingOn == null)
                        {
                            currentState.StateWaitingOn = new PeriodTraverseState(outEdge.Target);
                            stack.Push(currentState.StateWaitingOn);
                            done = false; // need to process what we just pushed
                            break;
                        }
                        else
                        {
                            delayOnThisPath             = outEdge.Delay + currentState.StateWaitingOn.DelayReturned;
                            currentState.StateWaitingOn = null;
                        }
                    }
                    currentState.UnfinishedEdges.Dequeue();
                    currentState.MaxAmongOutgoingEdges = Math.Max(currentState.MaxAmongOutgoingEdges, delayOnThisPath);
                }
                if (done)
                {
                    ComputedDelays[currentState.Vertex] = currentState.MaxAmongOutgoingEdges;
                    currentState.DelayReturned          = currentState.MaxAmongOutgoingEdges;
                    Visiting.Remove(currentState.Vertex);
                    stack.Pop();
                }
            }
            return(currentState.DelayReturned);
        }