private void btn_ok_Click(object sender, EventArgs e)
        {
            bool   checklocalDB = rb_Local.Checked;
            string message      = "";

            if (txt_DatabaseName.Text == "")
            {
                lbl_thongbao.Text = "Chưa nhập Database Name";
                return;
            }

            try
            {
                ConnectObj ObjConnect = new ConnectObj();
                DevicesBUS busDevices = new DevicesBUS();

                message = busDevices.connect(/*cbx_sername.SelectedItem.ToString()*/ checklocalDB, cbx_sername.Text, txt_DatabaseName.Text, txt_Username.Text, txt_Password.Text, message);
                MessageBox.Show(message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {
                //if (conn.State == ConnectionState.Open)
                //conn.Close();
                this.Close();
                // save user setting
                Properties.Settings.Default.S_ServerName = cbx_sername.Text;
                Properties.Settings.Default.S_DBusername = txt_Username.Text;
                Properties.Settings.Default.S_DBpassword = txt_Password.Text;
            }
        }
예제 #2
0
 private void Update()
 {
     //work with rect
     if (Input.GetMouseButtonDown(0))
     {
         Transform hit = GetTransformHit(GetPositionMouse());
         if (DoubleClick())//DestroyRectangle
         {
             if (hit != null)
             {
                 hit.GetComponent <RectangleObj>().DestroyRect();
             }
         }
         else if (!CheckCollision(hit))//CreateRectangle
         {
             RectangleObj cloneRect = Instantiate(Resources.Load("Rect") as GameObject, GetPositionMouse(), Quaternion.identity, parentRect)
                                      .GetComponent <RectangleObj>();
             cloneRect.CreateRect(this);
             rectangles.Add(cloneRect.transform);
         }
         else
         {
             GetInfoAboutLastClick();
         }
     }
     //work with connect(line)
     if (Input.GetMouseButtonDown(1))
     {
         Transform hit = GetTransformHit(GetPositionMouse());
         if (connectNow == null)//CreateConnect
         {
             if (hit == null)
             {
                 return;
             }
             connectNow = Instantiate(Resources.Load("Connect") as GameObject).GetComponent <ConnectObj>();
             connectNow.CreateConnect(hit, this);
         }
         else//Finish CreateConnect
         {
             connectNow.CloseConnect(hit);
             connectNow = null;
         }
     }
 }
예제 #3
0
        public string Mahoa(ConnectObj obj)
        {
            byte[] data_encrypt = UTF8Encoding.UTF8.GetBytes(obj.password.ToString());
            using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider())
            {
                byte[] keys = md5.ComputeHash(UTF8Encoding.UTF8.GetBytes(obj.password.ToString()));
                using (TripleDESCryptoServiceProvider tripDes = new TripleDESCryptoServiceProvider()
                {
                    Key = keys, Mode = CipherMode.ECB, Padding = PaddingMode.PKCS7
                })
                {
                    ICryptoTransform transform = tripDes.CreateEncryptor();
                    byte[]           results   = transform.TransformFinalBlock(data_encrypt, 0, data_encrypt.Length);
                    obj.password = Convert.ToBase64String(results, 0, results.Length);
                }
            }

            return(obj.password);
        }
예제 #4
0
 public string Mahoa(ConnectObj obj)
 {
     return(dao.Mahoa(obj));
 }