Пример #1
0
        private void btnEdito_Click(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(txtEmri.Text) || String.IsNullOrEmpty(txtMbiemri.Text) || String.IsNullOrEmpty(txtPassword.Text) ||
                    String.IsNullOrEmpty(txtAdresa.Text) || String.IsNullOrEmpty(txtNrKontaktues.Text) || String.IsNullOrEmpty(dtDataLindjes.Text))
                {
                    MessageBox.Show("Mbushini të gjitha hapsirat e kerkuara");
                }
                else
                {
                    user.Emri         = txtEmri.Text;
                    user.Mbiemri      = txtMbiemri.Text;
                    user.Password     = txtPassword.Text;
                    user.Adresa       = txtAdresa.Text;
                    user.NrKontaktues = txtNrKontaktues.Text;
                    user.DataLindjes  = Convert.ToDateTime(dtDataLindjes.Text);

                    BussinessUser.EditUser(userid, user);
                    MessageBox.Show("Useri u editua me sukses");
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btnShto_Click(object sender, EventArgs e)
        {
            try
            {
                string   emri         = txtEmri.Text;
                string   mbiemri      = txtMbiemri.Text;
                string   email        = txtEmail.Text;
                string   adresa       = txtAdresa.Text;
                string   nrkontaktues = txtNrKontaktues.Text;
                string   password     = txtPassword.Text;
                DateTime dt           = Convert.ToDateTime(dtDataLindjes.Text);
                string   tipi         = cmbTipi.SelectedValue.ToString();
                string   pershkrimi   = cmbTipi.Text;

                if (String.IsNullOrEmpty(emri) || String.IsNullOrEmpty(mbiemri) || String.IsNullOrEmpty(email) ||
                    String.IsNullOrEmpty(adresa) || String.IsNullOrEmpty(email) || String.IsNullOrEmpty(password) ||
                    String.IsNullOrEmpty(dt.ToString()) || String.IsNullOrEmpty(tipi) || String.IsNullOrEmpty(pershkrimi))
                {
                    MessageBox.Show("Duhet te mbushen te gjitha hapsirat e kerkuara");
                }
                else
                {
                    string emailRegex = email;
                    Regex  regex      = new Regex(@"^[a-zA-Z0-9_.+-]+@[a-zA-Z]+.[a-zA-Z0-9]+$");
                    Match  match      = regex.Match(emailRegex);
                    if (!match.Success)
                    {
                        MessageBox.Show("Email nuk eshte valide");
                    }
                    else
                    {
                        User newUser = new User()
                        {
                            Emri         = emri,
                            Mbiemri      = mbiemri,
                            Email        = email,
                            Password     = password,
                            NrKontaktues = nrkontaktues,
                            DataLindjes  = dt,
                            Adresa       = adresa,
                            TipiUser     = new TipiUser()
                            {
                                TipiID     = int.Parse(tipi),
                                Pershkrimi = pershkrimi
                            }
                        };

                        BussinessUser.InsertUser(newUser);
                        MessageBox.Show("U shtua user i ri");
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #3
0
 void Show()
 {
     try
     {
         user                 = BussinessUser.GetUserById(userid);
         txtEmri.Text         = user.Emri;
         txtMbiemri.Text      = user.Mbiemri;
         txtPassword.Text     = user.Password;
         txtAdresa.Text       = user.Adresa;
         txtNrKontaktues.Text = user.NrKontaktues;
         dtDataLindjes.Text   = user.DataLindjes.ToShortDateString();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #4
0
 public usersController()
 {
     _user = new BussinessUser();
     BusinessManager <Users> manager = new BusinessManager <Users>(_user);
 }