Exemplo n.º 1
0
        private void LoadWilayah()
        {
            try
            {
                if (gridArea.SelectedCells.Count > 0)
                {
                    Guid RowID = (Guid)gridArea.SelectedCells[0].OwningRow.Cells["RowID"].Value;
                    this.Cursor = Cursors.WaitCursor;
                    dtWilayah   = FillComboBox.DBGetWilayah(Guid.Empty, RowID, Guid.Empty);
                    DataColumn cConcatenated = new DataColumn("conWilayah", Type.GetType("System.String"), "'Kec. ' + Kecamatan + ', ' + Kota + ', ' + Provinsi");
                    dtWilayah.Columns.Add(cConcatenated);

                    if (dtWilayah.Rows.Count > 0)
                    {
                        gridKolektor.AutoGenerateColumns = false;
                        dtWilayah.DefaultView.Sort       = "Kecamatan";
                        gridWilayah.DataSource           = dtWilayah.DefaultView;
                    }
                    else
                    {
                        dtWilayah.Clear();
                        gridWilayah.DataSource = dtWilayah.DefaultView;
                    }
                }
            }
            catch (System.Exception ex)
            {
                Error.LogError(ex);
            }

            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Exemplo n.º 2
0
        private void LoadWilayah()
        {
            displayPanel("Wilayah");
            DataTable dtProp, dt;

            if (formMode == enumFormMode.New)
            {
                txtWilArea.Text           = _area;
                dtProp                    = FillComboBox.DBGetProvinsi(Guid.Empty);
                dtProp.DefaultView.Sort   = "Nama ASC";
                cboProvinsi.DisplayMember = "Nama";
                cboProvinsi.ValueMember   = "RowID";
                cboProvinsi.DataSource    = dtProp.DefaultView;
                this.Text                 = "Master Kota";
                this.Title                = "Master Kota";

                // 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();
                    }
                }
            }
            else
            {
                dt     = FillComboBox.DBGetWilayah(_rowID, Guid.Empty, Guid.Empty);
                dtProp = FillComboBox.DBGetProvinsi(Guid.Empty);
                dtProp.DefaultView.Sort   = "Nama ASC";
                cboProvinsi.DisplayMember = "Nama";
                cboProvinsi.ValueMember   = "RowID";
                cboProvinsi.DataSource    = dtProp.DefaultView;
                txtWilArea.Text           = _area;
                _areaRowID        = (Guid)Tools.isNull(dt.Rows[0]["AreaRowID"], "");
                cboProvinsi.Text  = Tools.isNull(dt.Rows[0]["Provinsi"], "").ToString();
                cboKota.Text      = Tools.isNull(dt.Rows[0]["Kota"], "").ToString();
                cboKecamatan.Text = Tools.isNull(dt.Rows[0]["Kecamatan"], "").ToString();
                this.Text         = "Master Kota Update";
                this.Title        = "Master Kota Update";
            }
        }
Exemplo n.º 3
0
        public void RefreshRowData(string Sts, Guid _areaRowID, Guid _rowid)
        {
            using (Database db = new Database())
            {
                switch (Sts)
                {
                case "Area":
                    dtRefresh = FillComboBox.DBGetArea(Guid.Empty);
                    break;

                case "Wilayah":
                    dtRefresh = FillComboBox.DBGetWilayah(Guid.Empty, _areaRowID, Guid.Empty);
                    break;

                case "Kolektor":
                    dtRefresh = FillComboBox.DBGetAreaKolektor(Guid.Empty, _areaRowID, Guid.Empty);
                    break;
                }
            }
            if (dtRefresh.Rows.Count > 0)
            {
                switch (Sts)
                {
                case "Area":
                    gridArea.FindRow("RowID", _rowid.ToString());
                    break;

                case "Wilayah":
                    gridWilayah.FindRow("WilRowID", _rowid.ToString());
                    break;

                case "Kolektor":
                    gridKolektor.FindRow("KolRowID", _rowid.ToString());
                    break;
                }
            }
        }
Exemplo n.º 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.GridArea:
                if (gridArea.RowCount > 0)
                {
                    if (MessageBox.Show(Messages.Question.AskDelete, "Anda yakin akan menghapus data ini ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        Guid rowID = (Guid)gridArea.SelectedCells[0].OwningRow.Cells["RowID"].Value;

                        DataTable dtW = FillComboBox.DBGetWilayah(Guid.Empty, rowID, Guid.Empty);
                        DataTable dtK = FillComboBox.DBGetAreaKolektor(Guid.Empty, rowID, Guid.Empty);
                        if (dtW.Rows.Count > 0)
                        {
                            MessageBox.Show("Terdapat keterkaitan data !");
                        }
                        else if (dtK.Rows.Count > 0)
                        {
                            MessageBox.Show("Terdapat keterkaitan data !");
                        }
                        else
                        {                                                                // pake cek delete punya Pak Novi
                            if (Class.PenerimaanUang.checkDelete(rowID, "Area") == true) // this.ceckDelete(rowID) == true -> ke Area
                            {
                                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_Area_DELETE"));
                                db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, rowID));
                                db.Commands[0].ExecuteNonQuery();
                            }
                            gridArea.Rows.Remove(gridArea.SelectedCells[0].OwningRow);
                            MessageBox.Show("Data berhasil dihapus");
                        }
                    }
                }
                break;

            case enumSelectedGrid.GridWilayah:
                if (gridWilayah.RowCount > 0)
                {
                    if (MessageBox.Show(Messages.Question.AskDelete, "Anda yakin akan menghapus data ini ?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Guid rowID = (Guid)gridWilayah.SelectedCells[0].OwningRow.Cells["WilRowID"].Value;
                        // pake cek delete punya Pak Novi
                        if (Class.PenerimaanUang.checkDelete(rowID, "Wilayah") == true)     // this.ceckDelete(rowID) == true -> ke Wilayah
                        {
                            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_Wilayah_DELETE"));
                            db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, rowID));
                            db.Commands[0].ExecuteNonQuery();
                        }
                        gridWilayah.Rows.Remove(gridWilayah.SelectedCells[0].OwningRow);
                        MessageBox.Show("Data berhasil dihapus");
                    }
                }
                break;

            case enumSelectedGrid.GridKolektor:
                if (gridKolektor.RowCount > 0)
                {
                    if (MessageBox.Show(Messages.Question.AskDelete, "Anda yakin akan menghapus data ini ?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Guid rowID = (Guid)gridKolektor.SelectedCells[0].OwningRow.Cells["KolRowID"].Value;
                        // pake cek delete punya Pak Novi
                        if (Class.PenerimaanUang.checkDelete(rowID, "AreaKolektor") == true)     // this.ceckDelete(rowID) == true -> ke AreaKolektor
                        {
                            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_Area_Kolektor_DELETE"));
                            db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, rowID));
                            db.Commands[0].ExecuteNonQuery();
                        }
                        gridKolektor.Rows.Remove(gridKolektor.SelectedCells[0].OwningRow);
                        MessageBox.Show("Data berhasil dihapus");
                    }
                }
                break;
            }
        }