Ejemplo n.º 1
0
        private void LoadKolektor()
        {
            try
            {
                if (gridArea.SelectedCells.Count > 0)
                {
                    Guid RowID = (Guid)gridArea.SelectedCells[0].OwningRow.Cells["RowID"].Value;
                    this.Cursor = Cursors.WaitCursor;
                    dtKolektor  = FillComboBox.DBGetAreaKolektor(Guid.Empty, RowID, Guid.Empty);

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

            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Ejemplo n.º 2
0
        private void LoadKolektor()
        {
            displayPanel("Kolektor");
            DataTable dtKol, dt;

            if (formMode == enumFormMode.New)
            {
                txtKolArea.Text = _area;
                lkKolektor.txtNamaKolektor.Text = "";
                txtTMT.Text = "";
                this.Text   = "Master Kolektor";
                this.Title  = "Master Kolektor";
            }
            else
            {
                dt = FillComboBox.DBGetAreaKolektor(_rowID, Guid.Empty, Guid.Empty);
                txtKolArea.Text = _area;
                _areaRowID      = (Guid)Tools.isNull(dt.Rows[0]["AreaRowID"], "");
                _kolRowID       = (Guid)Tools.isNull(dt.Rows[0]["KolektorRowID"], "");
                dtKol           = FillComboBox.DBGetKolektor(_kolRowID);
                lkKolektor.txtNamaKolektor.Text = Tools.isNull(dtKol.Rows[0]["Nama"], "").ToString();
                txtTMT.DateValue = (DateTime)Tools.isNull(dt.Rows[0]["TMT"], "");
                this.Text        = "Master Kolektor Update";
                this.Title       = "Master Kolektor Update";
            }
        }
Ejemplo 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;
                }
            }
        }
Ejemplo 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;
            }
        }