Ejemplo n.º 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            u.FirstName = txtFirstname.Text;
            u.LastName  = txtLastname.Text;
            u.Username  = txtUsername.Text;
            u.Password  = txtPassword.Text;
            u.Email     = txtEmail.Text;
            u.Contact   = Convert.ToInt32(txtContact.Text);
            u.Gender    = cmbGender.Text;
            u.Address   = txtAddress.Text;
            u.UserType  = cmbUserType.Text;
            u.DateTime  = DateTime.Now;

            // Inserting in to database
            bool success = dal.Insert(u);

            // If the data is successfully inserted then the value of success will be true else it will be false
            if (success == true)
            {
                //Data successfully inserted
                MessageBox.Show("User successfully Added.");
                Clear();
            }
            else
            {
                //Fail to insert Data
                MessageBox.Show("Fail To Add User Try Again.");
            }
            //Refresh Data grid View
            DataTable dt = dal.Select();

            dgvUser.DataSource = dt;
        }
Ejemplo n.º 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //get the values from the UI
            u.full_name  = textBoxFullName.Text;
            u.email      = textBoxEmail.Text;
            u.username   = textBoxUsername.Text;
            u.password   = textBoxPassword.Text;
            u.contact    = textBoxContact.Text;
            u.address    = textBoxAddress.Text;
            u.added_date = DateTime.Now;
            u.image_name = imageName;

            //adding the values from the UI to database
            //boolean variable to check wether the data is inserted successfully or not
            bool success = dal.Insert(u);

            //check wether the data is inserted successfully or not
            if (success == true)
            {
                //data or user added successfully
                MessageBox.Show("New user added successfully.");

                //display the user in data grid view
                DataTable dt = dal.Select();
                dgvUsers.DataSource = dt;

                //clear textboxes
                Clear();
            }
            else
            {
                //failed to add a new user
                MessageBox.Show("Failed to add new user.");
            }
        }
Ejemplo n.º 3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            u.first_name = txtFirstName.Text;
            u.last_name  = txtLastName.Text;
            u.email      = txtEmail.Text;
            u.username   = txtUsername.Text;
            u.password   = txtPassword.Text;
            u.contact    = txtContact.Text;
            u.address    = txtAddress.Text;
            u.user_type  = cmbUserType.Text;
            u.added_date = DateTime.Now;

            string  loggedInUser = Login.loggedIn;
            userBLL usr          = dal.GetIDFromUsername(loggedInUser);

            u.added_by = usr.id;

            bool success = dal.Insert(u);

            if (success == true)
            {
                MessageBox.Show("User created Successfully.");
                clear();
            }
            else
            {
                MessageBox.Show("Failed to add new User!!");
            }

            DataTable dt = dal.Select();

            dgvUsers.DataSource = dt;
        }
Ejemplo n.º 4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            u.first_name = txtFirstName.Text;
            u.last_name  = txtLastName.Text;
            u.email      = txtEmail.Text;
            u.username   = txtUsername.Text;
            u.password   = txtPassword.Text;
            u.contact    = txtContact.Text;
            u.address    = txtAddress.Text;
            u.gender     = cmbGender.Text;
            u.user_type  = cmbUserType.Text;
            u.added_date = DateTime.Now;
            string  loggedUser = frmLogin.loggedIn;
            userBLL usr        = dal.GetIDFromUsername(loggedUser);

            u.added_by = usr.id;
            bool success = dal.Insert(u);

            if (success == true)
            {
                MessageBox.Show("ทำการบันทึกข้อมูลผู้ใช้งานเรียบร้อยแล้ว");
                clear();
            }
            else
            {
                MessageBox.Show("ไม่สามารถทำการบันทึกข้อมูลผู้ใช้งานได้! กรุณาลองใหม่อีกครั้ง");
            }
            DataTable dt = dal.Select();

            dgvUsers.DataSource = dt;
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //Step 1: Get the Values from UI
            u.full_name  = txtFullName.Text;
            u.email      = txtEmail.Text;
            u.username   = txtUsername.Text;
            u.password   = txtPassword.Text;
            u.contact    = txtContact.Text;
            u.address    = txtAddress.Text;
            u.added_date = DateTime.Now;
            u.image_name = imageName;

            //Step2: Adding the Values from UI to the Database
            //Create a Boolean Variable to check whether the data is inserted successfully or not
            bool success = dal.Insert(u);

            //Step 3: Check whether the Data is Inserted Successfully or Not
            if (success == true)
            {
                //Data or User Added Successfully
                MessageBox.Show("New User added Successfully.");

                //Display the user in DataGrid View
                DataTable dt = dal.Select();
                dgvUsers.DataSource = dt;

                //Clear TextBoxes
                Clear();
            }
            else
            {
                //Failed to Add User
                MessageBox.Show("Failed to Add New User.");
            }
        }
        private void btnCadastro_Click(object sender, EventArgs e)
        {
            u.pr_nome     = txtFirstName.Text;
            u.sb_nome     = txtLastName.Text;
            u.email       = txtEmail.Text;
            u.user_name   = txtUserName.Text;
            u.password    = txtSenha.Text;
            u.contato     = txtContato.Text;
            u.nm_endereco = txtEndereco.Text;
            u.sexo        = cbxSexo.Text;
            u.user_type   = cbxTpUser.Text;
            u.data        = DateTime.Now;
            u.add_por     = 1;

            bool sucess = dal.Insert(u);

            if (sucess = true)
            {
                MessageBox.Show("Usuário cadastrado com sucesso");
                Limpar();
            }
            else
            {
                MessageBox.Show("Não foi possivel cadastrar esse usuário");
            }

            DataTable dt = dal.Select();

            dgvUser.DataSource = dt;
        }
Ejemplo n.º 7
0
        private void FrmUsers_Load(object sender, EventArgs e)
        {
            //Display users on load
            DataTable dt = dal.Select();

            userDataGrid.DataSource = dt;
        }
Ejemplo n.º 8
0
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            String keywords = txtSearch.Text;

            if (keywords != null)
            {
                DataTable dt = dal.Search(keywords);
                dgvUsers.DataSource = dt;
            }
            else
            {
                DataTable dt = dal.Select();
                dgvUsers.DataSource = dt;
            }
        }
        private void LoadUserList(DataGridView dgv)
        {
            DataTable dt = dalUser.Select();

            dgv.Rows.Clear();

            foreach (DataRow user in dt.Rows)
            {
                int n = dgv.Rows.Add();
                dgv.Rows[n].Cells[dalUser.UserID].Value      = user[dalUser.UserID].ToString();
                dgv.Rows[n].Cells[dalUser.Username].Value    = user[dalUser.Username].ToString();
                dgv.Rows[n].Cells[dalUser.Permission].Value  = user[dalUser.Permission].ToString();
                dgv.Rows[n].Cells[dalUser.AddedDate].Value   = user[dalUser.AddedDate].ToString();
                dgv.Rows[n].Cells[dalUser.UpdatedDate].Value = user[dalUser.UpdatedDate].ToString();
                dgv.Rows[n].Cells[dalUser.UpdatedBy].Value   = user[dalUser.UpdatedBy].ToString();

                if (Convert.ToInt32(user[dalUser.AddedBy]) <= 0)
                {
                    dgv.Rows[n].Cells[dalUser.AddedBy].Value = "ADMIN";
                }
                else
                {
                    dgv.Rows[n].Cells[dalUser.AddedBy].Value = dalUser.getUsername(Convert.ToInt32(user[dalUser.AddedBy]));
                }

                if (int.TryParse(user[dalUser.UpdatedBy].ToString(), out int by))
                {
                    dgv.Rows[n].Cells[dalUser.UpdatedBy].Value = dalUser.getUsername(Convert.ToInt32(user[dalUser.UpdatedBy]));
                }
            }
            tool.listPaint(dgv);
        }
