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(); } }
private void ucitajPodatke() { DbSqlServer db = new DbSqlServer(AppOpcije.konekcioniString()); DataTable dtRadnici = db.vratiPodatkeLista("vratiRadnikaNaOsnouvIdRadnika", new DbParametri { Parametar = "@IdRadnika", Vrijednost = this.radnikId }); DataRow red = dtRadnici.Rows[0]; txtRadnikID.Text = red["IdRadnika"].ToString(); txtIme.Text = red["Ime"].ToString(); txtPrezime.Text = red["Prezime"].ToString(); dtpDatumRodjenja.Value = Convert.ToDateTime(red["Datum rođenja"]); txtKorIme.Text = red["Korisničko ime"].ToString(); txtSifra.Text = red["Šifra"].ToString(); txtTelefon.Text = red["Telefon"].ToString(); txtAdresa.Text = red["Adresa"].ToString(); txtTrenutnaPlata.Text = red["Trenutna plata"].ToString(); txtPocetnaPlata.Text = red["Početna plata"].ToString(); cmbUloga.SelectedValue = red["IdUloge"]; pcbSlika.Image = (red["Slika"] is DBNull) ? null : SlikaUpravljanje.staviSliku((byte[])red["Slika"]); if (pcbSlika.Image == null) { pcbSlika.BackgroundImage = POS.Properties.Resources.no_photo; } }
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 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; }
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; }
//ucitavanje podataka u combo box pri ucitavanju forme public static void ucitajPodatkeUcmb(ComboBox cmb, DbParametri parametar) { DbSqlServer db = new DbSqlServer(AppOpcije.konekcioniString()); cmb.DataSource = db.vratiPodatkeLista("vratiListeNaOsnovuId", parametar); cmb.DisplayMember = "Naziv"; cmb.ValueMember = "SifJM"; cmb.SelectedIndex = -1; cmb.DropDownStyle = ComboBoxStyle.DropDownList; }
private void frmKontrolnaTabla_Load(object sender, EventArgs e) { DbSqlServer db = new DbSqlServer(AppOpcije.konekcioniString()); DataTable dtArikli = db.vratiPodatkeLista("infoKorisnik", new DbParametri { Parametar = "@KorIme", Vrijednost = frmPrijava.postaviIme }); DataRow red = dtArikli.Rows[0]; lblImeRadnika.Text = red["Ime"].ToString() + " " + red["Prezime"].ToString(); imeRadnika = red["Ime"].ToString(); prezimeRadnika = red["Prezime"].ToString(); }
/// <summary> /// 构造数据库访问类 /// </summary> public QfDbConnector(string binPath) { switch (DbType) { case "postgresql": _db = new DbPostgreSql(binPath); break; case "sqlserver": _db = new DbSqlServer(binPath); break; default: _db = new DbMySql(binPath); break; } }
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 SignInButton_Click(object sender, EventArgs e) { if (IsFormValidate()) { DbSqlServer db = new DbSqlServer(AppSettings.ConnectionString()); bool isLoginDetailsCorrect = Convert.ToBoolean(db.GetScalerValue("usp_UsersCheckLoginDetails", GetParameters())); if (isLoginDetailsCorrect) { GetLoggedInUserSetting(); this.Hide(); DashboardForm dashboardForm = new DashboardForm(); dashboardForm.Show(); } else { MessageBox.Show("User Name/Password is not correct", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
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(); } }
//ucitavanje podataka iz dgv-a u formu nakon dvostrukog klika private void ucitajPodatake() { if (this.JeAzuriran) { DbSqlServer db = new DbSqlServer(AppOpcije.konekcioniString()); DataTable dtArikli = db.vratiPodatkeLista("vratiDetaljeArtiklaNaOsnovuIdProizvoda", new DbParametri { Parametar = "@IdProizvoda", Vrijednost = this.artiklID }); DataRow red = dtArikli.Rows[0]; txtIdProizvoda.Text = red["IdProizvoda"].ToString(); txtNazivArtikla.Text = red["Naziv"].ToString(); txtCijena.Text = red["Cijena"].ToString(); txtOpis.Text = red["Opis"].ToString(); cmbJedMjere.SelectedValue = red["SifJM"]; cmbKategorije.SelectedValue = red["IdKategorije"]; pcbLogo.Image = (red["Slika"] is DBNull) ? null : SlikaUpravljanje.staviSliku((byte[])red["Slika"]); } }
private void btnPrijava_Click(object sender, EventArgs e) { postaviIme = txtKorIme.Text; postaviSifru = txtSifra.Text; if (formaValidna()) { DbSqlServer db = new DbSqlServer(AppOpcije.konekcioniString()); bool detaljiPrijaveTacni = Convert.ToBoolean(db.vratiSkalarnuVrijednost("provjeraPrijave", vratiParametre())); if (detaljiPrijaveTacni) { this.Hide(); frmKontrolnaTabla forma = new frmKontrolnaTabla(); forma.Show(); } else { MessageBox.Show("Netačno korisničko ime ili šifra.", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void generisiNoviId() { DbSqlServer db = new DbSqlServer(AppOpcije.konekcioniString()); txtRadnikID.Text = db.vratiSkalarnuVrijednost("radniciGenerisiNoviId").ToString(); }
//ucitavanje podataka u dgv pri ucitavanju forme public static void ucitajPodatkeUdgv(DataGridView dgv, string storedProceIme) { DbSqlServer db = new DbSqlServer(AppOpcije.konekcioniString()); dgv.DataSource = db.vratiPodatkeLista(storedProceIme); }
private void generisiNoviId() { DbSqlServer db = new DbSqlServer(AppOpcije.konekcioniString()); txtIdProizvoda.Text = db.vratiSkalarnuVrijednost("proizvodiGenerisiNoviId").ToString(); }
private void SaveOrUpdateRecord(string storeProceName) { DbSqlServer db = new DbSqlServer(AppSettings.ConnectionString()); db.SaveOrUpdatRecord(storeProceName, GetObject()); }
private void GenerateEmployeeId() { DbSqlServer db = new DbSqlServer(AppSettings.ConnectionString()); EmployeeIdTextBox.Text = db.GetScalerValue("usp_EmployeesGenerateNewEmployeeId").ToString(); }
public static DbBase CreateConnection() { if (Enum.IsDefined(typeof(ConnectionTypes), Settings.Default.DbConnectionType)) { _connType = (ConnectionTypes)Settings.Default.DbConnectionType; } else { _connType = ConnectionTypes.Unknown; } string connString = Settings.Default.DbConnectionString; string defaultSchema = Settings.Default.DbDefaultSchema; bool promptPwd = Settings.Default.DbPromptPwd; if ((_connType == ConnectionTypes.Unknown) || String.IsNullOrEmpty(connString) || ((DbBase.GetBackend(connString, _connType) != Backends.Access) && String.IsNullOrEmpty(defaultSchema))) { promptPwd = false; SelectConnectionType(); } if (_connType == ConnectionTypes.Unknown) { return(null); } DbBase db = null; switch (_connType) { case ConnectionTypes.ODBC: db = new DbOdbc(ref connString, ref defaultSchema, ref promptPwd, Properties.Resources.PasswordMaskString, Settings.Default.UseAutomaticCommandBuilders, true, Settings.Default.DbIsUnicode, Settings.Default.DbUseTimeZone, Settings.Default.DbTextLength, Settings.Default.DbBinaryLength, Settings.Default.DbTimePrecision, Settings.Default.DbNumericPrecision, Settings.Default.DbNumericScale); break; case ConnectionTypes.OleDb: db = new DbOleDb(ref connString, ref defaultSchema, ref promptPwd, Properties.Resources.PasswordMaskString, Settings.Default.UseAutomaticCommandBuilders, true, Settings.Default.DbIsUnicode, Settings.Default.DbUseTimeZone, Settings.Default.DbTextLength, Settings.Default.DbBinaryLength, Settings.Default.DbTimePrecision, Settings.Default.DbNumericPrecision, Settings.Default.DbNumericScale); break; case ConnectionTypes.Oracle: db = new DbOracle(ref connString, ref defaultSchema, ref promptPwd, Properties.Resources.PasswordMaskString, Settings.Default.UseAutomaticCommandBuilders, true, Settings.Default.DbIsUnicode, Settings.Default.DbUseTimeZone, Settings.Default.DbTextLength, Settings.Default.DbBinaryLength, Settings.Default.DbTimePrecision, Settings.Default.DbNumericPrecision, Settings.Default.DbNumericScale); break; case ConnectionTypes.PostgreSQL: db = new DbPgSql(ref connString, ref defaultSchema, ref promptPwd, Properties.Resources.PasswordMaskString, Settings.Default.UseAutomaticCommandBuilders, true, Settings.Default.DbIsUnicode, Settings.Default.DbUseTimeZone, Settings.Default.DbTextLength, Settings.Default.DbBinaryLength, Settings.Default.DbTimePrecision, Settings.Default.DbNumericPrecision, Settings.Default.DbNumericScale); break; case ConnectionTypes.SQLServer: db = new DbSqlServer(ref connString, ref defaultSchema, ref promptPwd, Properties.Resources.PasswordMaskString, Settings.Default.UseAutomaticCommandBuilders, true, Settings.Default.DbIsUnicode, Settings.Default.DbUseTimeZone, Settings.Default.DbTextLength, Settings.Default.DbBinaryLength, Settings.Default.DbTimePrecision, Settings.Default.DbNumericPrecision, Settings.Default.DbNumericScale); break; } if (db != null) { Settings.Default.DbConnectionType = (int)_connType; Settings.Default.DbConnectionString = connString; Settings.Default.DbDefaultSchema = defaultSchema; Settings.Default.DbPromptPwd = promptPwd; Settings.Default.Save(); } return(db); }
private void dodavanjeUkorpu(string storedProceIme) { DbSqlServer db = new DbSqlServer(AppOpcije.konekcioniString()); db.snimiIliAzurirajZapis(storedProceIme, vratiObjekt()); }
private void generisiNoviId() { DbSqlServer db = new DbSqlServer(AppOpcije.konekcioniString()); txtIdNarudzbe.Text = db.vratiSkalarnuVrijednost("korpaGenerisiNoviId").ToString(); }
public static DbBase CreateConnection() { if (Enum.IsDefined(typeof(ConnectionTypes), Settings.Default.DbConnectionType)) _connType = (ConnectionTypes)Settings.Default.DbConnectionType; else _connType = ConnectionTypes.Unknown; string connString = Settings.Default.DbConnectionString; string defaultSchema = Settings.Default.DbDefaultSchema; bool promptPwd = Settings.Default.DbPromptPwd; if ((_connType == ConnectionTypes.Unknown) || String.IsNullOrEmpty(connString) || ((DbBase.GetBackend(connString, _connType) != Backends.Access) && String.IsNullOrEmpty(defaultSchema))) { promptPwd = false; SelectConnectionType(); } if (_connType == ConnectionTypes.Unknown) return null; DbBase db = null; switch (_connType) { case ConnectionTypes.ODBC: db = new DbOdbc(ref connString, ref defaultSchema, ref promptPwd, Properties.Resources.PasswordMaskString, Settings.Default.UseAutomaticCommandBuilders, true, Settings.Default.DbIsUnicode, Settings.Default.DbUseTimeZone, Settings.Default.DbTextLength, Settings.Default.DbBinaryLength, Settings.Default.DbTimePrecision, Settings.Default.DbNumericPrecision, Settings.Default.DbNumericScale); break; case ConnectionTypes.OleDb: db = new DbOleDb(ref connString, ref defaultSchema, ref promptPwd, Properties.Resources.PasswordMaskString, Settings.Default.UseAutomaticCommandBuilders, true, Settings.Default.DbIsUnicode, Settings.Default.DbUseTimeZone, Settings.Default.DbTextLength, Settings.Default.DbBinaryLength, Settings.Default.DbTimePrecision, Settings.Default.DbNumericPrecision, Settings.Default.DbNumericScale); break; case ConnectionTypes.Oracle: db = new DbOracle(ref connString, ref defaultSchema, ref promptPwd, Properties.Resources.PasswordMaskString, Settings.Default.UseAutomaticCommandBuilders, true, Settings.Default.DbIsUnicode, Settings.Default.DbUseTimeZone, Settings.Default.DbTextLength, Settings.Default.DbBinaryLength, Settings.Default.DbTimePrecision, Settings.Default.DbNumericPrecision, Settings.Default.DbNumericScale); break; case ConnectionTypes.PostgreSQL: db = new DbPgSql(ref connString, ref defaultSchema, ref promptPwd, Properties.Resources.PasswordMaskString, Settings.Default.UseAutomaticCommandBuilders, true, Settings.Default.DbIsUnicode, Settings.Default.DbUseTimeZone, Settings.Default.DbTextLength, Settings.Default.DbBinaryLength, Settings.Default.DbTimePrecision, Settings.Default.DbNumericPrecision, Settings.Default.DbNumericScale); break; case ConnectionTypes.SQLServer: db = new DbSqlServer(ref connString, ref defaultSchema, ref promptPwd, Properties.Resources.PasswordMaskString, Settings.Default.UseAutomaticCommandBuilders, true, Settings.Default.DbIsUnicode, Settings.Default.DbUseTimeZone, Settings.Default.DbTextLength, Settings.Default.DbBinaryLength, Settings.Default.DbTimePrecision, Settings.Default.DbNumericPrecision, Settings.Default.DbNumericScale); break; } if (db != null) { Settings.Default.DbConnectionType = (int)_connType; Settings.Default.DbConnectionString = connString; Settings.Default.DbDefaultSchema = defaultSchema; Settings.Default.DbPromptPwd = promptPwd; Settings.Default.Save(); } return db; }
private void GenerateStudentId() { DbSqlServer db = new DbSqlServer(AppSettings.ConnectionString()); StudentIdTextBox.Text = db.GetScalerValue("usp_StudentsGenerateNewStudentId").ToString(); }