Пример #1
0
        private void bNew_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            frmPatient frm = new frmPatient();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                Patient p = new Patient();
                p.ID             = frm.ID;
                p.PatientName    = frm.PatientName;
                p.Sex            = frm.Sex;
                p.DateOfBirth    = frm.DateOfBirth;
                p.PhoneNo        = frm.PhoneNo;
                p.Address        = frm.Address;
                p.Comments       = frm.Comments;
                p.MedicalHistory = frm.MedicalHistory;

                ServerToClient sc = new ServerToClient();
                PatientContext px = new PatientContext();
                sc = px.AddPatient(p);

                if (sc.Message == null)
                {
                    //LoadPatients();
                    //luePTN.EditValue = sc.Count;
                    XtraMessageBox.Show("New patient added successfully!");
                }
                else
                {
                    XtraMessageBox.Show(sc.Message);
                }
            }
        }
Пример #2
0
        private void luePTN_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            if (e.Button.Index == 1)
            {
                frmPatient frm = new frmPatient();
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    Patient p = new Patient();
                    p.ID             = frm.ID;
                    p.PatientName    = frm.PatientName;
                    p.Sex            = frm.Sex;
                    p.DateOfBirth    = frm.DateOfBirth;
                    p.PhoneNo        = frm.PhoneNo;
                    p.Address        = frm.Address;
                    p.Comments       = frm.Comments;
                    p.MedicalHistory = frm.MedicalHistory;

                    ServerToClient sc = new ServerToClient();
                    PatientContext px = new PatientContext();
                    sc = px.AddPatient(p);

                    if (sc.Message == null)
                    {
                        LoadPatients();
                        luePTN.EditValue = sc.Count;
                    }
                    else
                    {
                        XtraMessageBox.Show(sc.Message);
                    }
                }
            }
        }
Пример #3
0
        private void ShowData()
        {
            DateTime dtFR = DateTime.Parse(beiFR.EditValue.ToString());
            DateTime dtTO = DateTime.Parse(beiTO.EditValue.ToString());

            sc = tx.OverallView(dtFR, dtTO);

            grd.DataSource = sc.DT;
        }
Пример #4
0
        private void LoadPatients()
        {
            ServerToClient sc = new ServerToClient();
            PatientContext px = new PatientContext();

            sc = px.GetPatients();
            luePTN.Properties.DataSource    = sc.DT;
            luePTN.Properties.DisplayMember = "PatientName";
            luePTN.Properties.ValueMember   = "ID";
        }
Пример #5
0
        internal EventRouter()
        {
            ClientToServerCallbacks = new Dictionary <string, List <Action <NetworkPlayer, string> > >();
            ServerToClientCallbacks = new Dictionary <string, List <Action <NetworkPlayer, string> > >();
            BroadcastAllCallbacks   = new Dictionary <string, List <Action <NetworkPlayer, string> > >();

            ClientToServer.Subscribe(ClientToServerEventReceived);
            ServerToClient.Subscribe(ServerToClientEventReceived);
            BroadcastAll.Subscribe(BroadcastAllEventReceived);
        }
Пример #6
0
        TreatmentContext tx; // = new TreatmentContext();

        public ucOverallView()
        {
            InitializeComponent();

            sc = new ServerToClient();
            tx = new TreatmentContext();

            beiFR.EditValue = DateTime.Now;
            beiTO.EditValue = DateTime.Now;

            ShowData();
        }
Пример #7
0
        private void grv_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            string         pid = grv.GetFocusedRowCellValue(colPID).ToString();
            ServerToClient sc  = new ServerToClient();
            PatientContext px  = new PatientContext();

            sc = px.GetTreatments(pid);

            grdT.DataSource = sc.DT;

            grvT_FocusedRowChanged(null, null);
        }
Пример #8
0
 void LoadPatients()
 {
     sc             = new ServerToClient();
     px             = new PatientContext();
     sc             = px.GetPatients();
     grd.DataSource = sc.DT;
     if (grv.RowCount <= 0)
     {
         bEdit.Enabled = false;
         bDel.Enabled  = false;
     }
     else
     {
         bEdit.Enabled = true;
         bDel.Enabled  = true;
     }
 }
Пример #9
0
 private void Button_Save(object sender, RoutedEventArgs e)
 {
     try
     {
         Play        play = new Play();
         MCFunctions cf   = new MCFunctions();
         play.Title     = PlayTitle.Text;
         play.DateStart = DateStart.SelectedDate.Value.Date.ToShortDateString();
         play.DateEnd   = DateEnd.SelectedDate.Value.Date.ToShortDateString();
         play.Days      = cf.CheckboxDayReturn(Day0.IsChecked.Value,
                                               Day1.IsChecked.Value,
                                               Day2.IsChecked.Value,
                                               Day3.IsChecked.Value,
                                               Day4.IsChecked.Value,
                                               Day5.IsChecked.Value,
                                               Day6.IsChecked.Value,
                                               Day7.IsChecked.Value);
         play.Time = cf.CheckboxTimeReturn(Time0.IsChecked.Value,
                                           Time1.IsChecked.Value,
                                           Time2.IsChecked.Value,
                                           Time3.IsChecked.Value,
                                           Time4.IsChecked.Value);
         play.Prices = cf.PricesStringReturn(Price0.Text, Price1.Text, Price2.Text);
         if (PlayTitle.Text.Length == 0 || Price0.Text.Length == 0 || Price1.Text.Length == 0 || Price2.Text.Length == 0)
         {
             MessageBox.Show("Fill empty elements");
         }
         else
         {
             ServerToClient stc = (ServerToClient)Activator.GetObject(typeof(ServerToClient),
                                                                      "tcp://localhost:9090/ServerToClient",
                                                                      WellKnownObjectMode.Singleton);
             stc.SavePlayFromClient(play, Login.name);
             MessageBox.Show("Play has been succesfully added");
             var newform = new Manager();
             newform.Show();
             this.Close();
         }
     }
     catch (Exception b)
     {
         MessageBox.Show(b.Message);
     }
 }
