Example #1
0
        private void LoadKota()
        {
            try
            {
                Guid RowIDProv = (Guid)gridProvinsi.SelectedCells[0].OwningRow.Cells["ProvRowID"].Value;
                this.Cursor = Cursors.WaitCursor;
                dtKota      = FillComboBox.DBGetKota(Guid.Empty, RowIDProv);

                if (dtKota.Rows.Count > 0)
                {
                    dtKota.DefaultView.Sort      = "Nama";
                    gridKota.AutoGenerateColumns = false;
                    gridKota.DataSource          = dtKota.DefaultView;
                    LoadKec();
                }
                else
                {
                    dtKota.Clear();
                    gridKota.DataSource = dtKota.DefaultView;
                }
            }
            catch (System.Exception ex)
            {
                Error.LogError(ex);
            }

            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Example #2
0
        private void cboProvinsi_SelectedIndexChanged(object sender, EventArgs e)
        {
            Guid      rowID = (Guid)cboProvinsi.SelectedValue;
            DataTable dtK   = FillComboBox.DBGetKota(Guid.Empty, rowID);

            dtK.DefaultView.Sort  = "Nama ASC";
            cboKota.DisplayMember = "Nama";
            cboKota.ValueMember   = "RowID";
            cboKota.DataSource    = dtK.DefaultView;
        }
Example #3
0
 private void cboProvinsiDom_SelectedIndexChanged(object sender, EventArgs e)
 {
     cboKelurahanDom.DataSource = null;
     try
     {
         Guid      rowID = (Guid)cboProvinsiDom.SelectedValue;
         DataTable dt    = FillComboBox.DBGetKota(Guid.Empty, rowID);
         dt.DefaultView.Sort      = "Nama ASC";
         cboKotaDom.DisplayMember = "Nama";
         cboKotaDom.ValueMember   = "RowID";
         cboKotaDom.DataSource    = dt.DefaultView;
     }
     catch (Exception ex)
     {
         Error.LogError(ex);
     }
 }
Example #4
0
        private void cmdDelete_Click(object sender, EventArgs e)
        {
            DateTimeFormatInfo dfi  = DateTimeFormatInfo.CurrentInfo;
            DateTime           date = GlobalVar.GetServerDate;
            Calendar           cal  = dfi.Calendar;
            int mingguKe            = cal.GetWeekOfYear(date, dfi.CalendarWeekRule, dfi.FirstDayOfWeek);

            switch (selectedGrid)
            {
            case enumSelectedGrid.GridProvinsi:
                if (gridProvinsi.RowCount > 0)
                {
                    if (MessageBox.Show(Messages.Question.AskDelete, "Anda yakin akan menghapus data ini ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        Guid rowID = (Guid)gridProvinsi.SelectedCells[0].OwningRow.Cells["ProvRowID"].Value;

                        DataTable dt = FillComboBox.DBGetKota(Guid.Empty, rowID);
                        if (dt.Rows.Count > 0)
                        {
                            MessageBox.Show("Terdapat keterkaitan data");
                            return;
                        }
                        else
                        {                                                                    // Pake cekDelete punya Pak Novi
                            if (Class.PenerimaanUang.checkDelete(rowID, "Provinsi") == true) // this.ceckDelete(rowID) == true -> ke Provinsi
                            {
                                Tools.pin(PinId.Periode.Hari, mingguKe, date, PinId.Bagian.Piutang, Convert.ToInt32(PinId.ModulId.HapusMaster), "Hapus Master.\nSudah lewat tanggal, tidak diperkenankan menghapus data ini !");
                                if (GlobalVar.pinResult == false)
                                {
                                    return;
                                }
                            }

                            using (Database db = new Database())
                            {
                                db.Commands.Add(db.CreateCommand("usp_Provinsi_DELETE"));
                                db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, rowID));
                                db.Commands[0].ExecuteNonQuery();
                            }
                            gridProvinsi.Rows.Remove(gridProvinsi.SelectedCells[0].OwningRow);
                            MessageBox.Show("Data berhasil dihapus");
                        }
                    }
                }
                break;

            case enumSelectedGrid.GridKota:
                if (gridKota.RowCount > 0)
                {
                    if (MessageBox.Show(Messages.Question.AskDelete, "Anda yakin akan menghapus data ini ?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Guid rowID = (Guid)gridKota.SelectedCells[0].OwningRow.Cells["KotaRowID"].Value;

                        DataTable dt = FillComboBox.DBGetKecamatan(Guid.Empty, rowID);

                        if (dt.Rows.Count > 0)
                        {
                            MessageBox.Show("Terdapat keterkaitan data");
                            return;
                        }
                        else
                        {                                                                // Pake cekDelete punya Pak Novi
                            if (Class.PenerimaanUang.checkDelete(rowID, "Kota") == true) // this.ceckDelete(rowID) == true -> ke Kota
                            {
                                Tools.pin(PinId.Periode.Hari, mingguKe, date, PinId.Bagian.Piutang, Convert.ToInt32(PinId.ModulId.HapusMaster), "Hapus Master.\nSudah lewat tanggal, tidak diperkenankan menghapus data ini !");
                                if (GlobalVar.pinResult == false)
                                {
                                    return;
                                }
                            }

                            using (Database db = new Database())
                            {
                                db.Commands.Add(db.CreateCommand("usp_Kota_DELETE"));
                                db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, rowID));
                                db.Commands[0].ExecuteNonQuery();
                            }
                            gridKota.Rows.Remove(gridKota.SelectedCells[0].OwningRow);
                            MessageBox.Show("Data berhasil dihapus");
                        }
                    }
                }
                break;

            case enumSelectedGrid.GridKecamatan:
                if (gridKecamatan.RowCount > 0)
                {
                    if (MessageBox.Show(Messages.Question.AskDelete, "Anda yakin akan menghapus data ini ?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Guid rowID = (Guid)gridKecamatan.SelectedCells[0].OwningRow.Cells["KecRowID"].Value;

                        DataTable dt    = FillComboBox.DBGetKelurahan(Guid.Empty, rowID);
                        DataTable dtWil = FillComboBox.DBGetWilayah(Guid.Empty, Guid.Empty, rowID);

                        if (dt.Rows.Count > 0)
                        {
                            MessageBox.Show("Terdapat keterkaitan data");
                            return;
                        }
                        else if (dtWil.Rows.Count > 0)
                        {
                            MessageBox.Show("Terdapat keterkaitan data");
                            return;
                        }
                        else
                        {                                                                     // Pake cekDelete punya Pak Novi
                            if (Class.PenerimaanUang.checkDelete(rowID, "Kecamatan") == true) // this.ceckDelete(rowID) == true -> ke Kecamatan
                            {
                                Tools.pin(PinId.Periode.Hari, mingguKe, date, PinId.Bagian.Piutang, Convert.ToInt32(PinId.ModulId.HapusMaster), "Hapus Master.\nSudah lewat tanggal, tidak diperkenankan menghapus data ini !");
                                if (GlobalVar.pinResult == false)
                                {
                                    return;
                                }
                            }

                            using (Database db = new Database())
                            {
                                db.Commands.Add(db.CreateCommand("usp_Kecamatan_DELETE"));
                                db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, rowID));
                                db.Commands[0].ExecuteNonQuery();
                            }
                            gridKecamatan.Rows.Remove(gridKecamatan.SelectedCells[0].OwningRow);
                            MessageBox.Show("Data berhasil dihapus");
                        }
                    }
                }
                break;

            case enumSelectedGrid.GridKelurahan:
                if (gridKelurahan.RowCount > 0)
                {
                    if (MessageBox.Show(Messages.Question.AskDelete, "Anda yakin akan menghapus data ini ?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Guid rowID = (Guid)gridKelurahan.SelectedCells[0].OwningRow.Cells["KelRowID"].Value;
                        // Pake cekDelete punya Pak Novi
                        if (Class.PenerimaanUang.checkDelete(rowID, "Kelurahan") == true)      // this.ceckDelete(rowID) == true -> ke Kelurahan
                        {
                            Tools.pin(PinId.Periode.Hari, mingguKe, date, PinId.Bagian.Piutang, Convert.ToInt32(PinId.ModulId.HapusMaster), "Hapus Master.\nSudah lewat tanggal, tidak diperkenankan menghapus data ini !");
                            if (GlobalVar.pinResult == false)
                            {
                                return;
                            }
                        }

                        using (Database db = new Database())
                        {
                            db.Commands.Add(db.CreateCommand("usp_Kelurahan_DELETE"));
                            db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, rowID));
                            db.Commands[0].ExecuteNonQuery();
                        }
                        gridKelurahan.Rows.Remove(gridKelurahan.SelectedCells[0].OwningRow);
                        MessageBox.Show("Data berhasil dihapus");
                    }
                }
                break;
            }
        }
