예제 #1
0
 private void bntXoa2_Click(object sender, EventArgs e)
 {
     if (textMa2.Text.Trim() == "")
     {
         MessageBox.Show("Bạn muốn sửa gì nào? Phải chọn trước chứ!!!");
     }
     else
     {
         DialogResult dr = MessageBox.Show("Bạn thực sự muốn xóa người này???", "Xóa dữ liệu", MessageBoxButtons.YesNo);
         if (DialogResult.Yes == dr)
         {
             bool ktra = new Connection2().XoaGV(id);
             if (ktra == true)
             {
                 MessageBox.Show("Xóa thành công");
                 dataGV.DataSource = new Connection2().LoadData();
             }
             else
             {
                 MessageBox.Show("Không thể xóa được");
             }
         }
         else
         {
         }
     }
 }
예제 #2
0
 public void Dispose()
 {
     if (_conn != null)
     {
         _conn.Stop();
         _conn = null;
     }
 }
예제 #3
0
 public void Stop()
 {
     if (_conn != null)
     {
         _conn.Stop();
         _conn = null;
     }
 }
 public void Dispose()
 {
     if (_conn != null)
     {
         _conn.Stop();
         _conn = null;
     }
 }
예제 #5
0
    public static Connection2 getInstance()
    {
        if (instance == null)
        {
            instance = new Connection2();

        }
        return instance;
    }
        public void MyTestInitialize()
        {
            var pair = P2P.GeneratePair(provider);

            Connection1 = pair.Item1;
            Connection2 = pair.Item2;

            runnertask1 = Task.Run(() => Connection1.RunCollector());
            runnertask2 = Task.Run(() => Connection2.RunCollector());
        }
예제 #7
0
 private void bntLuu2_Click(object sender, EventArgs e)
 {
     if (bntThem2.Visible == true)
     {
         if (textTen2.Text.Trim() == "" || textGT2.Text.Trim() == "")
         {
             MessageBox.Show("Bạn phải nhập dữ liệu vào khung thông tin");
         }
         else
         {
             Giaovien GV = new Giaovien();
             GV.Name    = textTen2.Text.Trim();
             GV.GT1     = textGT2.Text.Trim();
             GV.NS1     = textNS3.Value;
             GV.Mon1    = textMon.Text.Trim();
             GV.ChucVu1 = textCV.Text.Trim();
             bool ktra = new Connection2().ThemGV(GV);
             if (ktra == true)
             {
                 MessageBox.Show("Thêm dữ liệu thành công");
                 dataGV.DataSource = new Connection2().LoadData();
             }
             else
             {
                 MessageBox.Show("Không thể thêm được học sinh mới. Hãy thử lại");
             }
         }
     }
     if (bntSua.Visible == true)
     {
         Giaovien GV = new Giaovien();
         GV.ID1     = textMa2.Text.Trim();
         GV.Name    = textTen2.Text.Trim();
         GV.GT1     = textGT2.Text.Trim();
         GV.NS1     = textNS3.Value;
         GV.Mon1    = textMon.Text.Trim();
         GV.ChucVu1 = textCV.Text.Trim();
         bool ktra = new Connection2().SuaGV(GV);
         if (ktra == true)
         {
             MessageBox.Show("Sửa dữ liệu thành công");
             dataGV.DataSource = new Connection2().LoadData();
         }
         else
         {
             MessageBox.Show("Không thể Sửa được học sinh mới. Hãy thử lại");
         }
     }
 }
예제 #8
0
        private void Obtengo()
        {
            Connection2 connection2 = new Connection2();

            if (ConnectionState == true)
            {
                try
                {
                    Producto   = connection2.CN_3(Convert.ToInt32(tb_Codigo_Ventas.Text))[0];
                    Precio     = connection2.CN_3(Convert.ToInt32(tb_Codigo_Ventas.Text))[1];
                    Inventario = connection2.CN_3(Convert.ToInt32(tb_Codigo_Ventas.Text))[2];

                    Text_output = Producto + " RD$" + Precio + ".00";


                    if (Producto == "#")
                    {
                        dbStatus();
                        if (ConnectionState == true)
                        {
                            bt_Enter_Ventas.Enabled = false;
                            Text_output             = "";
                            mostrarError("El código no existe", 35);
                        }
                        else
                        {
                            bt_Enter_Ventas.Enabled = false;
                            mostrarError(error, 100);
                        }
                    }
                    else
                    {
                        bt_Enter_Ventas.Enabled = true;
                    }
                }
                catch
                {
                    ValorInicial_Ventas();
                    mostrarError("El valor incertado no es valido", 35);
                }
            }
            else
            {
                mostrarError(error, 100);
            }

            lb_Info_Ventas.Text = Text_output;
        }