Пример #10
0
 private void bDel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (XtraMessageBox.Show("Are you sure you want to delete this patient record?", "Confirm delete", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         string         pid = grv.GetFocusedRowCellValue(colPID).ToString();
         ServerToClient sc  = new ServerToClient();
         PatientContext px  = new PatientContext();
         sc = px.DeletePatient(pid);
         if (sc.Message == null)
         {
             XtraMessageBox.Show("Patient ID " + pid + " deleted successfully!");
             LoadPatients();
         }
         else
         {
             XtraMessageBox.Show(sc.Message);
         }
     }
 }
Пример #11
0
        protected override void Update(GameTime gameTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            if (localControls != previousControls)
            {
                NetOutgoingMessage om = client.CreateMessage();
                om.Write((byte)ClientToServer.UpdateControls);
                EncodeControls(om, localControls);
                client.SendMessage(om, NetDeliveryMethod.ReliableOrdered);
            }
            previousControls.AssignValues(localControls);

            NetIncomingMessage msg;

            while ((msg = client.ReadMessage()) != null)
            {
                switch (msg.MessageType)
                {
                case NetIncomingMessageType.VerboseDebugMessage:
                case NetIncomingMessageType.DebugMessage:
                case NetIncomingMessageType.WarningMessage:
                case NetIncomingMessageType.ErrorMessage:
                    Console.WriteLine(msg.ReadString());
                    break;

                case NetIncomingMessageType.StatusChanged:
                    break;

                case NetIncomingMessageType.Data:
                    ServerToClient type = (ServerToClient)msg.ReadByte();
                    switch (type)
                    {
                    case ServerToClient.NewPlayers:
                    {
                        Console.WriteLine("Received new players");
                        // Read number of players
                        int n = msg.ReadInt32();
                        Console.WriteLine(n);
                        // Parse the n players and add them to the game
                        for (int i = 0; i < n; i++)
                        {
                            Controls c  = new Controls();
                            Player   p  = new Player(c, 32, Color.Red, false, false);
                            long     id = msg.ReadInt64();
                            DecodePlayer(msg, p);
                            players[id]  = p;
                            controls[id] = c;
                            game.AddPlayer(p);
                        }
                    }
                    break;

                    case ServerToClient.UpdateControls:
                    {
                        Console.WriteLine("Received a control update");
                        long     id      = msg.ReadInt64();
                        Controls control = controls[id];
                        DecodeControls(msg, control);
                    }
                    break;

                    case ServerToClient.UpdatePlayers:
                    {
                        Console.WriteLine("Received players update");
                        int n = msg.ReadInt32();
                        Console.WriteLine(n);
                        for (int i = 0; i < n; i++)
                        {
                            long id = msg.ReadInt64();
                            DecodePlayer(msg, players[id]);
                            Console.WriteLine(players[id].position);
                        }
                    }
                    break;

                    default:
                        break;
                    }
                    break;

                default:
                    Console.WriteLine("Unhandled type: " + msg.MessageType);
                    break;
                }
                client.Recycle(msg);
            }

            // Update game after receiving input changes
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

            game.Update(elapsed);
            base.Update(gameTime);
        }
Пример #12
0
 private void Handle()
 {
     if (result[1].GetType() == typeof(ServerToClient))
     {
         ServerToClient command = (ServerToClient)result[1];
         if (command == ServerToClient.Hit)
         {
             attackBoard.UpdateBoard((Vector2i)result[2], true);
             attackCanvas.InvalidateVisual();
         }
         else if (command == ServerToClient.Miss)
         {
             attackBoard.UpdateBoard((Vector2i)result[2], false);
             attackCanvas.InvalidateVisual();
         }
         else if (command == ServerToClient.Win)
         {
             player.AddWin();
             player.AddHits(attackBoard.hits);
             player.AddMiss(attackBoard.misses);
             mainWindow.UpdateStats();
             mainWindow.Activate();
             mainWindow.IsEnabled = true;
             gameOver             = true;
         }
         else if (command == ServerToClient.Loss)
         {
             player.AddLoss();
             player.AddHits(attackBoard.hits);
             player.AddMiss(attackBoard.misses);
             mainWindow.UpdateStats();
             mainWindow.Activate();
             mainWindow.IsEnabled = true;
             gameOver             = true;
         }
         else if (command == ServerToClient.BattleReady)
         {
             this.Show();
         }
         else if (command == ServerToClient.YourTurn)
         {
             //Added if something special should happen
         }
         else if (command == ServerToClient.EnemyAttack)
         {
             enemyAttacks.UpdateBoard((Vector2i)result[2], (bool)result[3]);
             shipCanvas.InvalidateVisual();
         }
         else if (command == ServerToClient.EnemyUsername)
         {
             Title = string.Format("Enemy: {0}", (string)result[2]);
         }
         else if (command == ServerToClient.EnemyShips)
         {
             attackCanvas.SetShipBoard((ShipBoard)result[2]);
             attackCanvas.drawBlanks = false;
             attackCanvas.drawShips  = true;
             attackCanvas.InvalidateVisual();
         }
     }
 }