public void LoadRecords(string search) { try { SQLConn.sqL = "SELECT cl_id, client_name, alamat, no_telp, email FROM client_project WHERE client_name LIKE '" + search.Trim() + "%' ORDER By client_name"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.dr = SQLConn.cmd.ExecuteReader(); ListViewItem x = null; listView1.Items.Clear(); while (SQLConn.dr.Read() == true) { x = new ListViewItem(SQLConn.dr["cl_id"].ToString()); x.SubItems.Add(SQLConn.dr["client_name"].ToString()); x.SubItems.Add(SQLConn.dr["alamat"].ToString()); x.SubItems.Add(SQLConn.dr["no_telp"].ToString()); x.SubItems.Add(SQLConn.dr["email"].ToString()); listView1.Items.Add(x); } } catch (Exception ex) { Interaction.MsgBox(ex.Message); } finally { SQLConn.cmd.Dispose(); SQLConn.conn.Close(); } }
private void GetStaffID() { try { SQLConn.sqL = "SELECT no_id FROM staff ORDER BY no_id DESC"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.dr = SQLConn.cmd.ExecuteReader(); if (SQLConn.dr.Read() == true) { txtno_id.Text = (Convert.ToInt32(SQLConn.dr["no_id"]) + 1).ToString(); } else { txtno_id.Text = "1"; } } catch (Exception ex) { Interaction.MsgBox(ex.ToString()); } finally { SQLConn.cmd.Dispose(); SQLConn.conn.Close(); } }
public void LoadRecord() { try { SQLConn.sqL = "SELECT o_id ,(SELECT project_category FROM category_project WHERE ct_id = order_project.ct_id) AS Category, (SELECT client_name FROM client_project WHERE cl_id = order_project.cl_id) AS Client, nama_product, tanggal_dimulai FROM order_project"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.dr = SQLConn.cmd.ExecuteReader(); ListViewItem x = null; listView1.Items.Clear(); while (SQLConn.dr.Read() == true) { x = new ListViewItem(SQLConn.dr["o_id"].ToString()); x.SubItems.Add(SQLConn.dr["Category"].ToString()); x.SubItems.Add(SQLConn.dr["Client"].ToString()); x.SubItems.Add(SQLConn.dr["nama_product"].ToString()); x.SubItems.Add(SQLConn.dr["tanggal_dimulai"].ToString()); listView1.Items.Add(x); } } catch (Exception ex) { Interaction.MsgBox(ex.ToString()); } finally { SQLConn.cmd.Dispose(); SQLConn.conn.Close(); } }
public void LoadRecord() { try { SQLConn.sqL = "SELECT ct_id, project_category FROM category_project"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.dr = SQLConn.cmd.ExecuteReader(); ListViewItem x = null; listView1.Items.Clear(); while (SQLConn.dr.Read() == true) { x = new ListViewItem(SQLConn.dr["ct_id"].ToString()); x.SubItems.Add(SQLConn.dr["project_category"].ToString()); listView1.Items.Add(x); } } catch (Exception ex) { Interaction.MsgBox(ex.Message); } finally { SQLConn.cmd.Dispose(); SQLConn.conn.Close(); } }
private void UpdateStaff() { try { SQLConn.sqL = "Update staff SET nama_lengkap = '" + txtnama_lengkap.Text + "', nama_panggilan = '" + txtnama_panggilan.Text + "', jenis_kelamin = '" + cmbjenis_kelamin.Text + "', tempat_lahir = '" + txttempat_lahir.Text + "', tanggal_lahir = '" + dtptanggal_lahir.Text + "', agama = '" + cmbagama.Text + "', status_pernikahan = '" + cmbstatus_pernikahan.Text + "', alamat = '" + txtalamat.Text + "', no_kontak = '" + txtno_kontak.Text + "', email = '" + txtemail.Text + "', pendidikan_terakhir = '" + txtpendidikan_terakhir.Text + "', akademik = '" + cmbakademik.Text + "', jurusan = '" + txtjurusan.Text + "', tgl_masuk = '" + dtptanggal_masuk.Text + "', posisi = '" + cmbposisi.Text + "', username = '******', password = '******' WHERE no_id = '" + pegawai_id + "'"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.cmd.ExecuteNonQuery(); Interaction.MsgBox("Data Pegawai Telah Di Update", MsgBoxStyle.Information, "Update Data Pegawai"); } catch (Exception ex) { Interaction.MsgBox(ex.ToString()); } finally { SQLConn.cmd.Dispose(); SQLConn.conn.Close(); } }
private void cmboid_SelectedIndexChanged(object sender, EventArgs e) { SQLConn.sqL = "SELECT o_id, (SELECT project_category FROM category_project WHERE ct_id = order_project.ct_id) AS Category, (SELECT client_name FROM client_project WHERE cl_id = order_project.cl_id) AS Client, nama_product, ct_id, cl_id FROM order_project WHERE o_id='" + cmboid.Text + "';"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.dr = SQLConn.cmd.ExecuteReader(); try { while (SQLConn.dr.Read()) { string sct_id = SQLConn.dr["Category"].ToString(); txtct.Text = sct_id; string scl_id = SQLConn.dr["Client"].ToString(); txtcl.Text = scl_id; string n_p = SQLConn.dr["nama_product"].ToString(); txtnp.Text = n_p; string ctid = SQLConn.dr["ct_id"].ToString(); txtctid.Text = ctid; string clid = SQLConn.dr["cl_id"].ToString(); txtclid.Text = clid; } } catch (Exception ex) { MessageBox.Show(ex.Message); } if (!string.IsNullOrEmpty(cmboid.Text) && !string.IsNullOrEmpty(txtno1.Text)) //cmbid + no urut = o_id_no { txtoidno1.Text = (Convert.ToString(cmboid.Text) + "-" + Convert.ToString(txtno1.Text)); } if (!string.IsNullOrEmpty(cmboid.Text) && !string.IsNullOrEmpty(txtno2.Text)) { txtoidno2.Text = (Convert.ToString(cmboid.Text) + "-" + Convert.ToString(txtno2.Text)); } if (!string.IsNullOrEmpty(cmboid.Text) && !string.IsNullOrEmpty(txtno3.Text)) { txtoidno3.Text = (Convert.ToString(cmboid.Text) + "-" + Convert.ToString(txtno3.Text)); } if (!string.IsNullOrEmpty(cmboid.Text) && !string.IsNullOrEmpty(txtno4.Text)) { txtoidno4.Text = (Convert.ToString(cmboid.Text) + "-" + Convert.ToString(txtno4.Text)); } if (!string.IsNullOrEmpty(cmboid.Text) && !string.IsNullOrEmpty(txtno5.Text)) { txtoidno5.Text = (Convert.ToString(cmboid.Text) + "-" + Convert.ToString(txtno5.Text)); } }
//______________________________________________________________________________________________________________________________________________ Category Project //********************************************************************************************************************************************** //______________________________________________________________________________________________________________________________________________ Client Project private void btnsavecl_Click(object sender, EventArgs e) { if (txtnamaclient.Text == "") { MessageBox.Show("Harap Check Kembali Inputan Anda", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtnamaclient.Focus(); return; } try { SQLConn.sqL = "SELECT cl_id FROM client_project WHERE cl_id=@find"; SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.ConnDB(); SQLConn.cmd.Parameters.Add(new MySqlParameter("@find", MySql.Data.MySqlClient.MySqlDbType.Int16, 5, "cl_id")); SQLConn.cmd.Parameters["@find"].Value = txtclid.Text; SQLConn.dr = SQLConn.cmd.ExecuteReader(); if (SQLConn.dr.Read()) { MessageBox.Show("Harap Masukkan No ID Yang Belum Terdaftar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtctid.Text = ""; txtctid.Focus(); if ((SQLConn.dr != null)) { SQLConn.dr.Close(); } return; } SQLConn.sqL = "INSERT INTO client_project(cl_id, client_name, alamat, no_telp, email) VALUES ('" + txtclid.Text + "', '" + txtnamaclient.Text + "', '" + txtalamatcl.Text + "','" + txttelpcl.Text + "','" + txtemailcl.Text + "')"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.dr = SQLConn.cmd.ExecuteReader(); MessageBox.Show("Berhasil Disimpan", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadRecordClID(); Resetcl(); } catch (Exception ex) { Interaction.MsgBox(ex.ToString()); } finally { SQLConn.cmd.Dispose(); SQLConn.conn.Close(); } }
private void btnsave_Click(object sender, EventArgs e) { if (txtnosurat.Text == "" && cmboid.SelectedIndex == -1) { MessageBox.Show("No Surat Tidak Boleh Kosong!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtnosurat.Focus(); return; } try { SQLConn.sqL = "SELECT no_surat FROM spgb WHERE no_surat=@find"; SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.ConnDB(); SQLConn.cmd.Parameters.Add(new MySqlParameter("@find", MySql.Data.MySqlClient.MySqlDbType.VarChar, 15, "no_surat")); SQLConn.cmd.Parameters["@find"].Value = txtnosurat.Text; SQLConn.dr = SQLConn.cmd.ExecuteReader(); if (SQLConn.dr.Read()) { MessageBox.Show("Harap Masukkan No Surat Yang Belum Terdaftar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtnosurat.Text = ""; txtnosurat.Focus(); if ((SQLConn.dr != null)) { SQLConn.dr.Close(); } return; } SQLConn.sqL = "INSERT INTO spgb(no_surat, lampiran, perihal, tgl_dibuat, no_kontrak, tgl_kontrak, o_id, no) VALUES ('" + txtnosurat.Text + "', '" + txtlmp.Text + "', '" + txtprl.Text + "','" + dtpdibuat.Text + "','" + txtnokontrak.Text + "','" + dtpkontrak.Text + "','" + cmboid.Text + "','" + txtno.Text + "')"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.dr = SQLConn.cmd.ExecuteReader(); MessageBox.Show("Berhasil Disimpan", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadRecord(); Reset(); } catch (Exception ex) { Interaction.MsgBox(ex.ToString()); } finally { SQLConn.cmd.Dispose(); SQLConn.conn.Close(); } }
public void DeleteCliID() { try { SQLConn.sqL = "DELETE FROM client_project WHERE cl_id=" + txtclid.Text + ""; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.dr = SQLConn.cmd.ExecuteReader(); MessageBox.Show("Data Berhasil Di Hapus", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Update() { try { txtnosurat.Text = listView1.FocusedItem.Text; SQLConn.sqL = "UPDATE spgb SET lampiran = '" + txtlmp.Text + "', perihal = '" + txtprl.Text + "', tgl_dibuat = '" + dtpdibuat.Text + "', no_kontrak = '" + txtnokontrak.Text + "', tgl_kontrak = '" + dtpkontrak.Text + "' WHERE no_surat='" + this.txtnosurat.Text + "'"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.cmd.ExecuteNonQuery(); Interaction.MsgBox("Data Telah Di Update", MsgBoxStyle.Information, "Update Data"); LoadRecord(); LoadList(""); } catch (Exception) { MessageBox.Show("Harap Pilih Data Yang Akan Di Hapus", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void Delete() { try { txtnosurat.Text = listView1.FocusedItem.Text; SQLConn.sqL = "DELETE FROM spgb WHERE no_surat='" + this.txtnosurat.Text + "';"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.dr = SQLConn.cmd.ExecuteReader(); MessageBox.Show("Data Surat Berhasil Di Hapus", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadRecord(); LoadList(""); } catch (Exception) { MessageBox.Show("Harap Pilih Data Yang Akan Di Hapus", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void DeleteStaff() { try { txtno_id.Enabled = false; txtno_id.Text = ListView1.FocusedItem.Text; SQLConn.sqL = "DELETE FROM staff WHERE no_id='" + this.txtno_id.Text + "';"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.dr = SQLConn.cmd.ExecuteReader(); MessageBox.Show("Data Pegawai Berhasil Di Hapus", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadStaffs(""); } catch (Exception) { MessageBox.Show("Harap Pilih Data Yang Akan Di Hapus", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void LoadRecord() { try { SQLConn.sqL = "SELECT * FROM spgb"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.dr = SQLConn.cmd.ExecuteReader(); } catch (Exception ex) { Interaction.MsgBox(ex.ToString()); } finally { SQLConn.cmd.Dispose(); SQLConn.conn.Close(); } }
private void cmbcl_SelectedIndexChanged(object sender, EventArgs e) { SQLConn.sqL = "SELECT * FROM client_project WHERE client_name='" + cmbcl.Text + "';"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.dr = SQLConn.cmd.ExecuteReader(); try { while (SQLConn.dr.Read()) { string scl_id = SQLConn.dr.GetInt32("cl_id").ToString(); txtclido.Text = scl_id; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void LoadUpdateStaff() { try { SQLConn.sqL = "SELECT * FROM staff WHERE no_id = '" + pegawai_id + "'"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.dr = SQLConn.cmd.ExecuteReader(); if (SQLConn.dr.Read() == true) { txtno_id.Text = SQLConn.dr["no_id"].ToString(); txtnama_lengkap.Text = SQLConn.dr["nama_lengkap"].ToString(); txtnama_panggilan.Text = SQLConn.dr["nama_panggilan"].ToString(); cmbjenis_kelamin.Text = SQLConn.dr["jenis_kelamin"].ToString(); txttempat_lahir.Text = SQLConn.dr["tempat_lahir"].ToString(); dtptanggal_lahir.Text = SQLConn.dr["tanggal_lahir"].ToString(); txtalamat.Text = SQLConn.dr["alamat"].ToString(); cmbagama.Text = SQLConn.dr["agama"].ToString(); cmbstatus_pernikahan.Text = SQLConn.dr["status_pernikahan"].ToString(); txtno_kontak.Text = SQLConn.dr["no_kontak"].ToString(); txtemail.Text = SQLConn.dr["email"].ToString(); txtpendidikan_terakhir.Text = SQLConn.dr["pendidikan_terakhir"].ToString(); txtjurusan.Text = SQLConn.dr["jurusan"].ToString(); cmbakademik.Text = SQLConn.dr["akademik"].ToString(); dtptanggal_masuk.Text = SQLConn.dr["tgl_masuk"].ToString(); cmbposisi.Text = SQLConn.dr["posisi"].ToString(); txtusername.Text = SQLConn.dr["username"].ToString(); txtpassword.Text = SQLConn.dr["password"].ToString(); txtconfirmpwd.Text = SQLConn.dr["password"].ToString(); } } catch (Exception ex) { Interaction.MsgBox(ex.ToString()); } finally { SQLConn.cmd.Dispose(); SQLConn.conn.Close(); } }
private void Updateoid() { try { SQLConn.sqL = "UPDATE order_project SET ct_id = '" + txtctido.Text + "', cl_id='" + txtclido.Text + "', nama_product ='" + txtnamaproducto.Text + "', tanggal_dimulai = '" + dtptanggaldimulai.Text + "' WHERE o_id='" + txtoid.Text + "'"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.cmd.ExecuteNonQuery(); Interaction.MsgBox("Data Telah Di Update", MsgBoxStyle.Information, "Update Data"); } catch (Exception ex) { Interaction.MsgBox(ex.ToString()); } finally { SQLConn.cmd.Dispose(); SQLConn.conn.Close(); } }
private void UpdateCliID() { try { SQLConn.sqL = "UPDATE client_project SET client_name = '" + txtnamaclient.Text + "', alamat='" + txtalamatcl.Text + "', no_telp='" + txttelpcl.Text + "', email = '" + txtemailcl.Text + "' WHERE cl_id='" + txtclid.Text + "'"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.cmd.ExecuteNonQuery(); Interaction.MsgBox("Data Telah Di Update", MsgBoxStyle.Information, "Update Data"); } catch (Exception ex) { Interaction.MsgBox(ex.ToString()); } finally { SQLConn.cmd.Dispose(); SQLConn.conn.Close(); } }
private void UpdateCatID() { try { SQLConn.sqL = "UPDATE category_project SET project_category = '" + txtjenisct.Text + "' WHERE ct_id='" + txtctid.Text + "'"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.cmd.ExecuteNonQuery(); Interaction.MsgBox("Data Telah Di Update", MsgBoxStyle.Information, "Update Data"); } catch (Exception ex) { Interaction.MsgBox(ex.ToString()); } finally { SQLConn.cmd.Dispose(); SQLConn.conn.Close(); } }
private void cmbclo() { try { SQLConn.sqL = "SELECT client_name FROM client_project"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.dr = SQLConn.cmd.ExecuteReader(); while (SQLConn.dr.Read()) { cmbcl.Items.Add(SQLConn.dr[0]); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } cmbcl.SelectedIndex = -1; }
public void LoadStaffs(string search) { try { SQLConn.sqL = "SELECT no_id, nama_lengkap, jenis_kelamin, tempat_lahir, tanggal_lahir, alamat, agama, status_pernikahan, no_kontak, email, posisi, username FROM staff WHERE nama_lengkap LIKE '" + search.Trim() + "%' ORDER By nama_lengkap"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.dr = SQLConn.cmd.ExecuteReader(); ListViewItem x = null; ListView1.Items.Clear(); while (SQLConn.dr.Read() == true) { x = new ListViewItem(SQLConn.dr["no_id"].ToString()); x.SubItems.Add(SQLConn.dr["nama_lengkap"].ToString()); x.SubItems.Add(SQLConn.dr["jenis_kelamin"].ToString()); x.SubItems.Add(SQLConn.dr["tempat_lahir"].ToString()); x.SubItems.Add(SQLConn.dr["tanggal_lahir"].ToString()); x.SubItems.Add(SQLConn.dr["alamat"].ToString()); x.SubItems.Add(SQLConn.dr["agama"].ToString()); x.SubItems.Add(SQLConn.dr["status_pernikahan"].ToString()); x.SubItems.Add(SQLConn.dr["no_kontak"].ToString()); x.SubItems.Add(SQLConn.dr["email"].ToString()); x.SubItems.Add(SQLConn.dr["posisi"].ToString()); x.SubItems.Add(SQLConn.dr["username"].ToString()); ListView1.Items.Add(x); } } catch (Exception ex) { Interaction.MsgBox(ex.Message); } finally { SQLConn.cmd.Dispose(); SQLConn.conn.Close(); } }
private void loadrecord() { try { SQLConn.sqL = "SELECT o_id, no,(SELECT client_name FROM client_project WHERE cl_id = detail_product.cl_id) AS Client, (SELECT nama_product FROM order_project WHERE o_id = detail_product.o_id) AS Product, nama_barang, jumlah, satuan, harga_satuan, jumlah_harga, (SELECT project_category FROM category_project WHERE ct_id = detail_product.ct_id) AS Category, (SELECT tanggal_dimulai FROM order_project WHERE o_id = detail_product.o_id) AS Tanggal FROM detail_product"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.dr = SQLConn.cmd.ExecuteReader(); ListViewItem x = null; listView1.Items.Clear(); while (SQLConn.dr.Read() == true) { x = new ListViewItem(SQLConn.dr["o_id"].ToString()); x.SubItems.Add(SQLConn.dr["no"].ToString()); x.SubItems.Add(SQLConn.dr["Client"].ToString()); x.SubItems.Add(SQLConn.dr["Product"].ToString()); x.SubItems.Add(SQLConn.dr["nama_barang"].ToString()); x.SubItems.Add(Strings.Format(SQLConn.dr["jumlah"], "#,##0".ToString())); x.SubItems.Add(SQLConn.dr["satuan"].ToString()); x.SubItems.Add(Strings.Format(SQLConn.dr["harga_satuan"], "#,##0".ToString())); x.SubItems.Add(Strings.Format(SQLConn.dr["jumlah_harga"], "#,##0".ToString())); x.SubItems.Add(SQLConn.dr["Category"].ToString()); x.SubItems.Add(SQLConn.dr["Tanggal"].ToString()); listView1.Items.Add(x); } } catch (Exception ex) { Interaction.MsgBox(ex.ToString()); } finally { SQLConn.cmd.Dispose(); SQLConn.conn.Close(); } }
private void button3_Click(object sender, EventArgs e) //button3 = "Save" { SQLConn.sqL = "SELECT no_id FROM staff WHERE no_id=@find"; SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.ConnDB(); SQLConn.cmd.Parameters.Add(new MySqlParameter("@find", MySql.Data.MySqlClient.MySqlDbType.Int16, 5, "no_id")); SQLConn.cmd.Parameters["@find"].Value = txtno_id.Text; SQLConn.dr = SQLConn.cmd.ExecuteReader(); if (SQLConn.dr.Read()) { MessageBox.Show("Harap Masukkan No ID Yang Belum Terdaftar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtno_id.Text = ""; txtno_id.Focus(); if ((SQLConn.dr != null)) { SQLConn.dr.Close(); } return; } if (SQLConn.adding == true) { AddStaff(); } else { UpdateStaff(); } if (System.Windows.Forms.Application.OpenForms["frmListStaff"] != null) { (System.Windows.Forms.Application.OpenForms["frmListStaff"] as frmListStaff).LoadStaffs(""); } this.Close(); }
//______________________________________________________________________________________________________________________________________________ Client Project //********************************************************************************************************************************************** //______________________________________________________________________________________________________________________________________________ Order Project private void auto_oid() { string id; string ND; // "CHHRT" or whatever; int sequence; try { SQLConn.sqL = "SELECT o_id FROM order_project ORDER BY o_id DESC"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.dr = SQLConn.cmd.ExecuteReader(); if (SQLConn.dr.Read() == true) { id = SQLConn.dr[0].ToString(); sequence = int.Parse(new string(id.Where(char.IsDigit).ToArray())); ND = new string(id.Where(char.IsLetter).ToArray()); id = ND + (sequence + 1).ToString("000"); txtoid.Text = id; } else { txtoid.Text = "ND001"; } } catch (Exception ex) { Interaction.MsgBox(ex.ToString()); } finally { SQLConn.cmd.Dispose(); SQLConn.conn.Close(); } }
private void LoadReport() { try { SQLConn.sqL = "SELECT no_surat, lampiran, perihal, tgl_dibuat, no_kontrak, tgl_kontrak, o_id FROM spgb"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.da = new MySqlDataAdapter(SQLConn.cmd); this.ReportSIP.DataSPGB.Clear(); SQLConn.da.Fill(this.ReportSIP.DataSPGB); this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout); this.reportViewer1.ZoomPercent = 90; this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent; this.reportViewer1.RefreshReport(); } catch (Exception ex) { Interaction.MsgBox(ex.ToString()); } }
private void LoadReport() { try { SQLConn.sqL = "SELECT no_id, nama_lengkap, jenis_kelamin, tempat_lahir, tanggal_lahir, alamat, agama, status_pernikahan, no_kontak, email, posisi FROM staff"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.da = new MySqlDataAdapter(SQLConn.cmd); this.ReportSIP.DataStaff.Clear(); SQLConn.da.Fill(this.ReportSIP.DataStaff); this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout); this.reportViewer1.ZoomPercent = 90; this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent; this.reportViewer1.RefreshReport(); } catch (Exception ex) { Interaction.MsgBox(ex.ToString()); } }
private void cmbo_id() { try { SQLConn.sqL = "SELECT o_id FROM order_project"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.dr = SQLConn.cmd.ExecuteReader(); while (SQLConn.dr.Read()) { cmboid.Items.Add(SQLConn.dr[0]); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } cmboid.SelectedIndex = -1; dtpdibuat.Value = DateTime.Today; dtpkontrak.Value = DateTime.Today; }
private void AddStaff() { try { SQLConn.sqL = "INSERT INTO staff(no_id, nama_lengkap, nama_panggilan, jenis_kelamin, tempat_lahir, tanggal_lahir, alamat, agama, status_pernikahan, no_kontak, email, pendidikan_terakhir, akademik, jurusan, posisi, tgl_masuk, username, password) VALUES('" + txtno_id.Text + "', '" + txtnama_lengkap.Text + "', '" + txtnama_panggilan.Text + "', '" + cmbjenis_kelamin.Text + "', '" + txttempat_lahir.Text + "', '" + dtptanggal_lahir.Text + "', '" + txtalamat.Text + "', '" + cmbagama.Text + "', '" + cmbstatus_pernikahan.Text + "', '" + txtno_kontak.Text + "', '" + txtemail.Text + "', '" + txtpendidikan_terakhir.Text + "', '" + cmbakademik.Text + "', '" + txtjurusan.Text + "', '" + cmbposisi.Text + "', '" + dtptanggal_masuk.Text + "', '" + txtusername.Text + "', '" + txtpassword.Text + "')"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.cmd.ExecuteNonQuery(); Interaction.MsgBox("Data Pegawai Telah Berhasil Ditambah", MsgBoxStyle.Information, "Tambah Pegawai"); } catch (Exception ex) { Interaction.MsgBox(ex.ToString()); } finally { SQLConn.cmd.Dispose(); SQLConn.conn.Close(); } }
public void LoadRecord() { try { SQLConn.sqL = "SELECT o_id_no, no, nama_barang, jumlah, satuan, harga_satuan, jumlah_harga FROM detail_product"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.dr = SQLConn.cmd.ExecuteReader(); ListViewItem x = null; listView1.Items.Clear(); while (SQLConn.dr.Read() == true) { x = new ListViewItem(SQLConn.dr["o_id_no"].ToString()); x.SubItems.Add(SQLConn.dr["no"].ToString()); x.SubItems.Add(SQLConn.dr["nama_barang"].ToString()); x.SubItems.Add(Strings.Format(SQLConn.dr["jumlah"], "#,##0".ToString())); x.SubItems.Add(SQLConn.dr["satuan"].ToString()); x.SubItems.Add(Strings.Format(SQLConn.dr["harga_satuan"], "#,##0".ToString())); x.SubItems.Add(Strings.Format(SQLConn.dr["jumlah_harga"], "#,##0".ToString())); listView1.Items.Add(x); } } catch (Exception ex) { Interaction.MsgBox(ex.ToString()); } finally { SQLConn.cmd.Dispose(); SQLConn.conn.Close(); } }
private void frmMain_Load(object sender, EventArgs e) { SQLConn.getData(); this.lbluser.Text = "Login user : " + Username.ToUpper(); }
private void btnsaveo_Click(object sender, EventArgs e) { try { if (txtoid.Text == "") { MessageBox.Show("Please enter Order ID", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtoid.Focus(); return; } if (cmbct.Text == "") { MessageBox.Show("Please select category", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbct.Focus(); return; } if (cmbcl.Text == "") { MessageBox.Show("Please select Client", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbcl.Focus(); return; } if (txtnamaproducto.Text == "") { MessageBox.Show("Please enter Nama Product", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtnamaproducto.Focus(); return; } SQLConn.sqL = "SELECT o_id FROM order_project WHERE o_id=@find"; SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.ConnDB(); SQLConn.cmd.Parameters.Add(new MySqlParameter("@find", MySql.Data.MySqlClient.MySqlDbType.VarChar, 10, "o_id")); SQLConn.cmd.Parameters["@find"].Value = txtoid.Text; SQLConn.dr = SQLConn.cmd.ExecuteReader(); if (SQLConn.dr.Read()) { MessageBox.Show("Harap Masukkan No ID Yang Belum Terdaftar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtoid.Text = ""; txtoid.Focus(); if ((SQLConn.dr != null)) { SQLConn.dr.Close(); } return; } SQLConn.sqL = "INSERT INTO order_project(o_id, ct_id, cl_id, nama_product, tanggal_dimulai) VALUES ('" + txtoid.Text + "', '" + txtctido.Text + "', '" + txtclido.Text + "','" + txtnamaproducto.Text + "','" + dtptanggaldimulai.Text + "')"; SQLConn.ConnDB(); SQLConn.cmd = new MySqlCommand(SQLConn.sqL, SQLConn.conn); SQLConn.dr = SQLConn.cmd.ExecuteReader(); MessageBox.Show("Berhasil Disimpan", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadRecordOID(); Resetoid(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }