private void StudentForm_Load(object sender, EventArgs e) { LoadDataIntoComboBoxes(); if (this.IsUpdate) { DbSqlServer db = new DbSqlServer(AppSettings.ConnectionString()); DataTable dtBranch = db.GetDataList("usp_StudentsGetAllStudentByStudentId", new DbParameter() { Parameter = "@StudentId", Value = this.StudentId }); DataRow row = dtBranch.Rows[0]; StudentIdTextBox.Text = row["StudentId"].ToString(); FullNameTextBox.Text = row["FullName"].ToString(); FatherNameTextBox.Text = row["FatherName"].ToString(); MotherNameTextBox.Text = row["MotherName"].ToString(); DOBDateTimePicker.Text = row["DOB"].ToString(); AddressTextBox.Text = row["Address"].ToString(); EmailTextBox.Text = row["Email"].ToString(); AdmissionDateDateTimePicker.Text = row["AdmissionDate"].ToString(); MobileTextBox.Text = row["Mobile"].ToString(); BloodGroupTextBox.Text = row["BloodGroup"].ToString(); GenderComboBox.SelectedValue = row["GenderId"]; BranchComboBox.SelectedValue = row["BranchId"]; ImagepictureBox.Image = (row["Photo"] is DBNull) ? null : ImageManipulation.PutPhoto((byte[])row["Photo"]); } else { GenerateStudentId(); } }
public static void LoadDataIntoComboBox(ComboBox cb, String storeProceName, DbParameter[] parameters) { DbSqlServer db = new DbSqlServer(AppSettings.ConnectionString()); cb.DataSource = db.GetDataList(storeProceName, parameters); cb.DisplayMember = "Description"; cb.ValueMember = "Id"; cb.SelectedIndex = -1; cb.DropDownStyle = ComboBoxStyle.DropDownList; }
public static void LoadDataIntoComboBox(ComboBox cb, DbParameter parameter) { DbSqlServer db = new DbSqlServer(AppSettings.ConnectionString()); cb.DataSource = db.GetDataList("usp_ListTypeDataGetDataByListTypeId", parameter); cb.DisplayMember = "Description"; cb.ValueMember = "Id"; cb.SelectedIndex = -1; cb.DropDownStyle = ComboBoxStyle.DropDownList; }
public static void LoadDataIntoGridView(DataGridView dgv, string storedProceName) { DbSqlServer db = new DbSqlServer(AppSettings.ConnectionString()); dgv.DataSource = db.GetDataList(storedProceName); dgv.MultiSelect = false; dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect; }
private void EmployeeInfoForm_Load(object sender, EventArgs e) { LoadDataIntoComboBoxes(); if (this.IsUpdate) { DbSqlServer db = new DbSqlServer(AppSettings.ConnectionString()); DataTable dtBranch = db.GetDataList("usp_EmployeesGetAllEmployeesByEmployeeId", new DbParameter() { Parameter = "@EmployeeId", Value = this.EmployeeId }); DataRow row = dtBranch.Rows[0]; EmployeeIdTextBox.Text = row["EmployeeId"].ToString(); FullNameTextBox.Text = row["FullName"].ToString(); DOBdateTimePicker.Text = row["DateOfBirth"].ToString(); NICTextBox.Text = row["NICNumber"].ToString(); EmailAddressTextBox.Text = row["EmailAddress"].ToString(); MobileTextBox.Text = row["Mobile"].ToString(); TelephoneTextBox.Text = row["Telephone"].ToString(); GenderComboBox.SelectedValue = row["GenderId"]; EmploymentDatedateTimePicker.Text = row["EmploymentDate"].ToString(); BranchComboBox.SelectedValue = row["BranchId"]; EmployeePictureBox.Image = (row["Photo"] is DBNull) ? null : ImageManipulation.PutPhoto((byte[])row["Photo"]); AddressLineTextBox.Text = row["AddressLine"].ToString(); CityComboBox.SelectedValue = row["CityId"]; DistrictComboBox.SelectedValue = row["DistrictId"]; PostCodeTextBox.Text = row["PostCode"].ToString(); JobTitleComboBox.SelectedValue = row["JObTitleId"]; CurrentSalaryTextBox1.Text = row["CurrentSalary"].ToString(); StartingSalaryTextBox.Text = row["StartingSalary"].ToString(); HasLeftComboBox.SelectedValue = row["HasLeft"]; DateLeftDateTimePicker.Text = row["DateLeft"].ToString(); ReasonLeftComboBox.SelectedValue = row["ReasonLeftId"]; CommentsTextBox.Text = row["Comments"].ToString(); } else { GenerateEmployeeId(); } }
private void LoadDataAndBindToControlIfUpdate() { if (this.IsUpdate) { DbSqlServer db = new DbSqlServer(AppSettings.ConnectionString()); DataTable dtBranch = db.GetDataList("usp_BranchesGetBranchDetailsByBranchId", new DbParameter() { Parameter = "@BranchId", Value = this.BranchId }); DataRow row = dtBranch.Rows[0]; BranchNametextBox.Text = row["BranchName"].ToString(); EmailAddressTextBox.Text = row["Email"].ToString(); TelephoneTextBox.Text = row["Telephone"].ToString(); WebsiteTextBox.Text = row["Website"].ToString(); AddressLineTextBox.Text = row["AddressLine"].ToString(); LogoPictureBox.Image = (row["BranchImage"] is DBNull)? null:ImageManipulation.PutPhoto((byte[])row["BranchImage"]); CityNameComboBox.SelectedValue = row["CityId"]; DistrictNameComboBox.SelectedValue = row["DistrictId"]; PostCodeTextBox.Text = row["PostCode"].ToString(); } }