Ejemplo n.º 10
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //empty form error message
            if (txtFirstName.Text == "" || txtLastName.Text == "" || txtEmail.Text == "" ||
                txtUsername.Text == "" || txtPassword.Text == "" || txtContact.Text == "" || txtAddress.Text == "")
            {
                MessageBox.Show("Please fill your detail first", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            else
            {
                //Gettting Data FRom UI
                u.first_name = txtFirstName.Text;
                u.last_name  = txtLastName.Text;
                u.email      = txtEmail.Text;
                u.username   = txtUsername.Text;
                u.password   = txtPassword.Text;
                u.contact    = txtContact.Text;
                u.address    = txtAddress.Text;
                u.gender     = cmbGender.Text;
                u.user_type  = cmbUserType.Text;
                u.added_date = DateTime.Now;

                //Getting Username of the logged in user
                string  loggedUser = frmLogin.loggedIn;
                userBLL usr        = dal.GetIDFromUsername(loggedUser);

                u.added_by = usr.id;

                //Inserting Data into DAtabase
                bool success = dal.Insert(u);
                //If the data is successfully inserted then the value of success will be true else it will be false
                if (success == true)
                {
                    //Data Successfully Inserted
                    MessageBox.Show("User successfully created.");
                    clear();
                }
                else
                {
                    //Failed to insert data
                    MessageBox.Show("Failed to add new user");
                }
                //Refreshing Data Grid View
                DataTable dt = dal.Select();
                dgvUsers.DataSource = dt;
            }
        }
Ejemplo n.º 11
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            // Getting Data from UI
            u.first_name = txtFirstName.Text;
            u.last_name  = txtLastName.Text;
            u.email      = txtEmail.Text;
            u.username   = txtUserName.Text;
            u.password   = txtPassword.Text;
            u.contact    = txtContact.Text;
            u.address    = txtAddress.Text;
            u.gender     = cmbBoxGender.Text;
            u.user_type  = cmbBoxUserType.Text;
            u.added_date = DateTime.Now;

            // Getting Username of the logged in user
            string  loggedUser = frmLogin.loggedIn;
            userBLL usr        = dal.GetIDFromUsername(loggedUser);

            u.added_by = usr.id;

            // Inserting Data into Database. we will declare one variable success which will take data to DAL
            bool success = dal.Inset(u);

            // now we wil ltest our condition that if data is successfully inserted, then good , otherwise it will be false

            if (success == true)
            {
                // Data Successfully inserted then the value will be true else will be false
                MessageBox.Show("User successfully Created");

                // Here we will call clear method
                clear();
            }
            else
            {
                // falied
                MessageBox.Show("Falied to add new user");
            }

            // Refreshing Data Grid View.we will create a temporary storage data table to store data.
            DataTable dt = dal.Select();

            // this will refer the data grid view
            dgvUsers.DataSource = dt;
        }
Ejemplo n.º 12
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            //on add get the text input
            u.username   = textBoxUsername.Text;
            u.first_name = textBoxFirstName.Text;
            u.last_name  = textBoxLastName.Text;
            u.email      = textBoxEmail.Text;
            u.address    = textBoxAddress.Text;
            u.mobile     = textBoxMobile.Text;
            switch (comboBoxGender.SelectedIndex)
            {
            case 0:
                u.gender = "Male";
                break;

            case 1:
                u.gender = "Female";
                break;

            case 2:
                u.gender = "Others";
                break;
            }

            u.enrolled_date          = dateTimePickerEnrolledDate.Value;
            u.membership_expiry_date = dateTimePickerExpiryDate.Value;
            u.num_books_borrowed     = int.Parse(textBoxBooksBorrowed.Text);
            bool success = dal.Insert(u);

            if (success)
            {
                MessageBox.Show("New User Added Successfully");

                //display the user in DataGrid view
                DataTable dt = dal.Select();
                dataGridViewUsers.DataSource = dt;

                //clear the text inputs
                Clear();
            }
            else
            {
                MessageBox.Show("Failed to Add New User");
            }
        }
Ejemplo n.º 13
0
        private void textBox1_TextChanged_1(object sender, EventArgs e)
        {
            string keywords = txtBoxSearch.Text;

            //check if the keywords has value
            if (keywords != null)
            {
                //Show user based on keywords
                DataTable dataTable = userDAL.Search(keywords);
                dgvUser.DataSource = dataTable;
            }
            else
            {
                //show all users from the database
                DataTable dataTable = userDAL.Select();
                dgvUser.DataSource = dataTable;
            }
        }
