예제 #1
0
        public SettingSales(IDbConnection conn)
        {
            InitializeComponent();
            _conn = conn;

            DAL shipper = null;

            try
            {
                shipper = new DAL();
                DataSet ds = shipper.Get_Sales_Data_Full(_conn);

                if (ds != null && ds.Tables.Count > 0)
                {
                    DataTable dt = ds.Tables[0];

                    foreach (DataRow dr in dt.Rows)
                    {
                        textBoxKodeSales.Text = dr["kodeSales"].ToString();
                        textBoxUsername.Text = dr["username"].ToString();
                        textBoxPassword.Text = dr["password"].ToString();
                        textBoxRWPassword.Text = dr["password"].ToString();
                        textBoxNamaSales.Text = dr["namaSales"].ToString();
                        textBoxAlamat.Text = dr["alamat"].ToString();
                        textBoxNoTelp.Text = dr["noTelp"].ToString();
                        textBoxEmail.Text = dr["email"].ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        public ForgetPass(IDbConnection conn)
        {
            InitializeComponent();
            _conn = conn;

            DAL shipper = null;
            IDataReader reader = null;

            try
            {
                shipper = new DAL();
                reader = shipper.Cek_Sales(_conn);

                if (reader.Read())
                {
                    textBoxUsername.Text = reader[0].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                    reader.Dispose();
                }
            }
        }
예제 #3
0
        public AddCarForm(IDbConnection conn, int tmpidCustomer)
        {
            InitializeComponent();
            _conn = conn;

            DAL shipper = null;

            try
            {
                shipper = new DAL();
                DataSet ds = shipper.Get_Customer_Data_ADDCAR(_conn, tmpidCustomer);

                if (ds != null && ds.Tables.Count > 0)
                {
                    DataTable dt = ds.Tables[0];

                    foreach (DataRow dr in dt.Rows)
                    {
                        tbidCustomer.Text = tmpidCustomer.ToString();
                        namacus_db.Text = dr["namaCustomer"].ToString();
                        DateTime dob = Convert.ToDateTime(dr["tglLahir"].ToString());
                        tgllahircus_db.Text = dob.ToString("dd MMMM yyyy");
                        tbAgama.Text = dr["agama"].ToString();
                        alamat_db.Text = dr["alamat"].ToString();
                        notlpn_db.Text = dr["noTelp"].ToString();
                        hp1_db.Text = dr["noHP1"].ToString();
                        hp2_db.Text = dr["noHP2"].ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBoxKodeSales.Text.Length == 0 || textBoxNamaSales.Text.Length == 0 || textBoxNoTelp.Text.Length == 0 || textBoxPassword.Text.Length == 0 || textBoxRWPassword.Text.Length == 0 || textBoxUsername.Text.Length == 0)
            {
                MessageBox.Show("There are some field that empty");
            }
            else
            {
                DAL shipper = null;

                try
                {
                    shipper = new DAL();
                    shipper.Register_Sales(_conn, textBoxKodeSales.Text, textBoxUsername.Text, textBoxPassword.Text, textBoxNamaSales.Text, textBoxAlamat.Text, textBoxNoTelp.Text, textBoxEmail.Text);

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                MessageBox.Show("Register Success");
                Hide();
                using (Login l = new Login(_conn)) //if data ok, form will close it self!
                {
                    if (l.ShowDialog() == DialogResult.OK)
                    {

                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    this.DialogResult = DialogResult.OK;

                }
            }
        }
예제 #5
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            DAL shipper = null;
            IDataReader reader = null;

            try
            {
                shipper = new DAL();
                reader = shipper.Cek_Sales(_conn);

                if (reader.Read())
                {
                    if (!textBoxUsername.Text.Equals(reader.GetString(0)) || !textBoxPassword.Text.Equals(reader.GetString(1)) )
                    {
                        MessageBox.Show("Username atau Password Salah");

                    }
                    else
                    {
                        MessageBox.Show("Login Berhasil");
                        this.DialogResult = DialogResult.OK;

                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                    reader.Dispose();
                }
            }
        }
예제 #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBoxKodeSales.Text.Length == 0 || textBoxNamaSales.Text.Length == 0 || textBoxNoTelp.Text.Length == 0 || textBoxPassword.Text.Length == 0 || textBoxRWPassword.Text.Length == 0 || textBoxUsername.Text.Length == 0)
            {
                MessageBox.Show("There are some field that empty");
            }
            else
            {
                DAL shipper = null;

                try
                {
                    shipper = new DAL();
                    shipper.update_Setting_Sales(_conn, textBoxKodeSales.Text, textBoxUsername.Text, textBoxPassword.Text, textBoxNamaSales.Text, textBoxAlamat.Text, textBoxNoTelp.Text, textBoxEmail.Text);
                    MessageBox.Show("Data have been update.");
                    this.Close();
                }
                catch(Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
예제 #7
0
        private void buttonChange_Click(object sender, EventArgs e)
        {
            if (flagPass == 1 && flagConPass == 1 && textBoxUsername.Text.Length != 0 && textBoxNPass.Text.Length != 0 && textBoxCNPass.Text.Length != 0)
            {
                DAL shipper = null;

                try
                {
                    shipper = new DAL();
                    shipper.updateSales(_conn, textBoxUsername.Text, textBoxCNPass.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                MessageBox.Show("Password Change Succeed.");
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("Errors Occured");
            }
        }
예제 #8
0
        private void getData()
        {
            try
            {
                aksesLayer = new DAL();
                DataSet ds = null;
                if (keySearch != null && wordSearch != null && keySort != null)
                {
                    if (keySearch.Equals("idCustomer"))
                    {
                        queryPlus = "AND c." + keySearch + " = " + wordSearch + " ORDER BY " + keySort;
                    }
                    else
                    {
                        queryPlus = "AND " + keySearch + " LIKE '" + wordSearch + "%'" + "ORDER BY " + keySort;
                    }
                }

                if (keySearch != null || wordSearch != null || keySort != null)
                {
                    ds = aksesLayer.Get_AllCustomer_Data(_conn, queryPlus);
                }
                else
                {
                    ds = aksesLayer.Get_AllCustomer_Data(_conn);
                }

                if (ds != null && ds.Tables.Count > 0)
                {
                    listView1.Items.Clear();
                    DataTable dt = ds.Tables[0];

                    foreach (DataRow dr in dt.Rows)
                    {
                        ListViewItem lvi = new ListViewItem();
                        lvi.Text = dr["idCustomer"].ToString();
                        lvi.SubItems.Add(dr["namaCustomer"].ToString());
                        lvi.SubItems.Add(dr["alamat"].ToString());
                        lvi.SubItems.Add(dr["noTelp"].ToString());
                        lvi.SubItems.Add(dr["noHP1"].ToString());
                        lvi.SubItems.Add(dr["email"].ToString());
                        lvi.SubItems.Add(dr["tipeMobil"].ToString());
                        lvi.SubItems.Add(dr["tglDelivery"].ToString());
                        lvi.SubItems.Add(dr["tglSTNK"].ToString());
                        lvi.SubItems.Add(dr["caraPembayaran"].ToString());
                        listView1.Items.Add(lvi);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #9
0
        private void retrieve_salesData()
        {
            DAL toyota = new DAL();
            IDataReader reader = null;
            //SALES DATA
            try
            {
            statusData.Text = "Retreiving sales data";
            reader = toyota.Get_Sales_Data(_conn);

            if (reader.Read())
            {
                labelKodeSales.Text = reader[0].ToString();
                GKodeSales = reader[0].ToString();
                labelNamaSales.Text = reader[1].ToString();
                labelAlamat.Text = reader[2].ToString();
                labelNoTelepon.Text = reader[3].ToString();
                labelEmail.Text = reader[4].ToString();
            }
            }
            catch(Exception ex)
            {
                throw new Exception("Faild to retrieve sales data", ex);
            }
        }
예제 #10
0
        public MenuUtama(IDbConnection conn)
        {
            InitializeComponent();
            _conn = conn;

            DAL shipper = null;
            IDataReader reader = null;
            current = DateTime.Now;

            try
            {
                shipper = new DAL();
                reader = shipper.Cek_Sales(_conn);

                if (reader.Read())
                {
                    Hide();
                    using (Login l = new Login(_conn)) //if data ok, form will close it self!
                    {
                        if (l.ShowDialog() == DialogResult.OK)
                        {
                            this.Visible = true;
                        }
                        else
                        {
                            _conn.Close();
                            _conn.Dispose();
                            Application.Exit();
                        }
                    }
                }
                else
                {
                    Hide();
                    using (Register c = new Register(_conn)) //if data ok, form will close it self!
                    {
                        if (c.ShowDialog() == DialogResult.OK)
                        {
                            this.Visible = true;
                        }
                        else
                        {
                            _conn.Close();
                            _conn.Dispose();
                            Application.Exit();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                    reader.Dispose();
                }
            }
            retrieve_salesData();
            retrieve_pageData(current);
        }
예제 #11
0
        private void retrieve_pageData(DateTime currentDate)
        {
            DAL toyota = new DAL();
            DateTime shortDate = Convert.ToDateTime(currentDate.ToShortDateString());
            int amount = 0;
            try
            {
                //BIRTHDAY DATA
                try
                {
                    statusData.Text = "Retreiving birthday data";
                    DataSet bds = toyota.Get_Birthday_Data(_conn, currentDate);

                    if (bds != null && bds.Tables.Count > 0)
                    {
                        listViewBirthday.Items.Clear();
                        DataTable bdt = bds.Tables[0];

                        foreach (DataRow bdr in bdt.Rows)
                        {
                            ListViewItem blvi = new ListViewItem();
                            blvi.Text = bdr["namaCustomer"].ToString();
                            blvi.SubItems.Add(bdr["noTelp"].ToString());
                            blvi.SubItems.Add(bdr["noHP1"].ToString());
                            blvi.SubItems.Add(bdr["noHP2"].ToString());
                            listViewBirthday.Items.Add(blvi);
                            amount++;
                        }

                    }
                    else
                    {
                        lblJmlBirthday.Text = "No birthday found";
                    }
                    lblJmlBirthday.Text = amount.ToString();
                }
                catch (Exception ex)
                {
                    throw new Exception("Failed to retrieve birthday data", ex);
                }

                //STNK DATA
                try
                {
                    statusData.Text = "Retreiving STNK data";
                    DataSet sds = toyota.Get_STNK_Data(_conn, currentDate);
                    amount = 0;

                    if (sds != null && sds.Tables.Count > 0)
                    {
                        listViewSTNK.Items.Clear();
                        DataTable sdt = sds.Tables[0];
                        foreach (DataRow sdr in sdt.Rows)
                        {
                            String stnkTimeLeft = null;
                            int hitunganLeftSTNK = 0;
                            DateTime datelineSTNK = Convert.ToDateTime(sdr["habisSTNK"].ToString());
                            hitunganLeftSTNK = (6 - Convert.ToInt32(currentDate.DayOfWeek)) + Convert.ToInt32(datelineSTNK.DayOfWeek);
                            if (hitunganLeftSTNK > 6)
                                stnkTimeLeft = (Convert.ToInt32(datelineSTNK.DayOfWeek) - Convert.ToInt32(currentDate.DayOfWeek)).ToString() + " days left";
                            else if (currentDate.ToShortDateString().Equals(datelineSTNK.ToShortDateString()))
                                stnkTimeLeft = "Last Date";
                            else
                                stnkTimeLeft = hitunganLeftSTNK.ToString() + " days left";

                            ListViewItem slvi = new ListViewItem();
                            slvi.Text = sdr["namaCustomer"].ToString();
                            slvi.SubItems.Add(sdr["noTelp"].ToString());
                            slvi.SubItems.Add(sdr["noHP1"].ToString());
                            slvi.SubItems.Add(sdr["noHP2"].ToString());
                            slvi.SubItems.Add(stnkTimeLeft);
                            listViewSTNK.Items.Add(slvi);
                            amount++;
                        }

                    }
                    else
                    {
                        ListViewItem slvi = new ListViewItem();
                        slvi.Text = "No";
                        slvi.SubItems.Add("STNK");
                        slvi.SubItems.Add("Data");
                        slvi.SubItems.Add("Found");
                        listViewSTNK.Items.Add(slvi);
                    }
                    lblJmlSTNK.Text = amount.ToString();
                }
                catch (Exception ex)
                {
                    throw new Exception("Failed to retrieve STNK data", ex);
                }

                //ASURANSI DATA
                try
                {
                    statusData.Text = "Retreiving asuransi data";
                    DataSet ads = toyota.Get_Asuransi_Data(_conn, currentDate);
                    amount = 0;

                    if (ads != null && ads.Tables.Count > 0)
                    {
                        listViewAsuransi.Items.Clear();
                        DataTable adt = ads.Tables[0];

                        foreach (DataRow adr in adt.Rows)
                        {
                            String asuransiTimeLeft = null;
                            int hitunganLeftAsuransi = 0;
                            DateTime datelineAsuransi = Convert.ToDateTime(adr["habisAsuransi"].ToString());
                            hitunganLeftAsuransi = (6 - Convert.ToInt32(currentDate.DayOfWeek)) + Convert.ToInt32(datelineAsuransi.DayOfWeek);
                            if (hitunganLeftAsuransi > 6)
                                asuransiTimeLeft = (Convert.ToInt32(datelineAsuransi.DayOfWeek) - Convert.ToInt32(currentDate.DayOfWeek)).ToString() + " days left";
                            else if (currentDate == datelineAsuransi)
                                asuransiTimeLeft = "Last Date";
                            else
                                asuransiTimeLeft = hitunganLeftAsuransi.ToString() + " days left";

                            ListViewItem alvi = new ListViewItem();
                            alvi.Text = adr["namaCustomer"].ToString();
                            alvi.SubItems.Add(adr["noTelp"].ToString());
                            alvi.SubItems.Add(adr["noHP1"].ToString());
                            alvi.SubItems.Add(adr["noHP2"].ToString());
                            alvi.SubItems.Add(asuransiTimeLeft);
                            listViewAsuransi.Items.Add(alvi);
                            amount++;
                        }
                    }
                    else
                    {
                        ListViewItem alvi = new ListViewItem();
                        alvi.Text = "No";
                        alvi.SubItems.Add("ASURANSI");
                        alvi.SubItems.Add("Data");
                        alvi.SubItems.Add("Found");
                        listViewAsuransi.Items.Add(alvi);
                    }
                    lbljmlAsuransi.Text = amount.ToString();
                }
                catch (Exception ex)
                {
                    throw new Exception("Failed to retrieve asuransi data", ex);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Fail to retrieve home data", ex);
            }
        }
예제 #12
0
        private void btn_submit_Click(object sender, EventArgs e)
        {
            String namaPerusahaanAsuransi = "";
            DateTime? tglAsuransi = null;
            int jumlahTahunAsuransi = 0;
            int tmpJmlTahunKredit = 0;
            int tmpidCustomer = Convert.ToInt32(tbidCustomer.Text);

            if (tipeMobilTxt.Text == null || warnaMobilTxt.Text == null || tgldo_hari.Text.Length == 0 || tgldo_bulan.Text.Length == 0 || tgldo_tahun.Text.Length == 0 || tglstnk_hari.Text.Length == 0 || tglstnk_bulan.Text.Length == 0 || tglstnk_tahun.Text.Length == 0)
            {
                MessageBox.Show("There are some field that empty");
            }
            else
            {
                DAL shipper = null;

                DateTime tanggaldo = convertToDate(tgldo_hari.Text, tgldo_bulan.Text, tgldo_tahun.Text);

                if (npa.Text != "")
                {
                    namaPerusahaanAsuransi = npa.Text;
                    if (tglasuransi_hari.Text != "" && tglasuransi_bulan.Text != "" && tglasuransi_tahun.Text != "")
                        tglAsuransi = convertToDate(tglasuransi_hari.Text, tglasuransi_bulan.Text, tglasuransi_tahun.Text);

                    if (combobox_jta.SelectedItem.ToString() != "")
                        jumlahTahunAsuransi = Convert.ToInt32(combobox_jta.SelectedItem.ToString());
                }

                DateTime tanggalSTNK = convertToDate(tglstnk_hari.Text, tglstnk_bulan.Text, tglstnk_tahun.Text);

                try
                {
                    shipper = new DAL();
                    string pembayaran;

                    if (radiobtn_credit.Checked)
                    {
                        pembayaran = "Credit";
                        tmpJmlTahunKredit = Convert.ToInt32(combobox_jtk.SelectedItem.ToString());
                    }
                    else
                    {
                        pembayaran = "Cash";
                    }

                    //Insert Transaksi
                    shipper.Add_Transaksi(_conn, tmpidCustomer, tipeMobilTxt.Text , warnaMobilTxt.Text, tanggaldo,
                                          tanggalSTNK, tglAsuransi, namaPerusahaanAsuransi, jumlahTahunAsuransi, pembayaran,
                                          tmpJmlTahunKredit);

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                MessageBox.Show("Add Car Success");
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
예제 #13
0
        private void btn_submit_Click(object sender, EventArgs e)
        {
            DateTime? tglLahirKeluarga1 = null;
            DateTime? tglLahirKeluarga2 = null;
            DateTime? tglLahirKeluarga3 = null;
            DateTime? tglLahirKeluarga4 = null;
            String namaPerusahaanAsuransi = "";
            DateTime? tglAsuransi = null;
            string tmpAgama = null;
            string tmpJenKel = null;
            int tmpidCustomer=0;
            int jumlahTahunAsuransi = 0;
            int tmpJmlTahunKredit =0;

            if (namacus.Text.Length == 0 || alamat.Text.Length == 0 || notlpn.Text.Length == 0 || hp1.Text.Length == 0 || tgllahircus_hari.Text.Length == 0 || tgllahircus_bulan.Text.Length == 0 || tgllahircus_tahun.Text.Length == 0 || tipeMobilTxt.Text == null || warnaMobilTxt.Text == null || tgldo_hari.Text.Length == 0 || tgldo_bulan.Text.Length == 0 || tgldo_tahun.Text.Length == 0 || tglstnk_hari.Text.Length == 0 || tglstnk_bulan.Text.Length == 0 || tglstnk_tahun.Text.Length == 0)
            {
                MessageBox.Show("There are some field that empty");
            }
            else
            {
                DAL shipper = null;

                DateTime tglLahirCustomer = convertToDate(tgllahircus_hari.Text, tgllahircus_bulan.Text, tgllahircus_tahun.Text);

                if (ak1.Text != "")
                    if (tgllahir1_hari.Text != "" && tgllahir1_bulan.Text != "" && tgllahir1_tahun.Text != "")
                        tglLahirKeluarga1 = convertToDate(tgllahir1_hari.Text, tgllahir1_bulan.Text, tgllahir1_tahun.Text);

                if (ak2.Text != "")
                    if (tgllahir2_hari.Text != "" && tgllahir2_bulan.Text != "" && tgllahir2_tahun.Text != "")
                        tglLahirKeluarga2 = convertToDate(tgllahir2_hari.Text, tgllahir2_bulan.Text, tgllahir2_tahun.Text);

                if (ak3.Text != "")
                    if (tgllahir3_hari.Text != "" && tgllahir3_bulan.Text != "" && tgllahir3_tahun.Text != "")
                        tglLahirKeluarga3 = convertToDate(tgllahir3_hari.Text, tgllahir3_bulan.Text, tgllahir3_tahun.Text);

                if (ak4.Text != "")
                    if (tgllahir4_hari.Text != "" && tgllahir4_bulan.Text != "" && tgllahir4_tahun.Text != "")
                        tglLahirKeluarga4 = convertToDate(tgllahir4_hari.Text, tgllahir4_bulan.Text, tgllahir4_tahun.Text);

                DateTime tanggaldo = convertToDate(tgldo_hari.Text, tgldo_bulan.Text, tgldo_tahun.Text);

                if (npa.Text != "")
                {
                    namaPerusahaanAsuransi = npa.Text;
                    if (tglasuransi_hari.Text != "" && tglasuransi_bulan.Text != "" && tglasuransi_tahun.Text != "")
                        tglAsuransi = convertToDate(tglasuransi_hari.Text, tglasuransi_bulan.Text, tglasuransi_tahun.Text);

                    if (combobox_jta.SelectedItem.ToString() != "")
                        jumlahTahunAsuransi = Convert.ToInt32(combobox_jta.SelectedItem.ToString());
                }

                DateTime tanggalSTNK = convertToDate(tglstnk_hari.Text, tglstnk_bulan.Text, tglstnk_tahun.Text);

                if (combobox_agama.SelectedIndex == -1)
                {
                    tmpAgama = "";
                }
                else
                {
                    tmpAgama = combobox_agama.SelectedItem.ToString();
                }

                if (radiobtn_pria.Checked)
                {
                    tmpJenKel = "Pria";
                }
                else if (radiobtn_wania.Checked)
                {
                    tmpJenKel = "Wanita";
                }
                else
                {
                    tmpJenKel = "Pria";
                }

                try
                {
                    shipper = new DAL();
                    string pembayaran;

                    if (radiobtn_credit.Checked)
                    {
                        pembayaran = "Credit";
                        tmpJmlTahunKredit = Convert.ToInt32(combobox_jtk.SelectedItem.ToString());
                    }
                    else
                    {
                        pembayaran = "Cash";
                    }
                    //Insert Biodata Customer
                    shipper.Add_Customer(_conn, _kodeSales, namacus.Text, tmpJenKel, alamat.Text, notlpn.Text,
                                        hp1.Text, hp2.Text, email.Text, tglLahirCustomer,
                                        tmpAgama, ak1.Text, ak2.Text,
                                        ak3.Text, ak4.Text, tglLahirKeluarga1, tglLahirKeluarga2,
                                        tglLahirKeluarga3, tglLahirKeluarga4);

                    //Get idCustomer
                    IDataReader reader = null;
                    try
                    {
                        reader = shipper.Cek_idCustomer(_conn,namacus.Text);

                        if (reader.Read())
                        {
                            tmpidCustomer = Convert.ToInt32( reader[0].ToString());
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Faild to retrieve sales data", ex);
                    }
                    finally
                    {
                        if (reader != null)
                        {
                            reader.Close();
                            reader.Dispose();
                        }
                    }

                    //Insert Transaksi
                    shipper.Add_Transaksi(_conn, tmpidCustomer, tipeMobilTxt.Text, warnaMobilTxt.Text, tanggaldo,
                                          tanggalSTNK, tglAsuransi, namaPerusahaanAsuransi, jumlahTahunAsuransi, pembayaran,
                                          tmpJmlTahunKredit);

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                MessageBox.Show("Register Success");
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
예제 #14
0
        private void getCustomer()
        {
            aksesLayer = new DAL();
            DataSet ds = null;
            DateTime dob;
            int jta;

            ds = aksesLayer.Get_Customer_Data(_conn, _idCustomer, _tipeMobil);

            if (ds != null && ds.Tables.Count > 0)
            {
                DataTable dt = ds.Tables[0];

                foreach (DataRow dr in dt.Rows)
                {
                    namacus.Text = dr["namaCustomer"].ToString();
                    dob = Convert.ToDateTime(dr["tglLahir"].ToString());
                    tgllahircus_hari.Text = dob.Day.ToString();
                    tgllahircus_bulan.Text = dob.Month.ToString();
                    tgllahircus_tahun.Text = dob.Year.ToString();
                    if (dr["jenisKelamin"].Equals("Pria"))
                    {
                        radiobtn_pria.Select();
                    }
                    else
                    {
                        radiobtn_wanita.Select();
                    }
                    if (dr["agama"].Equals("Katholik"))
                    {
                        combobox_agama.SelectedIndex = 1;
                    }
                    else if (dr["agama"].Equals("Kristen"))
                    {
                        combobox_agama.SelectedIndex = 2;

                    }
                     else if (dr["agama"].Equals("Islam"))
                    {
                        combobox_agama.SelectedIndex = 3;

                    }
                     else if (dr["agama"].Equals("Hindu"))
                    {
                        combobox_agama.SelectedIndex = 4;

                    }
                     else if (dr["agama"].Equals("Buddha"))
                    {
                        combobox_agama.SelectedIndex = 5;

                    }
                    alamat.Text = dr["alamat"].ToString();
                    notlpn.Text = dr["noTelp"].ToString();
                    hp1.Text = dr["noHP1"].ToString();
                    hp2.Text = dr["noHP2"].ToString();
                    email.Text = dr["email"].ToString();
                    ak1.Text = dr["anggotaKeluarga1"].ToString();
                    ak2.Text = dr["anggotaKeluarga2"].ToString();
                    ak3.Text = dr["anggotaKeluarga3"].ToString();
                    ak4.Text = dr["anggotaKeluarga4"].ToString();
                    if (dr["tglLahirKeluarga1"].ToString().Length == 0)
                    {
                        tgllahir1_hari.Text = null;
                        tgllahir1_bulan.Text = null;
                        tgllahir1_tahun.Text = null;
                    }
                    else
                    {
                        dob = Convert.ToDateTime(dr["tglLahirKeluarga1"].ToString());
                        tgllahir1_hari.Text = dob.Day.ToString();
                        tgllahir1_bulan.Text = dob.Month.ToString();
                        tgllahir1_tahun.Text = dob.Year.ToString();
                    }
                    if (dr["tglLahirKeluarga2"].ToString().Length == 0)
                    {
                        tgllahir2_hari.Text = null;
                        tgllahir2_bulan.Text = null;
                        tgllahir2_tahun.Text = null;
                    }
                    else
                    {
                        dob = Convert.ToDateTime(dr["tglLahirKeluarga2"].ToString());
                        tgllahir2_hari.Text = dob.Day.ToString();
                        tgllahir2_bulan.Text = dob.Month.ToString();
                        tgllahir2_tahun.Text = dob.Year.ToString();
                    }
                    if (dr["tglLahirKeluarga3"].ToString().Length == 0)
                    {
                        tgllahir3_hari.Text = null;
                        tgllahir3_bulan.Text = null;
                        tgllahir3_tahun.Text = null;
                    }
                    else
                    {
                        dob = Convert.ToDateTime(dr["tglLahirKeluarga3"].ToString());
                        tgllahir3_hari.Text = dob.Day.ToString();
                        tgllahir3_bulan.Text = dob.Month.ToString();
                        tgllahir3_tahun.Text = dob.Year.ToString();
                    }
                    if (dr["tglLahirKeluarga4"].ToString().Length == 0)
                    {
                        tgllahir4_hari.Text = null;
                        tgllahir4_bulan.Text = null;
                        tgllahir4_tahun.Text = null;
                    }
                    else
                    {
                        dob = Convert.ToDateTime(dr["tglLahirKeluarga4"].ToString());
                        tgllahir4_hari.Text = dob.Day.ToString();
                        tgllahir4_bulan.Text = dob.Month.ToString();
                        tgllahir4_tahun.Text = dob.Year.ToString();
                    }

                    tipeMobilTxt.Text = dr["tipeMobil"].ToString();
                    warnaMobilTxt.Text = dr["warnaMobil"].ToString();
                    dob = Convert.ToDateTime(dr["tglDelivery"].ToString());
                    tgldo_hari.Text = dob.Day.ToString();
                    tgldo_bulan.Text = dob.Month.ToString();
                    tgldo_tahun.Text = dob.Year.ToString();
                    dob = Convert.ToDateTime(dr["tglSTNK"].ToString());
                    tglstnk_hari.Text = dob.Day.ToString();
                    tglstnk_bulan.Text = dob.Month.ToString();
                    tglstnk_tahun.Text = dob.Year.ToString();
                    npa.Text = dr["namaAsuransi"].ToString();
                    dob = Convert.ToDateTime(dr["tglAsuransi"].ToString());
                    tglasuransi_hari.Text = dob.Day.ToString();
                    tglasuransi_bulan.Text = dob.Month.ToString();
                    tglasuransi_tahun.Text = dob.Year.ToString();
                    jta = Convert.ToInt32(dr["jmlTahunAsuransi"].ToString());
                    if (jta == 1)
                    {
                        combobox_jta.SelectedIndex = 1;
                    }
                    else if (jta == 2)
                    {
                        combobox_jta.SelectedIndex = 2;
                    }
                    else if (jta == 3)
                    {
                        combobox_jta.SelectedIndex = 3;
                    }
                    else if (jta == 4)
                    {
                        combobox_jta.SelectedIndex = 4;
                    }
                    else if (jta == 5)
                    {
                        combobox_jta.SelectedIndex = 5;
                    }
                    else
                    {
                        combobox_jta.SelectedIndex = 0;
                    }

                    if (dr["caraPembayaran"].ToString().Equals("cash") || dr["caraPembayaran"].ToString().Equals("Cash"))
                    {
                        radiobtn_cash.Select();
                    }
                    else
                    {
                        radiobtn_credit.Select();
                    }
                    if (dr["jmlTahunKredit"].ToString().Equals("1"))
                    {
                        combobox_jtk.SelectedIndex = 1;
                    }
                    else if (dr["jmlTahunKredit"].ToString().Equals("2"))
                    {
                        combobox_jtk.SelectedIndex = 2;
                    }
                    else if (dr["jmlTahunKredit"].ToString().Equals("3"))
                    {
                        combobox_jtk.SelectedIndex = 3;
                    }
                    else if (dr["jmlTahunKredit"].ToString().Equals("4"))
                    {
                        combobox_jtk.SelectedIndex = 4;
                    }
                    else if (dr["jmlTahunKredit"].ToString().Equals("5"))
                    {
                        combobox_jtk.SelectedIndex = 5;
                    }
                }
            }
        }
예제 #15
0
        private void btn_submit_Click(object sender, EventArgs e)
        {
            DateTime? tglLahirKeluarga1 = null;
            DateTime? tglLahirKeluarga2 = null;
            DateTime? tglLahirKeluarga3 = null;
            DateTime? tglLahirKeluarga4 = null;
            String namaPerusahaanAsuransi = "";
            DateTime? tglAsuransi = null;
            string tmpAgama = null;
            string jenkel = null;
            int jumlahTahunAsuransi = 0;
            int tmpJmlTahunKredit =0;

            if (namacus.Text.Length == 0 || alamat.Text.Length == 0 || notlpn.Text.Length == 0 || hp1.Text.Length == 0 || tgllahircus_hari.Text.Length == 0 || tgllahircus_bulan.Text.Length == 0 || tgllahircus_tahun.Text.Length == 0 || tipeMobilTxt.Text == null || warnaMobilTxt.Text == null || tgldo_hari.Text.Length == 0 || tgldo_bulan.Text.Length == 0 || tgldo_tahun.Text.Length == 0 || tglstnk_hari.Text.Length == 0 || tglstnk_bulan.Text.Length == 0 || tglstnk_tahun.Text.Length == 0)
            {
                MessageBox.Show("There are some field that empty");
            }
            else
            {
                DAL shipper = null;

                DateTime tglLahirCustomer = convertToDate(tgllahircus_hari.Text, tgllahircus_bulan.Text, tgllahircus_tahun.Text);

                if (ak1.Text != "")
                    if (tgllahir1_hari.Text != "" && tgllahir1_bulan.Text != "" && tgllahir1_tahun.Text != "")
                        tglLahirKeluarga1 = convertToDate(tgllahir1_hari.Text, tgllahir1_bulan.Text, tgllahir1_tahun.Text);

                if (ak2.Text != "")
                    if (tgllahir2_hari.Text != "" && tgllahir2_bulan.Text != "" && tgllahir2_tahun.Text != "")
                        tglLahirKeluarga2 = convertToDate(tgllahir2_hari.Text, tgllahir2_bulan.Text, tgllahir2_tahun.Text);

                if (ak3.Text != "")
                    if (tgllahir3_hari.Text != "" && tgllahir3_bulan.Text != "" && tgllahir3_tahun.Text != "")
                        tglLahirKeluarga3 = convertToDate(tgllahir3_hari.Text, tgllahir3_bulan.Text, tgllahir3_tahun.Text);

                if (ak4.Text != "")
                    if (tgllahir4_hari.Text != "" && tgllahir4_bulan.Text != "" && tgllahir4_tahun.Text != "")
                        tglLahirKeluarga4 = convertToDate(tgllahir4_hari.Text, tgllahir4_bulan.Text, tgllahir4_tahun.Text);

                DateTime tanggaldelivery = convertToDate(tgldo_hari.Text, tgldo_bulan.Text, tgldo_tahun.Text);

                if (npa.Text != "")
                {
                    namaPerusahaanAsuransi = npa.Text;
                    if (tglasuransi_hari.Text != "" && tglasuransi_bulan.Text != "" && tglasuransi_tahun.Text != "")
                        tglAsuransi = convertToDate(tglasuransi_hari.Text, tglasuransi_bulan.Text, tglasuransi_tahun.Text);

                    if (combobox_jta.SelectedItem.ToString() != (""))
                        jumlahTahunAsuransi = Convert.ToInt32(combobox_jta.SelectedItem.ToString());
                }

                DateTime tanggalSTNK = convertToDate(tglstnk_hari.Text, tglstnk_bulan.Text, tglstnk_tahun.Text);

                if (radiobtn_pria.Checked)
                {
                    jenkel = "Pria";
                }
                else
                {
                    jenkel = "Wanita";
                }

                if (combobox_agama.SelectedIndex == -1)
                {
                    tmpAgama = "";
                }
                else
                {
                    tmpAgama = combobox_agama.SelectedItem.ToString();
                }

                try
                {
                    shipper = new DAL();
                    string pembayaran;

                    if (radiobtn_credit.Checked)
                    {
                        pembayaran = "Credit";
                        tmpJmlTahunKredit = Convert.ToInt32(combobox_jtk.SelectedItem.ToString());
                    }
                    else
                    {
                        pembayaran = "Cash";
                    }

                    //Update Biodata Customer
                    shipper.Update_Customer_Data(_conn, _idCustomer, namacus.Text, alamat.Text, notlpn.Text,
                                        hp1.Text, hp2.Text, email.Text, tglLahirCustomer, jenkel,
                                        tmpAgama, ak1.Text, ak2.Text,
                                        ak3.Text, ak4.Text, tglLahirKeluarga1, tglLahirKeluarga2,
                                        tglLahirKeluarga3, tglLahirKeluarga4);

                    //Update Transaksi
                    shipper.Update_Customer_Car_Data(_conn, _idCustomer, _tipeMobil, tipeMobilTxt.Text, warnaMobilTxt.Text, tanggaldelivery,
                                          tanggalSTNK, tglAsuransi, namaPerusahaanAsuransi, jumlahTahunAsuransi, pembayaran,
                                          tmpJmlTahunKredit);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                MessageBox.Show("Register Success");
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }