public Data_Pemesanan(string namapemesan, string nomorhp, int berat, DateTime tglPesan, string jenis) { InitializeComponent(); mode = Mode.Edit; pelanggan = new Pelanggan { Nama = namapemesan, No_Hp = nomorhp, Berat_Cucian = Convert.ToInt32(tbberat.Text), Jenis_Paket = tbjenispaket.Text, Harga_Paket = Convert.ToDouble(tbharga.Text), Harga_Total = Convert.ToDouble(tbhargatotal.Text), Tanggal_Pemsanan = Convert.ToDateTime(dateTimePicker2.Text), Tanggal_Pengambilan = Convert.ToDateTime(dateTimePicker1.Text), }; tbnama.Text = namapemesan; tbnohp.Text = nomorhp; tbberat.Text = tbberat.Text; tbjenispaket.Text = tbjenispaket.Text; tbharga.Text = tbharga.Text; tbhargatotal.Text = tbhargatotal.Text; dateTimePicker2.Text = dateTimePicker2.Text; dateTimePicker1.Text = dateTimePicker1.Text; btnsimpan.Text = "Simpan"; }
private void SimpanData() { if (tbnama.Text != "" && tbnohp.Text != "" && tbberat.Text != "" && tbjenispaket.Text != "" && tbharga.Text != "" && tbhargatotal.Text != "" && dateTimePicker2.Text != "" && dateTimePicker1.Text != "") { using (var db = new PelangganModel()) { pelanggan = new Pelanggan { Nama = tbnama.Text, No_Hp = tbnohp.Text, Berat_Cucian = Convert.ToInt32(tbberat.Text), Jenis_Paket = tbjenispaket.Text, Harga_Paket = Convert.ToDouble(tbharga.Text), Harga_Total = Convert.ToDouble(tbhargatotal.Text), Tanggal_Pemsanan = Convert.ToDateTime(dateTimePicker2.Text), Tanggal_Pengambilan = Convert.ToDateTime(dateTimePicker1.Text), }; db.Pelanggans.Add(pelanggan); db.SaveChanges(); MessageBox.Show("Pesanan Disimpan"); } } else { MessageBox.Show("Nama, Nomor Hp, Berat Cucian, Jenis Paket, Tanggal Pemesanan harus diisi"); } }