Ejemplo n.º 1
0
 private void btnSignup_Click(object sender, EventArgs e)
 {
     //insert on Account.
     if (!TM.AddAccount(txtUsername.Text, MD5.CreateMD5(txtPassword.Text), 2, 1))
     {
         //if add faild, show notification
         MessageBox.Show("Failed");
     }
     else
     {
         //get id of it
         var rs = TM.GetListOfAccount().OrderByDescending(s => s.ID).First();
         //insert on Driver.
         if (!TM.AddDriver((int)rs.ID, txtFullname.Text, txtIDCard.Text, txtAddress.Text, txtPhone.Text))
         {
             //if add failed. show notification
             MessageBox.Show("Add info failed, please sign in and update your profile");
         }
         else
         {
             //if 2 success, show notification
             MessageBox.Show("Sign up successed");
         }
     }
 }
Ejemplo n.º 2
0
 private void btnChange_Click(object sender, EventArgs e)
 {
     //when click change pass button
     //check empty textbox
     if (String.IsNullOrEmpty(txtPass.Text) || String.IsNullOrEmpty(txtPassRepeat.Text))
     {
         MessageBox.Show("Please don't let empty");
     }
     else
     {
         //compare password and passrepeat
         if (String.Compare(txtPassRepeat.Text, txtPass.Text) != 0)
         {
             MessageBox.Show("Password and Repeat-Password are not matched");
         }
         else
         {
             //update
             if (TM.UpdatePasswordAccount(id, MD5.CreateMD5(txtPass.Text.Trim())))
             {
                 MessageBox.Show("Update successed");
                 Close();
             }
             else
             {
                 MessageBox.Show("Update failed! Please try again");
             }
         }
     }
 }
Ejemplo n.º 3
0
 private void btnDel_Click(object sender, EventArgs e)
 {
     //Delete Infomation
     //1. Delete info
     //2. delete account
     if (TM.DeleteDriver(int.Parse(lblIDdr.Text)))
     {
         //1.
         if (TM.DeleteAccount(int.Parse(lblIDdr.Text)))
         {
             //2.
             MessageBox.Show("Delete Successed!");
         }
         else
         {
             MessageBox.Show("Delete failed!");
         }
     }
     else
     {
         MessageBox.Show("Delete failed!");
     }
     //reload to update on form
     OnLoad(e);
 }
Ejemplo n.º 4
0
        void Reload_Data()
        {
            var ls = TM.GetListOfDriver();

            dgvDriverData.DataSource = ls;
            var ls2 = TM.GetListOfAccount().Where(s => s.TYPEID == 2).ToList();

            dgvAccountDriver.AutoGenerateColumns = false;
            dgvAccountDriver.DataSource          = ls2;
        }
Ejemplo n.º 5
0
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     //Update status account
     if (TM.UpdateStatusAccount(int.Parse(lblID.Text), rdActive.Checked == true ? 1 : 2))
     {
         MessageBox.Show("Update successed!");
     }
     else
     {
         MessageBox.Show("Update failed!");
     }
     Reload_Data();
 }
Ejemplo n.º 6
0
        private void FormDriver_Load(object sender, EventArgs e)
        {
            //load info of Driver signed in
            var ls = TM.GetListOfDriver();
            var rs = ls.Where(s => s.ID == id).SingleOrDefault();

            if (rs != null)
            {
                lblFullname.Text = rs.NAME;
                lblIDCard.Text   = rs.IDCARD;
                lblAddress.Text  = rs.ADDRESS;
                lblPhone.Text    = rs.PHONE;
            }
        }
Ejemplo n.º 7
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            //Update information
            if (TM.UpdateInfoDriver(int.Parse(lblIDdr.Text), txtFullname.Text.ToString().Trim(), txtIDCard.Text.ToString().Trim(), txtAddress.Text.ToString().Trim(), txtPhone.Text.ToString().Trim()))
            {
                MessageBox.Show("Update successed!");
            }
            else
            {
                MessageBox.Show("Update failed!");
            }

            Reload_Data();
        }
