private void CustMain_Load(object sender, EventArgs e) { ViewGrid(); Hapus(); Btn_Save.Text = "Save"; Txt_CustomerNama.Focus(); }
private void Txt_CustomerEmail_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)13) { Txt_CustomerNama.Focus(); } }
private void Btn_Cancel_Click(object sender, EventArgs e) { cust_Id = 0; Hapus(); Btn_Save.Text = "Save"; Txt_Search.Enabled = true; Txt_CustomerNama.Focus(); }
void Hapus() { Txt_CustomerNama.Clear(); Txt_CustomerAlamat.Clear(); Txt_CustomerKota.Clear(); Txt_CustomerPic.Clear(); Txt_CustomerTlp.Clear(); Txt_CustomerEmail.Clear(); Txt_CustomerNama.Focus(); Txt_CustomerInputBy.Text = GlobalVariable.UserId; Txt_CustomerInputTgl.Text = DateTime.Now.ToShortDateString(); }
private void Btn_Update_Click(object sender, EventArgs e) { if (Txt_CustomerNama.Text == "") { MessageBox.Show("Nama Pelanggan harus diisi", "Perhatian", MessageBoxButtons.OK); Txt_CustomerNama.Focus(); } else { UpdateRecord(); Tampil(); } }
private void Btn_Save_Click(object sender, EventArgs e) { if (Txt_CustomerNama.Text == "") { MessageBox.Show("Nama Pelanggan harus diisi", "Perhatian", MessageBoxButtons.OK); Txt_CustomerNama.Focus(); } try { Connection con = new Connection(); SqlDataAdapter sda_cek = new SqlDataAdapter("select * from CustomerInfo where CustomerId = '" + Txt_CustomerId.Text + "'", con.ActiveCon()); SqlCommand command_cek = new SqlCommand(); DataTable dt_cek = new DataTable(); sda_cek.Fill(dt_cek); if (dt_cek.Rows.Count > 1) { MessageBox.Show("Nama Pelanggan : " + Txt_CustomerId.Text + " sudah ada", "Perhatian", MessageBoxButtons.OK); } else { SqlDataAdapter sda = new SqlDataAdapter("Tambah_Pro_Id", con.ActiveCon()); sda.SelectCommand.CommandType = CommandType.StoredProcedure; //SqlCommand command = new SqlCommand //{ // CommandType = CommandType.StoredProcedure //}; //MySqlCommand command = new MySqlCommand(); //command.CommandType = CommandType.StoredProcedure; DataTable dt = new DataTable(); sda.Fill(dt); Txt_CustomerId.Text = dt.Rows[0][0].ToString(); AddNewRecord(); ViewGrid(); Btn_Save.Hide(); Btn_cancel.Hide(); Btn_Update.Enabled = true; Btn_Delete.Enabled = true; Txt_Search.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Perhatian"); } }
private void Btn_cancel_Click(object sender, EventArgs e) { if (dataGridView1.Rows.Count > 0) { Tampil(); Btn_Delete.Enabled = true; Btn_Update.Enabled = true; } else { Btn_Delete.Enabled = false; Btn_Update.Enabled = false; } Btn_Save.Hide(); Btn_cancel.Hide(); Txt_Search.Enabled = true; Txt_CustomerNama.Focus(); }
private bool validateform() { bool output = true; if (Txt_CustomerNama.Text == "") { output = false; MessageBox.Show("Nama Pelanggan harus diisi", "Perhatian", MessageBoxButtons.OK); Txt_CustomerNama.Focus(); } else if (Txt_CustomerTlp.Text == "" && Txt_CustomerEmail.Text == "") { output = false; MessageBox.Show("No. Telepon/Email harus diisi", "Perhatian", MessageBoxButtons.OK); Txt_CustomerTlp.Focus(); } try { using (IDbConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings[db].ConnectionString)) { var p = new DynamicParameters(); p.Add("@Cust_Id", cust_Id); p.Add("@CustomerNama", Txt_CustomerNama.Text); var Hitung = connection.ExecuteScalar <int>("dbo.SpCust_Cek_Nama", p, commandType: CommandType.StoredProcedure); if (Hitung == 1) { output = false; MessageBox.Show($"Nama Pelanggan {Txt_CustomerNama.Text} sudah ada", "Perhatian", MessageBoxButtons.OK, MessageBoxIcon.Error); Txt_CustomerNama.Focus(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } return(output); }
private void Btn_New_Click(object sender, EventArgs e) { { Txt_CustomerId.Clear(); Txt_CustomerNama.Clear(); Txt_CustomerAlamat.Clear(); Txt_CustomerKota.Clear(); Txt_CustomerPic.Clear(); Txt_CustomerTlp.Clear(); Txt_CustomerEmail.Clear(); Txt_CustomerNama.Focus(); Txt_CustomerInputBy.Text = GlobalVariable.UserId; Txt_CustomerInputTgl.Text = DateTime.Now.ToShortDateString(); Btn_Save.Show(); Btn_cancel.Show(); Btn_Update.Enabled = false; Btn_Delete.Enabled = false; Txt_Search.Enabled = false; } }