private void Txt_InputBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { Btn_Save.Focus(); Btn_Save_Click(sender, e); } }
private void dataGridView1_MouseClick(object sender, MouseEventArgs e) { Tampil(); Btn_Save.Hide(); Btn_cancel.Hide(); Btn_Update.Enabled = true; Btn_Delete.Enabled = true; }
private void ProMain_Load(object sender, EventArgs e) { ViewGrid(); 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(); }
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 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; } }