/// <summary> /// When the client select the user that wants to edit the not necessarily labels, tetxboxes and comboboxes are hiding /// from the form and then the neccesarily labels, tetxboxes and comboboxes are pop up. Then fills all the fields with /// the data of the selected user. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnSelect_Click(object sender, EventArgs e) { Guidelbl.Hide(); CmbUser.Hide(); BtnSelect.Hide(); label1.Show(); label2.Show(); label3.Show(); label4.Show(); label5.Show(); label6.Show(); TbxFirstName.Show(); TbxLastName.Show(); TbxUsername.Show(); TbxTelephone.Show(); TbxEmail.Show(); CmbTypes.Show(); BtnEdit.Show(); SelectedData = DCom.GetData(String.Format(SqlExec, CmbUser.SelectedValue)); TbxFirstName.Text = (string)SelectedData.Rows[0]["First_Name"]; TbxLastName.Text = (string)SelectedData.Rows[0]["Last_Name"]; TbxUsername.Text = (string)SelectedData.Rows[0]["Username"]; TbxEmail.Text = (string)SelectedData.Rows[0]["Email"]; TbxTelephone.Text = (string)SelectedData.Rows[0]["Telephone"]; DataTable GetUserType = DCom.GetData(String.Format("SELECT users_types.Type FROM users, users_types WHERE users.Username='******' and users.Type=users_types.Type", CmbUser.SelectedValue)); CmbTypes.DataSource = DCom.GetData("SELECT * FROM users_types"); CmbTypes.DisplayMember = "Type"; CmbTypes.ValueMember = "Type"; CmbTypes.Text = (string)GetUserType.Rows[0]["Type"]; }
private void BtnSelect_Click(object sender, EventArgs e) { LblBusinessDescription.Show(); LblBusinessName.Show(); LblCategory.Show(); LblPrice.Show(); LblRating.Show(); LblTelephone.Show(); LblUser.Show(); LblWebsite.Show(); LblWorkHours.Show(); LblBusinessType.Show(); LblLocation.Show(); TbxBusinessName.Show(); TbxCategory.Show(); TbxDescription.Show(); TbxPrice.Show(); TbxRating.Show(); TbxTelephone.Show(); TbxWebsite.Show(); CmbLocation.Show(); CmbTypes.Show(); CmbUser.Show(); CmbWorkHours.Show(); ChbReservation.Show(); BtnEdit.Show(); LblSelect.Hide(); CmbBusinesses.Hide(); BtnSelect.Hide(); SelectedData = DCom.GetData(String.Format(SqlExec, CmbBusinesses.SelectedValue)); TbxBusinessName.Text = (string)SelectedData.Rows[0]["Business_Name"]; TbxCategory.Text = (string)SelectedData.Rows[0]["Category"]; TbxDescription.Text = (string)SelectedData.Rows[0]["Description"]; TbxPrice.Text = SelectedData.Rows[0]["Price_Range"].ToString(); TbxRating.Text = (string)SelectedData.Rows[0]["Rating"].ToString(); TbxTelephone.Text = (string)SelectedData.Rows[0]["Telephone"]; TbxWebsite.Text = (string)SelectedData.Rows[0]["Website"]; CmbLocation.DataSource = DCom.GetData("SELECT ID,CONCAT(Address_Name, ', ', Address_Number) AS NAME FROM location"); CmbLocation.DisplayMember = "NAME"; CmbLocation.ValueMember = "ID"; CmbTypes.DataSource = DCom.GetData("SELECT * FROM businesses_types"); CmbTypes.DisplayMember = "Type"; CmbTypes.ValueMember = "Type"; CmbUser.DataSource = DCom.GetData("SELECT * FROM users"); CmbUser.DisplayMember = "Username"; CmbUser.ValueMember = "Username"; CmbWorkHours.DataSource = DCom.GetData("SELECT * FROM work_hours"); CmbWorkHours.DisplayMember = "ID"; CmbWorkHours.ValueMember = "ID"; }