Ejemplo n.º 14
0
        private void frmUsers_Load(object sender, EventArgs e)
        {
            DataTable dt = dal.Select();

            dgvUser.DataSource             = dt;
            dgvUser.Columns[0].HeaderText  = "ID";
            dgvUser.Columns[1].HeaderText  = "NOME";
            dgvUser.Columns[2].HeaderText  = "SOBRENOME";
            dgvUser.Columns[3].HeaderText  = "E-MAIL";
            dgvUser.Columns[4].HeaderText  = "USUÁRIO";
            dgvUser.Columns[5].HeaderText  = "SENHA";
            dgvUser.Columns[6].HeaderText  = "TELEFONE";
            dgvUser.Columns[7].HeaderText  = "ENDEREÇO";
            dgvUser.Columns[8].HeaderText  = "SEXO";
            dgvUser.Columns[9].HeaderText  = "TIPO USUÁRIO";
            dgvUser.Columns[10].HeaderText = "DATA/HORA";
            dgvUser.Columns[11].HeaderText = "CADASTRADO POR";
        }
        private void button2_Click(object sender, EventArgs e)
        {
            if (lblUserType.Text == "Student")
            {
                userType = "Student";
            }
            else if (lblUserType.Text == "Tutor")
            {
                userType = "Tutor";
            }
            if (txtpassword.Text == txtrepassword.Text)
            {
                u.fullname   = txtFullName.Text;
                u.address    = txtAddress.Text;
                u.dob        = dateTimePicker1.Value;
                u.parentName = txtParentName.Text;
                u.tell       = txtTel.Text;
                u.username   = txtusername.Text;
                u.password   = txtpassword.Text;
                u.userType   = lblUserType.Text;

                bool success = dal.Insert(u);
                if (success == true)
                {
                    MessageBox mb = new MessageBox("User Added Successfully!!!", sampleframe.cs.MessageBox.MsgType.success);
                    mb.Show();
                    clear();
                    Login f4 = new Login();
                    f4.Show();
                    this.Visible = false;
                }
                else
                {
                    MessageBox mb = new MessageBox("Fail to Added!!!", sampleframe.cs.MessageBox.MsgType.retry);
                    mb.Show();
                }
                DataTable dt = dal.Select();
            }
            else
            {
                MessageBox mb = new MessageBox("Passwords are not matched!!!", sampleframe.cs.MessageBox.MsgType.retry);
                mb.Show();
            }
        }
Ejemplo n.º 16
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            u.first_name = txtFirstName.Text;
            u.last_name  = txtLastName.Text;
            u.email      = txtEmail.Text;
            u.username   = txtUserName.Text;
            u.password   = txtPassword.Text;
            u.contact    = txtContact.Text;
            u.address    = txtAddress.Text;
            u.gender     = comboGender.Text;
            u.user_type  = comboUserType.Text;
            u.added_date = DateTime.Now;
            string  loggedUser = frmLogin.loggedIn;
            userBLL usr        = dal.GetIdFromUsername(loggedUser);

            u.added_by = loggedUser;
            if (u.user_type == "")
            {
                MassageBox mb = new MassageBox("Added Failed", MsgType.retry);
                mb.Show();
            }
            else
            {
                bool success = dal.Insert(u);

                if (success == true)
                {
                    MassageBox mb = new MassageBox("Added Success", MsgType.success);
                    mb.Show();
                    //MessageBox.Show("User Added Successfully!!!");
                    clear();
                }
                else
                {
                    MassageBox mb = new MassageBox("Added Failed", MsgType.retry);
                    mb.Show();
                    //MessageBox.Show("Fail to Added!!!");
                }
            }

            DataTable dt = dal.Select();

            dgvUser.DataSource = dt;
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //Getting username of the logged in user
            string loggedUser = frmLogin.loggedIn;


            //Getting Data from UI
            u.first_name = txtFirstName.Text;
            u.last_name  = txtLastName.Text;
            u.email      = txtEmail.Text;
            u.username   = txtUsername.Text;
            u.password   = txtPassword.Text;
            u.contact    = txtContact.Text;
            u.address    = txtAddress.Text;
            u.gender     = cmbGender.Text;
            u.user_type  = cmbUserType.Text;
            u.added_date = DateTime.Now;

            //Getting Username of the logged in user
            string  loggeduser = frmLogin.loggedIn;
            userBLL usr        = dal.GetIDFromUsername(loggedUser);

            u.added_by = usr.id;

            //Inserting Data into Database
            bool success = dal.Insert(u);

            //If the data is successfully inserted then the value will be true else it will be false
            if (success == true)
            {
                //Data Successfully Inserted
                MessageBox.Show("User Suuccessfully Created");
                clear();
            }
            else
            {
                //Failed to Insert Data
                MessageBox.Show("Failed to Add New User");
            }
            //Refresing DatagridView
            DataTable dt = dal.Select();

            dgvUsers.DataSource = dt;
        }