Example #5
0
        private void frmLeasingUpdate_Load(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                if (formMode == enumFormMode.Update)
                {
                    DataTable dt = new DataTable();
                    using (Database db = new Database())
                    {
                        db.Commands.Add(db.CreateCommand("usp_Leasing_LIST"));
                        db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, _rowID));
                        dt = db.Commands[0].ExecuteDataTable();
                    }
                    txtNama.Text    = Tools.isNull(dt.Rows[0]["Nama"], "").ToString();
                    txtAlamat.Text  = Tools.isNull(dt.Rows[0]["Alamat"], "").ToString();
                    txtTelepon.Text = Tools.isNull(dt.Rows[0]["Telepon"], "").ToString();

                    DataTable dt2 = FillComboBox.DBGetProvinsi(Guid.Empty);
                    dt2.DefaultView.Sort      = "Nama ASC";
                    cboProvinsi.DisplayMember = "Nama";
                    cboProvinsi.ValueMember   = "RowID";
                    cboProvinsi.DataSource    = dt2.DefaultView;
                    cboProvinsi.Text          = Tools.isNull(dt.Rows[0]["Provinsi"], "").ToString();

                    Guid      _provRowID = (Guid)cboProvinsi.SelectedValue;
                    DataTable dt3        = FillComboBox.DBGetKota(Guid.Empty, _provRowID);

                    dt3.DefaultView.Sort  = "Nama ASC";
                    cboKota.DisplayMember = "Nama";
                    cboKota.ValueMember   = "RowID";
                    cboKota.DataSource    = dt3.DefaultView;
                    cboKota.Text          = Tools.isNull(dt.Rows[0]["Kota"], "").ToString();
                }
                else
                {
                    DataTable dt = FillComboBox.DBGetProvinsi(Guid.Empty);
                    dt.DefaultView.Sort       = "Nama ASC";
                    cboProvinsi.DisplayMember = "Nama";
                    cboProvinsi.ValueMember   = "RowID";
                    cboProvinsi.DataSource    = dt.DefaultView;

                    Guid      _provRowID = (Guid)cboProvinsi.SelectedValue;
                    DataTable dt2        = FillComboBox.DBGetKota(Guid.Empty, _provRowID);

                    dt2.DefaultView.Sort  = "Nama ASC";
                    cboKota.DisplayMember = "Nama";
                    cboKota.ValueMember   = "RowID";
                    cboKota.DataSource    = dt2.DefaultView;
                    // ambil dari app setting
                    DataTable dummyPR = new DataTable();
                    using (Database dbsubPR = new Database())
                    {
                        dbsubPR.Commands.Add(dbsubPR.CreateCommand("usp_AppSetting_LIST"));
                        dbsubPR.Commands[0].Parameters.Add(new Parameter("@key", SqlDbType.VarChar, "PROVPEMILIKBPKB"));
                        dummyPR = dbsubPR.Commands[0].ExecuteDataTable();
                        if (dummyPR.Rows.Count > 0)
                        {
                            cboProvinsi.Text = dummyPR.Rows[0]["Value"].ToString();
                        }
                    }
                    DataTable dummyKT = new DataTable();
                    using (Database dbsubKT = new Database())
                    {
                        dbsubKT.Commands.Add(dbsubKT.CreateCommand("usp_AppSetting_LIST"));
                        dbsubKT.Commands[0].Parameters.Add(new Parameter("@key", SqlDbType.VarChar, "KOTAPEMILIKBPKB"));
                        dummyKT = dbsubKT.Commands[0].ExecuteDataTable();
                        if (dummyKT.Rows.Count > 0)
                        {
                            cboKota.Text = dummyKT.Rows[0]["Value"].ToString();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Error.LogError(ex);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }