Example #1
0
        private void Profile_Load(object sender, EventArgs e)
        {
            employee = new DepartmentBUS().SelectByID(DataStatic.user, DataStatic.token, id);
            if (employee != null)
            {
                textBox1.Text = employee.Name;
                textBox2.Text = employee.Address;
                textBox3.Text = employee.Email;
                if (employee.Birthday != new DateTime())
                {
                    dateTimePicker1.Value = employee.Birthday;
                }
                comboBox2.SelectedItem = employee.Gender;
            }
            else
            {
                MessageBox.Show("Emplyee isn't exist");
                this.Close();
            }
            String imagebitmap = new AccountBUS().GetImage(new AccountBUS.ImageChange {
                id = this.id, imagebitmap = "", token = DataStatic.token, username = DataStatic.user
            });

            if (imagebitmap != null)
            {
                imagebitmap = imagebitmap.Remove(imagebitmap.Length - 1, 1).Remove(0, 1);
                byte[] imageBytes = Convert.FromBase64String(imagebitmap);
                //Console.WriteLine(imagebitmap);
                using (MemoryStream ms = new MemoryStream(imageBytes))
                {
                    pictureBox1.Image    = Image.FromStream(ms);
                    pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                }
            }
        }
Example #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            DepartmentBUS.Employee newEmployee = new DepartmentBUS.Employee(textBox2.Text, textBox3.Text, null, "", "", comboBox2.Text.ToString(), comboBox3.Text.ToString(), new DateTime(), null);
            bool result = departmentBUS.Insert(new DepartmentBUS.FilePut(newEmployee, DataStatic.user, DataStatic.token));

            if (result)
            {
                MessageBox.Show("Thêm thành công");
                ChangeDataGridView();
            }
            else
            {
                MessageBox.Show("Thêm thất bại");
            }
        }
Example #3
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (CheckNull())
     {
         DepartmentBUS.Employee updateEmployee = new DepartmentBUS.Employee()
         {
             Address = textBox2.Text, Birthday = dateTimePicker1.Value, Department = employee.Department, Email = textBox3.Text, Gender = comboBox2.Text.ToString(), ID = employee.ID, Image = null, Name = employee.Name, Position = employee.Position
         };
         bool result = new DepartmentBUS().Update(new DepartmentBUS.FilePut(updateEmployee, DataStatic.user, DataStatic.token));
         if (result)
         {
             MessageBox.Show("Cập nhật thành công");
             profileClosing.CheckReset(true);
         }
         else
         {
             MessageBox.Show("Cập nhật thất bại");
         }
     }
 }
Example #4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Bạn có chắc xóa không", "Xóa?", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                DepartmentBUS.Employee deleteEmployee = new DepartmentBUS.Employee(textBox2.Text, textBox3.Text, null, null, null, comboBox2.Text.ToString(), comboBox3.Text.ToString(), new DateTime(), null);
                bool result = departmentBUS.Delete(new DepartmentBUS.FilePut(deleteEmployee, DataStatic.user, DataStatic.token));
                if (result)
                {
                    MessageBox.Show("Xóa thành công");
                    ChangeDataGridView();
                }
                else
                {
                    MessageBox.Show("Xóa thất bại");
                }
            }
            else
            {
                ChangeDataGridView();
            }
        }