예제 #9
0
 public async Task Start()
 {
     if (_conn != null)
     {
         return;
     }
     _conn = new Connection2(Urls.RealTimeMessaging);
     _conn.Headers["ut"]   = App.UserToken;
     _conn.Headers["ak"]   = App.Apikey;
     _conn.Received       += OnReceived;
     _conn.Closed         += OnClosed;
     _conn.ConnectionSlow += OnConnectionSlow;
     _conn.Error          += OnError;
     _conn.Reconnected    += OnReconnected;
     _conn.Reconnecting   += OnReconnecting;
     _conn.StateChanged   += OnStatechange;
     await _conn.Start();
 }
예제 #10
0
        static void Main(string[] args)
        {
            int number;

            int.TryParse(args[0], out number);
            //IForkExchange conn = new Connection( "Pipe")
            using (IForkExchange conn = new Connection2("Memory1"))
            {
                var cafe = new PhilosopherClasses.MainClasses.Cafe(number, conn);
                cafe.StateChanged += Show;
                var thread = new Thread(cafe.Start);
                thread.Start();
                thread.Join();
            }


            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            int number;

            int.TryParse(args[0], out number);

            //IForkExchange conn = new Connection2("Memory1");
            //IForkExchange conn = new Connection("Pipe")
            using (IForkExchange conn = new Connection2("Memory1"))
            {
                var philosopher = new PhilosopherClasses.Philosopher(number, conn);
                philosopher.ChangeStateEvent += Show;
                philosopher.DeathEvent       += Death;
                var thread = new Thread(philosopher.Start);
                thread.Start();
                thread.Join();
            }

            Console.ReadKey();
        }
        public async Task InitializeConnection(IWriteToOutput writeToOutput, StringBuilder content, string messageConnection1 = null, string messageConnection2 = null)
        {
            bool service1IsNull = this.Service1 == null;
            bool service2IsNull = this.Service2 == null;

            {
                var mess1 = messageConnection1;
                if (string.IsNullOrEmpty(mess1))
                {
                    mess1 = Properties.OutputStrings.ConnectingToCRM;
                }

                var mess2 = Connection1.GetConnectionDescription();

                if (service1IsNull)
                {
                    writeToOutput.WriteToOutput(null, mess1);
                    writeToOutput.WriteToOutput(null, mess2);

                    this.Service1 = await QuickConnection.ConnectAsync(Connection1);
                }

                var mess3 = string.Format(Properties.OutputStrings.CurrentServiceEndpointFormat1, this.Service1.CurrentServiceEndpoint);

                if (service1IsNull)
                {
                    writeToOutput.WriteToOutput(null, mess3);
                }

                if (content != null)
                {
                    content.AppendLine(mess1);
                    content.AppendLine(mess2);
                    content.AppendLine(mess3);
                }
            }

            if (service1IsNull)
            {
                writeToOutput.WriteToOutput(null, string.Empty);
            }

            if (content != null)
            {
                content.AppendLine();
            }

            {
                var mess1 = messageConnection2;
                if (string.IsNullOrEmpty(mess1))
                {
                    mess1 = Properties.OutputStrings.ConnectingToCRM;
                }
                var mess2 = Connection2.GetConnectionDescription();

                if (service2IsNull)
                {
                    writeToOutput.WriteToOutput(null, mess1);
                    writeToOutput.WriteToOutput(null, mess2);

                    this.Service2 = await QuickConnection.ConnectAsync(Connection2);
                }

                var mess3 = string.Format(Properties.OutputStrings.CurrentServiceEndpointFormat1, this.Service2.CurrentServiceEndpoint);

                if (service2IsNull)
                {
                    writeToOutput.WriteToOutput(null, mess3);
                }

                if (content != null)
                {
                    content.AppendLine(mess1);
                    content.AppendLine(mess2);
                    content.AppendLine(mess3);
                }
            }

            if (content != null)
            {
                content.AppendLine();
            }
        }
 public async Task Start()
 {
     if (_conn != null)
         return;
     _conn = new Connection2(Urls.RealTimeMessaging);
     _conn.Headers["ut"] = App.UserToken;
     _conn.Headers["ak"] = App.Apikey;
     _conn.Received += OnReceived;
     _conn.Closed += OnClosed;
     _conn.ConnectionSlow += OnConnectionSlow;
     _conn.Error += OnError;
     _conn.Reconnected += OnReconnected;
     _conn.Reconnecting += OnReconnecting;
     _conn.StateChanged += OnStatechange;
     await _conn.Start();
 }
 public void Stop()
 {
     if (_conn != null)
     {
         _conn.Stop();
         _conn = null;
     }
 }