Ejemplo n.º 18
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //Getting Username of the logged in user

            string loggedUser = frmLogin.loggedIn;

            // Getting Data From UI
            // We will use BLL Object here
            u.first_name = txtFirstName.Text;
            u.last_name  = txtLastName.Text;
            u.email      = txtEmail.Text;
            u.username   = txtUsername.Text;
            u.password   = txtPassword.Text;
            u.contact    = txtContact.Text;
            u.address    = txtAddress.Text;
            u.gender     = cmbGender.Text;
            u.user_type  = cmbUserType.Text;
            u.added_date = DateTime.Now; // This DateTime.Now will show the current date when user adds data

            userBLL usr = dal.GetIDFromUsername((loggedUser));

            u.added_by = usr.id; // currently we don't have user id so we wil put it later ***** We have fixed it and we have user id now

            //Inserting Data into Database
            bool sucess = dal.Insert(u);

            // If the data is sucessfully inserted then the value will be true else it will be false
            if (sucess == true)
            {
                //Data Sucessfully Inserted
                MessageBox.Show("User Sucessfully Added");
                clear();
            }
            else
            {
                // Failed to insert data
                MessageBox.Show("Failed to Add New User");
            }
            //Refreshing Data Grid View
            DataTable dt = dal.Select();

            dgvUsers.DataSource = dt;
        }
Ejemplo n.º 19
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //getting data from UI
            u.first_name = txtFirstName.Text;
            u.last_name  = txtLastName.Text;
            u.Email_id   = txtEmail_id.Text;
            u.username   = txtUsername.Text;
            u.password   = txtPassword.Text;
            u.contact    = txtContact.Text;
            u.address    = txtAddress.Text;
            u.gender     = cmbGender.Text;
            u.user_type  = cmbUserType.Text;
            u.added_date = DateTime.Now;

            //getting username of the logged in user
            string loggedUser = frmLogin.loggedIn;

            userBLL usr = dal.GetIDFromUsername(loggedUser);

            u.added_by = usr.id;

            //inserting data into database
            bool success = dal.Insert(u);

            //if the data is successfully inserted then the value of success will be trueelse it will be false
            if (success == true)
            {
                //data successfully inserted
                MessageBox.Show("user successfully created");
                clear();
            }
            else
            {
                //failed to inserted data
                MessageBox.Show("failed to add new user");
            }
            //refreshing data grid view
            DataTable dt = dal.Select();

            dgvUsers.DataSource = dt;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            // Getting userID
            //update
            string loggedUser = frmLogin.loggedIn;

            // Geting data from UI
            u.first_name = textBox1.Text;
            u.last_name  = textBox2.Text;
            u.email      = textBox3.Text;
            u.username   = textBox4.Text;
            u.password   = textBox5.Text;
            u.contact    = textBox6.Text;
            u.address    = textBox7.Text;
            u.gender     = comboBox1.Text;
            u.user_type  = comboBox2.Text;
            u.added_date = DateTime.Now;

            // String loggedUser = frmLogin.loggedIn;
            userBLL usr = dal.GetIdFromUsername(loggedUser);

            u.added_by = usr.id;

            //Inserting data into database
            bool success = dal.Insert(u);

            if (success == true)
            {
                //data inserted sucesfully
                MessageBox.Show("User Added Succesfully");
                clear();
            }
            else
            {
                //error occured
                MessageBox.Show("Sorry..!! , Failed to add user");
            }
            DataTable dt = dal.Select();

            dgvUsers.DataSource = dt;
        }
Ejemplo n.º 21
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //..........................................Getting Data from UI.........................................
            u.first_name = txtFirstName.Text;
            u.last_name  = txtLastName.Text;
            u.email      = txtEmail.Text;
            u.username   = txtUsername.Text;
            u.password   = txtPassword.Text;
            u.contact    = txtContact.Text;
            u.address    = txtAddress.Text;
            u.user_type  = cnbUserType.Text;
            u.added_date = DateTime.Now;
            u.gender     = cnbGender.Text;

            //Getting User Name From Logged In User
            string  LoggedInUser = frmLogin.LoggedIn;
            userBLL usr          = daL.GetIDFromUserName(LoggedInUser);

            u.added_by = usr.id;

            //Inserting Data into Database
            bool success = daL.Insert(u);

            //if data is successfully inserted value of success will be true
            if (success == true)
            {
                MessageBox.Show("User succesfully created.");
                clear();
            }
            else
            {
                MessageBox.Show("Failed to create user");
            }
            //Refreshing Data Grid View
            DataTable dt = daL.Select();

            dgvUsers.DataSource = dt;
        }
Ejemplo n.º 22
0
        private void btnAdd_Click(object sender, EventArgs e)
        {   //Getting UserName of the loggedIn User
            string loggedUser = frmLogin.LoggedInUserName;

            //Getting the UserID basedon the UserNAme
            UserBll usr = userDl.GetIDFromUsername(loggedUser);

            //Getting data from UI
            userBl.firstName = txtFirstName.Text;
            userBl.lastName  = txtLastName.Text;
            userBl.email     = txtEmail.Text;
            userBl.userName  = txtUserName.Text;
            userBl.passWord  = txtpassword.Text;
            userBl.Contact   = txtContact.Text;
            userBl.address   = txtAdress.Text;
            userBl.gender    = cmbGender.Text;
            userBl.user_type = cmbUserType.Text;
            userBl.addedDate = DateTime.Now;
            userBl.addedBy   = usr.id;

            //inserting Data into DATABASE
            bool success = userDl.Insert(userBl);

            //if the data SuccessFully inserted then Success will be True
            if (success == true)
            {
                MessageBox.Show("User SuccessFully Created");
                clear();
            }
            else
            {
                MessageBox.Show("Failed!!!! to Add User");
            }
            //Refreshing Data Grid View
            DataTable DT = userDl.Select();

            dgvUsers.DataSource = DT;
        }
Ejemplo n.º 23
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string  loggedUser = frmLogin.loggedIn;
            userBLL usr        = dal.GetIDFromUSername(loggedUser);

            //Getting data from UI
            u.first_name = txtFirstName.Text;
            u.last_name  = txtLastName.Text;
            u.email      = txtEmail.Text;
            u.username   = txtUsername.Text;
            u.password   = txtPassword.Text;
            u.contact    = txtContact.Text;
            u.address    = txtAdress.Text;
            u.gender     = cmbGender.Text;
            u.user_type  = cmbUsertype.Text;
            u.added_date = DateTime.Now;
            u.added_by   = usr.id;

            //Inserting data in to DB

            bool success = dal.Insert(u);

            if (success == true)
            {
                MessageBox.Show("User succesfully created");
                clear();
            }

            else
            {
                MessageBox.Show("Failed to add new user");
            }
            //Refreshing Data Grid View
            DataTable dt = dal.Select();

            dgvUsers.DataSource = dt;
        }
Ejemplo n.º 24
0
        private void Form1_Load(object sender, EventArgs e)
        {
            bool bit = true;

            if (bit)
            {
                tbl_users u = new tbl_users
                {
                    first_name = "name",
                    last_name  = "name"
                };
                dal.Insert(u);
                List <tbl_users> query = dal.Select();
                foreach (var item in query)
                {
                    textBox1.Text = textBox1.Text + Environment.NewLine + item.Id + " " + item.first_name;
                }
            }
            else
            {
                var user = new tbl_users {
                    first_name = "firstname2"
                };
                db.tbl_users.Add(user);
                db.SaveChanges();

                // Display all Blogs from the database
                var query = from b in db.tbl_users
                            orderby b.first_name
                            select b;

                foreach (var item in query)
                {
                    textBox1.Text = textBox1.Text + Environment.NewLine + item.Id + " " + item.first_name;
                }
            }
        }
Ejemplo n.º 25
0
        private void refreshDataGridView(string type = null)
        {
            DataTable dt = type != null?dal.Search(type) : dal.Select();

            dgvUsers.DataSource = dt;
        }
Ejemplo n.º 26
0
        private void FrmUsers_Load(object sender, EventArgs e)
        {
            DataTable dt = dal.Select();

            dgvUsers.DataSource = dt;
        }