예제 #1
0
        private void btnCetak_Click(object sender, EventArgs e)
        {
            if (this.id == "")
            {
                MessageBox.Show(this, "Maaf silahkan pilih data terlebih dahulu");
                return;
            }
            CetakStrukTransaksi cetak = new CetakStrukTransaksi();

            try
            {
                cetak.InputCetakStruk(id_member, nama, harga, no_struk, tanggal, kasir, masa_aktif, kelas, promo, "", "");
                cetak.setListBox(kelas);
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
            cetak.ShowDialog();
        }
예제 #2
0
        private void btnTransaksi_Click(object sender, EventArgs e)
        {
            try
            {
                if (cmbPromo.SelectedValue.ToString() == "9")
                {
                    if (!con.IsActiveMember(int.Parse(cmbMember.SelectedValue.ToString())))
                    {
                        MessageBox.Show(this, "Maaf, Member ini belum aktif", "Kesalahan", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    if (txtDeposit.Text == "")
                    {
                        MessageBox.Show(this, "Maaf, Harap isikan Data terlebih dahulu.", "Gagal", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    else if (con.GetDepositByIDMember(int.Parse(cmbMember.SelectedValue.ToString())) < (decimal)300000 && double.Parse(txtDeposit.Text) < 300000)
                    {
                        MessageBox.Show(this, "Maaf, Deposit anda kurang dari  Rp 300.000, silahkan deposit minimal Rp 300.000", "Kesalahan", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    else
                    {
                        con.TambahTransaksi(int.Parse(cmbPromo.SelectedValue.ToString()), int.Parse(cmbMember.SelectedValue.ToString()),
                                            null, DateTime.Now, decimal.Parse(txtDeposit.Text), Pegawai);
                        con.DepositReguler(int.Parse(cmbMember.SelectedValue.ToString()), decimal.Parse(txtDeposit.Text));
                        CetakStrukTransaksi cetak = new CetakStrukTransaksi();
                        try
                        {
                            no_struk = DateTime.Now.ToString("yy") + "." + DateTime.Now.ToString("MM") + "." + con.GetLastIdTransaksi();
                            cetak.InputCetakStruk(cmbMember.Text, txtNamaMember.Text, txtTotalHarga.Text, no_struk, DateTime.Now.ToString(), nama_pegawai, con.GetTglExpired(int.Parse(cmbMember.SelectedValue.ToString())).ToString(), "", cmbPromo.Text, "", "");
                            cetak.setListBox(kelas);
                        }
                        catch (Exception ex) { MessageBox.Show(ex.ToString()); }
                        cetak.ShowDialog();
                        MessageBox.Show(this, "Data Transaksi Berhasil Disimpan", "Sukses", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }

                else if (cmbPromo.SelectedValue.ToString() == "4")    //member get member
                {
                    //cek member aktif blm

                    if (con.IsActiveMember(int.Parse(cmbMember.SelectedValue.ToString())))
                    {
                        MessageBox.Show(this, "Member tersebut sudah aktif");
                        return;
                    }
                    else if (con.IsActiveMember(int.Parse(cmbIdMember2.SelectedValue.ToString())))
                    {
                        MessageBox.Show(this, "Member " + int.Parse(cmbIdMember2.SelectedValue.ToString()) + "sudah aktif");
                        return;
                    }
                    con.TambahTransaksi(int.Parse(cmbPromo.SelectedValue.ToString()), int.Parse(cmbMember.SelectedValue.ToString()),
                                        null, DateTime.Now, con.GetHargaPromo(int.Parse(cmbPromo.SelectedValue.ToString())), Pegawai);
                    CetakStrukTransaksi cetak = new CetakStrukTransaksi();
                    try
                    {
                        no_struk = DateTime.Now.ToString("yy") + "." + DateTime.Now.ToString("MM") + "." + con.GetLastIdTransaksi();
                        cetak.InputCetakStruk(cmbMember.Text, txtNamaMember.Text, txtTotalHarga.Text, no_struk, DateTime.Now.ToString(), nama_pegawai, con.GetTglExpired(int.Parse(cmbMember.SelectedValue.ToString())).ToString(), "", cmbPromo.Text, cmbIdMember2.Text, txtNamaMember2.Text);
                        cetak.setListBoxSetelahTransaksi(kelas);
                    }
                    catch (Exception ex) { MessageBox.Show(ex.ToString()); }
                    cetak.ShowDialog();
                    con.AktivasiTahunanMemberGetMember(int.Parse(cmbIdMember2.SelectedValue.ToString()), int.Parse(cmbMember.SelectedValue.ToString()));
                    if (Mcontrol.cekAdaTidakRecordMember(DateTime.Now.Month.ToString(), DateTime.Now.Year.ToString()) == 0)
                    {
                        Mcontrol.InsertRecordMemberBaru(DateTime.Now.Month.ToString(), DateTime.Now.Year.ToString(), Mcontrol.totalMemberAktif(), Mcontrol.totalMemberNonAktif(),
                                                        Mcontrol.totalMemberAktif() + Mcontrol.totalMemberNonAktif());
                    }
                    Mcontrol.UbahAktifMember(DateTime.Now.Month.ToString(), DateTime.Now.Year.ToString());
                    MessageBox.Show(this, "Data Transaksi Berhasil Disimpan", "Sukses", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                else if (cmbPromo.SelectedValue.ToString() == "3") //couple aktivasi
                {
                    if (con.IsActiveMember(int.Parse(cmbMember.SelectedValue.ToString())))
                    {
                        MessageBox.Show(this, "Member " + cmbMember.Text + " sudah aktif");
                        return;
                    }
                    else if (con.IsActiveMember(int.Parse(cmbIdMember2.SelectedValue.ToString())))
                    {
                        MessageBox.Show(this, "Member " + cmbIdMember2 + " sudah aktif");
                        return;
                    }
                    con.TambahTransaksi(int.Parse(cmbPromo.SelectedValue.ToString()), int.Parse(cmbMember.SelectedValue.ToString()),
                                        null, DateTime.Now, con.GetHargaPromo(int.Parse(cmbPromo.SelectedValue.ToString())) / 2, Pegawai);
                    CetakStrukTransaksi cetak = new CetakStrukTransaksi();
                    try
                    {
                        no_struk = DateTime.Now.ToString("yy") + "." + DateTime.Now.ToString("MM") + "." + con.GetLastIdTransaksi();
                        cetak.InputCetakStruk(cmbMember.Text, txtNamaMember.Text, (double.Parse(txtTotalHarga.Text) / 2).ToString(), no_struk, DateTime.Now.ToString(), nama_pegawai, con.GetTglExpired(int.Parse(cmbMember.SelectedValue.ToString())).ToString(), "", cmbPromo.Text, "", "");
                        cetak.setListBoxSetelahTransaksi(kelas);
                    }
                    catch (Exception ex) { MessageBox.Show(ex.ToString()); }

                    con.TambahTransaksi(int.Parse(cmbPromo.SelectedValue.ToString()), int.Parse(cmbIdMember2.SelectedValue.ToString()),
                                        null, DateTime.Now, con.GetHargaPromo(int.Parse(cmbPromo.SelectedValue.ToString())) / 2, Pegawai);

                    try
                    {
                        no_struk = DateTime.Now.ToString("yy") + "." + DateTime.Now.ToString("MM") + "." + con.GetLastIdTransaksi();
                        cetak.InputCetakStruk(cmbIdMember2.Text, txtNamaMember2.Text, (double.Parse(txtTotalHarga.Text) / 2).ToString(), no_struk, DateTime.Now.ToString(), nama_pegawai, con.GetTglExpired(int.Parse(cmbIdMember2.SelectedValue.ToString())).ToString(), "", cmbPromo.Text, "", "");
                        cetak.setListBox(kelas);
                    }
                    catch (Exception ex) { MessageBox.Show(ex.ToString()); }
                    cetak.ShowDialog();
                    con.AktivasiCouple(int.Parse(cmbMember.SelectedValue.ToString()), int.Parse(cmbIdMember2.SelectedValue.ToString()));
                    if (Mcontrol.cekAdaTidakRecordMember(DateTime.Now.Month.ToString(), DateTime.Now.Year.ToString()) == 0)
                    {
                        Mcontrol.InsertRecordMemberBaru(DateTime.Now.Month.ToString(), DateTime.Now.Year.ToString(), Mcontrol.totalMemberAktif(), Mcontrol.totalMemberNonAktif(),
                                                        Mcontrol.totalMemberAktif() + Mcontrol.totalMemberNonAktif());
                    }
                    Mcontrol.UbahAktifMember(DateTime.Now.Month.ToString(), DateTime.Now.Year.ToString());
                    Mcontrol.UbahAktifMember(DateTime.Now.Month.ToString(), DateTime.Now.Year.ToString());
                    MessageBox.Show(this, "Data Transaksi Berhasil Disimpan", "Sukses", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                else if (cmbPromo.SelectedValue.ToString() == "1")
                {
                    if (con.IsActiveMember(int.Parse(cmbMember.SelectedValue.ToString())))
                    {
                        MessageBox.Show(this, "Member " + cmbMember.Text + " tersebut sudah aktif");
                        return;
                    }
                    con.TambahTransaksi(int.Parse(cmbPromo.SelectedValue.ToString()), int.Parse(cmbMember.SelectedValue.ToString()),
                                        null, DateTime.Now, con.GetHargaPromo(int.Parse(cmbPromo.SelectedValue.ToString())), Pegawai);
                    CetakStrukTransaksi cetak = new CetakStrukTransaksi();
                    try
                    {
                        no_struk = DateTime.Now.ToString("yy") + "." + DateTime.Now.ToString("MM") + "." + con.GetLastIdTransaksi();
                        cetak.InputCetakStruk(cmbMember.Text, txtNamaMember.Text, txtTotalHarga.Text, no_struk, DateTime.Now.ToString(), nama_pegawai, con.GetTglExpired(int.Parse(cmbMember.SelectedValue.ToString())).ToString(), "", cmbPromo.Text, "", "");
                        cetak.setListBox(kelas);
                    }
                    catch (Exception ex) { MessageBox.Show(ex.ToString()); }
                    cetak.ShowDialog();
                    con.AktivasiReguler(int.Parse(cmbMember.SelectedValue.ToString()));
                    if (Mcontrol.cekAdaTidakRecordMember(DateTime.Now.Month.ToString(), DateTime.Now.Year.ToString()) == 0)
                    {
                        Mcontrol.InsertRecordMemberBaru(DateTime.Now.Month.ToString(), DateTime.Now.Year.ToString(), Mcontrol.totalMemberAktif(), Mcontrol.totalMemberNonAktif(),
                                                        Mcontrol.totalMemberAktif() + Mcontrol.totalMemberNonAktif());
                    }
                    Mcontrol.UbahAktifMember(DateTime.Now.Month.ToString(), DateTime.Now.Year.ToString());
                    MessageBox.Show(this, "Data Transaksi Berhasil Disimpan", "Sukses", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if ((cmbMember.SelectedIndex == -1) && cmbPromo.SelectedIndex == -1)
                {
                    MessageBox.Show(this, "Maaf, Harap isikan Data terlebih dahulu.", "Gagal", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (!con.IsActiveMember(int.Parse(cmbMember.SelectedValue.ToString())))
                    {
                        MessageBox.Show(this, "Member " + cmbMember.Text + " tersebut belum aktif");
                        return;
                    }
                    else
                    {
                        if (con.GetDepositByIDMember(int.Parse(cmbMember.SelectedValue.ToString())) - decimal.Parse(txtTotalHarga.Text) < 300000)
                        {
                            MessageBox.Show(this, "Member ini tidak memiliki cukup deposit uang, jika deposit dilakukan");
                            return;
                        }

                        if (con.GetDepositByIDMember(int.Parse(cmbMember.SelectedValue.ToString())) < decimal.Parse(txtTotalHarga.Text))
                        {
                            MessageBox.Show(this, "Member ini tidak memiliki cukup deposit uang");
                            return;
                        }

                        if (!con.IsDepositMemberExist(int.Parse(cmbMember.SelectedValue.ToString()), int.Parse(cmbKelas.SelectedValue.ToString())))
                        {
                            MessageBox.Show("Data Deposit Belum Ada, Data deposit baru akan di daftarkan");
                            con.TambahTransaksi(int.Parse(cmbPromo.SelectedValue.ToString()), int.Parse(cmbMember.SelectedValue.ToString()),
                                                int.Parse(cmbKelas.SelectedValue.ToString()), DateTime.Now, decimal.Parse(txtTotalHarga.Text), Pegawai);
                            con.DepositReguler(int.Parse(cmbMember.SelectedValue.ToString()), -decimal.Parse(txtTotalHarga.Text));
                            con.TambahDepositKelas(int.Parse(cmbMember.SelectedValue.ToString()), int.Parse(cmbKelas.SelectedValue.ToString()), int.Parse(txtDepositPertemuan.Text), null);
                            MessageBox.Show(this, "Data Transaksi Berhasil Disimpan", "Sukses", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            SetDataTransaksi();
                            CetakStrukTransaksi cetak = new CetakStrukTransaksi();
                            try
                            {
                                no_struk = DateTime.Now.ToString("yy") + "." + DateTime.Now.ToString("MM") + "." + con.GetLastIdTransaksi();
                                cetak.InputCetakStruk(cmbMember.Text, txtNamaMember.Text, txtTotalHarga.Text, no_struk, DateTime.Now.ToString(), nama_pegawai, con.GetTglExpired(int.Parse(cmbMember.SelectedValue.ToString())).ToString(), cmbKelas.Text, cmbPromo.Text, "", "");
                                cetak.setListBox(kelas);
                            }
                            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
                            cetak.ShowDialog();
                        }

                        else if (con.IsDepositMemberExist(int.Parse(cmbMember.SelectedValue.ToString()), int.Parse(cmbKelas.SelectedValue.ToString())))
                        {
                            MessageBox.Show("Data Deposit Sudah Ada, Data deposit akan di update");
                            con.TambahTransaksi(int.Parse(cmbPromo.SelectedValue.ToString()), int.Parse(cmbMember.SelectedValue.ToString()),
                                                int.Parse(cmbKelas.SelectedValue.ToString()), DateTime.Now, decimal.Parse(txtTotalHarga.Text), Pegawai);
                            con.UpdateDepositKelas(int.Parse(cmbMember.SelectedValue.ToString()), int.Parse(cmbKelas.SelectedValue.ToString()), int.Parse(txtDepositPertemuan.Text));
                            con.DepositReguler(int.Parse(cmbMember.SelectedValue.ToString()), -decimal.Parse(txtTotalHarga.Text));
                            MessageBox.Show(this, "Data Transaksi Berhasil Disimpan", "Sukses", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            SetDataTransaksi();
                            CetakStrukTransaksi cetak = new CetakStrukTransaksi();
                            try
                            {
                                no_struk = DateTime.Now.ToString("yy") + "." + DateTime.Now.ToString("MM") + "." + con.GetLastIdTransaksi();
                                cetak.InputCetakStruk(cmbMember.Text, txtNamaMember.Text, txtTotalHarga.Text, no_struk, DateTime.Now.ToString(), nama_pegawai, con.GetTglExpired(int.Parse(cmbMember.SelectedValue.ToString())).ToString(), cmbKelas.Text, cmbPromo.Text, "", "");
                                cetak.setListBox(kelas);
                            }
                            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
                            cetak.ShowDialog();
                        }
                    }
                }

                clear();
                SetDataTransaksi();
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
        }