Ejemplo n.º 8
0
        private void Menu_Load(object sender, EventArgs e)
        {
            //load list driver
            var ls = TM.GetListOfDriver();

            dgvDriverData.DataSource = ls;

            //load list account driver
            var ls2 = TM.GetListOfAccount().Where(s => s.TYPEID == 2).ToList();

            dgvAccountDriver.AutoGenerateColumns = false;
            dgvAccountDriver.DataSource          = ls2;
            if (String.IsNullOrEmpty(txtFullname.Text))
            {
                btnDel.Enabled    = btnUpdate.Enabled = false;
                btnSubmit.Enabled = false;
            }
        }
Ejemplo n.º 9
0
        private void FormUpdateInfoDriver_Load(object sender, EventArgs e)
        {
            //when form load
            //load info of driver
            var ls = TM.GetListOfDriver();
            var rs = ls.Where(s => s.ID == id).SingleOrDefault();

            if (rs != null)
            {
                txtFullname.Text = rs.NAME;
                txtIDCard.Text   = rs.IDCARD;
                txtAddress.Text  = rs.ADDRESS;
                txtPhone.Text    = rs.PHONE;
            }
            else
            {
                btnUpdate.Enabled = false;
            }
        }
Ejemplo n.º 10
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     //when click update button
     //check empty textbox
     if (String.IsNullOrEmpty(txtFullname.Text) || String.IsNullOrEmpty(txtIDCard.Text) ||
         String.IsNullOrEmpty(txtAddress.Text) || String.IsNullOrEmpty(txtPhone.Text))
     {
         MessageBox.Show("Please input");
     }
     else
     {
         //update
         if (TM.UpdateInfoDriver(id, txtFullname.Text.ToString().Trim(), txtIDCard.Text.ToString().Trim(), txtAddress.Text.ToString().Trim(), txtPhone.Text.ToString().Trim()))
         {
             MessageBox.Show("Update successed!");
         }
         else
         {
             MessageBox.Show("Update failed!");
         }
     }
 }
Ejemplo n.º 11
0
 private void btnDangNhap_Click(object sender, EventArgs e)
 {
     //Check textbox Empty
     if (string.IsNullOrEmpty(txtUser.Text) | string.IsNullOrEmpty(txtPassword.Text))
     {
         //if empty, show error
         MessageBox.Show("Don't empty username or password.");
     }
     else
     {
         //if not empty
         //check valid account
         var acc = TM.GetListOfAccount();
         var rs  = acc.Where(s => (s.USERNAME.Trim() == txtUser.Text) & (s.PASSWORD.Trim() == MD5.CreateMD5(txtPassword.Text))).SingleOrDefault();
         if (rs != null)
         {
             //1: is Admin, 2: is Driver
             if (rs.TYPEID == 1)
             {
                 //1: status actived, 2: blocked
                 if (rs.STATUS == 1)
                 {
                     //Show notification
                     MessageBox.Show("Sign in success as Admin");
                     //call form admin manage
                     Menu fmn = new Menu((int)rs.ID);
                     fmn.StartPosition = FormStartPosition.CenterScreen;
                     fmn.FormClosed   += new FormClosedEventHandler(fmn_FormClosed);
                     Hide();
                     fmn.ShowDialog();
                 }
                 else
                 {
                     MessageBox.Show("Account is blocked");
                 }
             }
             else if (rs.TYPEID == 2)
             {
                 //1: status actived, 2: blocked
                 if (rs.STATUS == 1)
                 {
                     //Show notification
                     MessageBox.Show("Sign in success as Driver");
                     //call form admin manage
                     FormDriver fd = new FormDriver((int)rs.ID);
                     fd.StartPosition = FormStartPosition.CenterScreen;
                     fd.FormClosed   += new FormClosedEventHandler(fd_FormClosed);
                     Hide();
                     fd.ShowDialog();
                 }
                 else
                 {
                     MessageBox.Show("Account is blocked");
                 }
             }
         }
         else
         {
             //Show Exception
             MessageBox.Show("Username or Password is incorrect!");
         }
     }
 }