private void button2_Click(object sender, EventArgs e) // Button Simpan { cekTanggal(); if (flagperintah == 1)//tambah data { //txtKodePro.ReadOnly = false; if (cektxt() == true) { if (System.DateTime.Now.Year - DateTime.Parse(dateBirth.Text).Year < 13) { DialogResult dr = MessageBox.Show("Umur customer minimal adalah 13 tahun, silahkan periksa kembali data yang dimasukan", "iNBC", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { errorProvider1.Clear(); iNBC.Entity.Customer Cus = new Entity.Customer(createcustomerid(), txtNama.Text, DateTime.Parse(dateBirth.Text), cmbJK.Text, txtAlamat.Text, txtTelepon.Text, txtEmail.Text, txtAlergi.Text, System.DateTime.Now, 0, createcustomerpassword(), 1); try { CUS_C.addCustomer(Cus); clearall(); todayCustomer++; this.Hide(); PengelolaanCustomer myParent = (PengelolaanCustomer)this.Parent; myParent.enable(); myParent.Show(); } catch (SqlException ex) { if (ex.Number == 2627) { DialogResult drErrorSQL = MessageBox.Show("Error pada customer ID", "iNBC", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } } } else { //txtKodePro.ReadOnly = true; if (cektxt() == true) { // errorProvider1.Clear(); //iNBC.Entity.Promo Pro = new Entity.Promo(txtKodePro.Text, txtNama.Text, float.Parse(txtDiskon.Text), DateTime.Parse(dateStart.Text), DateTime.Parse(dateEnd.Text), cmbStatusPro.Text, 1); DialogResult dr = MessageBox.Show("Apakah anda yakin ingin mengubah data produk " + temp_promo, "iNBC", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { //PRO_C.editPromo(Pro, txtID.Text); DialogResult drX = MessageBox.Show("Data Produk berhasil diubah", "iNBC", MessageBoxButtons.OK, MessageBoxIcon.Information); } clearall(); this.Hide(); PengelolaanCustomer myParent = (PengelolaanCustomer)this.Parent; myParent.Enableedit(); } } }