Exemplo n.º 1
0
 public void GetHargaHpp(string barangID)
 {
     try
     {
         DataTable dtGetHargaHPP = new DataTable();
         using (Database db = new Database())
         {
             db.Commands.Add(db.CreateCommand("usp_cekHargaHPP"));
             db.Commands[0].Parameters.Add(new Parameter("@barangID", SqlDbType.VarChar, barangID));
             dtGetHargaHPP = db.Commands[0].ExecuteDataTable();
         }
         if (dtGetHargaHPP.Rows.Count > 0)
         {
             _hrgHPP = Convert.ToDouble(dtGetHargaHPP.Rows[0]["HPP"]);
         }
         else
         {
             _hrgHPP = 0;
             KotakPesan.HargaBeli("Barang tidak mempunyai riwayat HPP, hubungi Manager Anda");
             CanInsertGridViewPos = false;
         }
     }
     catch (Exception ex)
     {
         Error.LogError(ex);
     }
 }
Exemplo n.º 2
0
        private void GetHrgBMK()
        {
            try
            {
                DataTable dtGetHrgBMK = new DataTable();
                using (Database db = new Database())
                {
                    db.Commands.Add(db.CreateCommand("[usp_GetHargaJual]"));
                    db.Commands[0].Parameters.Add(new Parameter("@tglDo", SqlDbType.DateTime, DateTime.Now));
                    db.Commands[0].Parameters.Add(new Parameter("@barangID", SqlDbType.VarChar, _barangID));
                    db.Commands[0].Parameters.Add(new Parameter("@cabang", SqlDbType.VarChar, _c1));
                    db.Commands[0].Parameters.Add(new Parameter("@kodeToko", SqlDbType.VarChar, "0000000001"));
                    dtGetHrgBMK = db.Commands[0].ExecuteDataTable();
                }
                if (dtGetHrgBMK.Rows.Count > 0)
                {
                    _hrgB     = Convert.ToDouble(dtGetHrgBMK.Rows[0]["HrgB"]);
                    _hrgM     = Convert.ToDouble(dtGetHrgBMK.Rows[0]["HrgM"]);
                    _hrgK     = Convert.ToDouble(dtGetHrgBMK.Rows[0]["HrgK"]);
                    _hrg4     = Convert.ToDouble(dtGetHrgBMK.Rows[0]["Hrg4"]);
                    _hrgAkhir = Convert.ToDouble(dtGetHrgBMK.Rows[0]["HrgTerakhir"]);
                    _hrgNet   = Convert.ToDouble(dtGetHrgBMK.Rows[0]["HrgNet"]);
                }
                else
                {
                    _hrgB     = 0;
                    _hrgM     = 0;
                    _hrgK     = 0;
                    _hrg4     = 0;
                    _hrgAkhir = Convert.ToDouble(dtGetHrgBMK.Rows[0]["HrgTerakhir"]);
                    _hrgNet   = Convert.ToDouble(dtGetHrgBMK.Rows[0]["HrgNet"]);
                }


                if (_hrgAkhir > 0)
                {
                    if (dtGetHrgBMK.Rows.Count > 0)
                    {
                        _tglAkhir = (DateTime)dtGetHrgBMK.Rows[0]["TglTerakhir"];
                    }
                    else
                    {
                        _tglAkhir = new DateTime(1900, 1, 1);
                    }
                }

                if (_hrgB > 0 && _hrgM > 0 && _hrgK > 0 && _hrg4 > 0)
                {
                    //    lblBMK.Text = "1: " + _hrgB.ToString("N0") + "  2: " + _hrgM.ToString("N0") + "  3: " + _hrgK.ToString("N0") + "  4: " + _hrg4.ToString("N0") + "  Harga Akhir: " + _hrgAkhir.ToString("N0") + "  Harga Net: " + _hrgNet.ToString("N0");
                }
                else
                {
                    KotakPesan.HargaJual("tidak mempunyai BMK Silakan hubungi Manager anda");
                }
            }
            catch (Exception ex)
            {
                Error.LogError(ex);
            }
        }
Exemplo n.º 3
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtdate.Text))
            {
                KotakPesan.Warning("Anda belum mengisi Tanggal", "Cek Tanggal");
                txtdate.Focus();
                return;
            }

            if (txtdate.DateValue < GlobalVar.DateOfServer)
            {
                KotakPesan.Warning("Tanggal tidak boleh kurang dari datetime server", "Cek Tanggal");
                txtdate.Focus();
                return;
            }
            if (txtHargaJual.GetDoubleValue <= 0)
            {
                KotakPesan.Warning("Harga Jual Harus Lebih besar dari 0", "Cek Harga Jual");
                txtHargaJual.Focus();
                return;
            }
            try
            {
                // using (Database db = new Database(GlobalVar.DBFinance))
                using (Database db = new Database())

                {
                    db.Open();
                    DataTable dt = new DataTable();
                    db.Commands.Add(db.CreateCommand("usp_JasaHarga_Insert"));
                    db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, RowID));
                    db.Commands[0].Parameters.Add(new Parameter("@JasaRowID", SqlDbType.UniqueIdentifier, JasaRowID));
                    db.Commands[0].Parameters.Add(new Parameter("@Tanggal", SqlDbType.DateTime, txtdate.DateValue));
                    db.Commands[0].Parameters.Add(new Parameter("@HargaJual", SqlDbType.Money, txtHargaJual.GetDoubleValue));
                    db.Commands[0].Parameters.Add(new Parameter("@Keterangan", SqlDbType.VarChar, txtKeterangan.Text));
                    db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserName));
                    dt = db.Commands[0].ExecuteDataTable();
                    db.Close();
                    db.Dispose();
                    if (dt.Rows.Count > 0)
                    {
                        KotakPesan.Warning(string.Format("Jasa Harga Tanggal {0:dd-MM-yyyy} sudah ada. Mohon gunakan Tombol Edit jika ingin merubah.", txtdate.DateValue), "Cek Tanggal");
                        txtdate.Focus();
                        return;
                    }
                }

                this.DialogResult = DialogResult.OK;
                frmJasaBrowse frmcaller = (frmJasaBrowse)this.Caller;
                frmcaller.RefreshData();
                this.Close();
                frmcaller.Show();
            }
            catch (Exception ex)
            {
                Error.LogError(ex);
            }
        }
Exemplo n.º 4
0
        private void cmdDelete_Click(object sender, EventArgs e)
        {
            if (_selectedGrid == enumSelectedGrid.Detail)
            {
                try
                {
                    Guid   RowID_ = (Guid)dataGridDetail.SelectedCells[0].OwningRow.Cells["RowIDDetail"].Value;
                    String Kdtp   = dataGridDetail.SelectedCells[0].OwningRow.Cells["KodeTransaksi"].Value.ToString();

                    DateTime TglTansact = Convert.ToDateTime(dataGridDetail.SelectedCells[0].OwningRow.Cells["TglTransaksiDetail"].Value);
                    if (TglTansact != GlobalVar.DateOfServer)
                    {
                        KotakPesan.Warning("Date time server >< Tgl. Transaksi"); return;
                    }
                    if (Kdtp == "ADJ" || Kdtp == "RET")
                    {
                        if (!SecurityManager.AskPasswordManager())
                        {
                            return;
                        }
                    }
                    else
                    {
                        KotakPesan.Warning("Kode Transaksi Piutang selain ADJ & RET Tidak Bisa Di Hapus"); return;
                    }
                    this.Cursor = Cursors.WaitCursor;
                    DataTable dtSales = new DataTable();
                    using (Database db = new Database(GlobalVar.DBFinance))
                    {
                        db.Commands.Add(db.CreateCommand("[usp_KartuPiutangDetail_DELETE]"));
                        db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, RowID_));
                        db.Commands[0].ExecuteNonQuery();
                    }

                    RefreshKPiutangDetail(dataGridHeader.SelectedCells[0].OwningRow.Cells["KPID"].Value.ToString(), (Guid)dataGridHeader.SelectedCells[0].OwningRow.Cells["RowID"].Value);
                    MessageBox.Show("Record Berhasil Terhapus", "Notifikacation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    Error.LogError(ex);
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            }
        }
Exemplo n.º 5
0
 private void cmdEdit_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedCells.Count > 0)
     {
         if (Grid == GridSelected.Header)
         {
             Guid rowid = new Guid(dataGridView1.SelectedCells[0].OwningRow.Cells["RowID"].Value.ToString());
             Master.frmJasaUpdate ifrmChild = new Master.frmJasaUpdate(this, rowid);
             ifrmChild.MdiParent = Program.MainForm;
             Program.MainForm.RegisterChild(ifrmChild);
             ifrmChild.Show();
         }
         else
         {
             if (DataGridView2.SelectedCells.Count > 0)
             {
                 if ((DateTime)DataGridView2.SelectedCells[0].OwningRow.Cells["DTanggal"].Value != GlobalVar.DateOfServer)
                 {
                     KotakPesan.Warning("Tanggal Jasa Harga Tidak sama dengan Tanggal Server. Tidak bisa edit data lampau. Silahkan buat Jasa Harga yang baru saja.", "Cek Harga");
                     return;
                 }
                 Guid rowid       = new Guid(DataGridView2.SelectedCells[0].OwningRow.Cells["DRowID"].Value.ToString());
                 Guid Headerrowid = new Guid(dataGridView1.SelectedCells[0].OwningRow.Cells["RowID"].Value.ToString());
                 Master.frmJasaHargaUpdate ifrmChild = new Master.frmJasaHargaUpdate(this, Headerrowid, rowid);
                 ifrmChild.MdiParent = Program.MainForm;
                 Program.MainForm.RegisterChild(ifrmChild);
                 ifrmChild.Show();
             }
             else
             {
                 MessageBox.Show(Messages.Error.RowNotSelected);
             }
         }
     }
     else
     {
         MessageBox.Show(Messages.Error.RowNotSelected);
     }
 }
Exemplo n.º 6
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            if (!ValidateInput())
            {
                return;
            }

            if (txtJnsTrans.Text.Substring(0, 1) == "K")
            {
                uraian = "PJK (" + Tools.isNull(dtNota.Rows[0]["NamaSales"], "").ToString() + ")";
            }

            if (txtJnsTrans.Text.Substring(0, 1) == "T")
            {
                uraian = "PJT (" + Tools.isNull(dtNota.Rows[0]["NamaSales"], "").ToString() + ")";
            }

            NamaToko_ = Tools.isNull(dtNota.Rows[0]["NamaToko"], "").ToString().Trim();
            Sales_    = Tools.isNull(dtNota.Rows[0]["KodeSales"], "").ToString().Trim().Substring(7, 3);

            /***************************************************************
            * Code di bawah ini sudah tidak di pakai karena tidak ada lagi
            * karena PJ3 tidak lagi ada jenis transaksi berinitial "T"
            ***************************************************************/
            //else
            //{
            //    if (txtJnsTrans.Text.Substring(0, 1) == "T")
            //    {
            //        uraian = "PJT (" + Tools.isNull(dtNota.Rows[0]["NamaSales"], "").ToString() + ")";
            //        hariKredit = 3;
            //    }
            //    else
            //        uraian = "PENJUALAN (" + Tools.isNull(dtNota.Rows[0]["NamaSales"], "").ToString() + ")";
            //}

            /* Isi TglTerima */
            try
            {
                GlobalVar.LastClosingDate = (DateTime)txtTglTerima.DateValue;
                if (txtTglTerima.DateValue <= GlobalVar.LastClosingDate)
                {
                    KotakPesan.Information(String.Format(Messages.Error.AlreadyClosingPJT, GlobalVar.LastClosingDate));
                    return;
                }
                if (MessageBox.Show("Tgl Jatuh Tempo Nota ini: " + HitungTglJatuhTempo().ToString("dd-MMM-yyyy") + ", data akan disimpan?", "KONFIRMASI", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    IsiTglTerima();
                }
                else
                {
                    this.DialogResult = DialogResult.No;
                    return;
                }

                /* Proses link ke piutang */
                string cCab1 = Tools.isNull(dtNota.Rows[0]["Cabang1"], "").ToString().Trim();
                string cCab2 = Tools.isNull(dtNota.Rows[0]["Cabang2"], "").ToString().Trim();

                if (cCab1 == GlobalVar.CabangID && cCab2 == GlobalVar.CabangID)
                {
                    LinkKePiutang();
                }
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (System.Exception ex)
            {
                Error.LogError(ex);
            }
        }
Exemplo n.º 7
0
        private void cmdDelete_Click(object sender, EventArgs e)
        {
            if (selectedGrid == enumSelectedGrid.HeaderSelected)
            {
                if (gridUtm.SelectedCells.Count > 0)
                {
                    DateTime _Tanggal = (DateTime)gridUtm.SelectedCells[0].OwningRow.Cells["TglBBM"].Value;
                    if (_Tanggal.Date != GlobalVar.DateOfServer.Date)
                    {
                        KotakPesan.Warning("Tanggal server tidak sama dengan tanggal transaksi. \n Tidak bisa hapus transaksi");
                        return;
                    }
                    if (gridDetail.Rows.Count > 0)
                    {
                        KotakPesan.Warning("Sudah ada record di detail, tidak bisa hapus record. \n Silahkan hapus record detail terlebih dahulu.");
                        return;
                    }
                    else if (!SecurityManager.AskPasswordManager())
                    {
                        return;
                    }

                    if (PeriodeClosing.IsKasirClosed(_Tanggal))
                    {
                        MessageBox.Show("Sudah Closing!");
                        return;
                    }
                    Guid headerID = (Guid)gridUtm.SelectedCells[0].OwningRow.Cells["RowID"].Value;

                    if (MessageBox.Show(Messages.Question.AskDelete, "Delete", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        using (Database db = new Database(GlobalVar.DBFinance))
                        {
                            db.Commands.Clear();
                            db.Commands.Add(db.CreateCommand("usp_TransferBank_DELETE"));
                            db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, headerID));
                            db.BeginTransaction();
                            db.Commands[0].ExecuteNonQuery();
                            db.CommitTransaction();
                        }
                        //gridDetail.Rows.Remove(gridDetail.SelectedCells[0].OwningRow);

                        //RefreshRowBuktiTransfer(headerID); // ini buat apa ?

                        #region "Tambahan"
                        int i = 0;
                        int n = 0;
                        i = gridUtm.SelectedCells[0].RowIndex;
                        n = gridUtm.SelectedCells[0].ColumnIndex;
                        DataRowView dv = (DataRowView)gridUtm.SelectedCells[0].OwningRow.DataBoundItem;

                        DataRow dr = dv.Row;

                        dr.Delete();
                        dtHeader.AcceptChanges();
                        gridUtm.Focus();
                        gridUtm.RefreshEdit();
                        if (gridUtm.RowCount > 0)
                        {
                            if (i == 0)
                            {
                                gridUtm.CurrentCell = gridUtm.Rows[0].Cells[n];
                                gridUtm.RefreshEdit();
                            }
                            else
                            {
                                gridUtm.CurrentCell = gridUtm.Rows[i - 1].Cells[n];
                                gridUtm.RefreshEdit();
                            }
                        }
                        #endregion
                    }
                }
            }
            else
            {
                if (gridDetail.SelectedCells.Count > 0)
                {
                    DateTime _Tanggal = (DateTime)gridUtm.SelectedCells[0].OwningRow.Cells["TglBBM"].Value;
                    if (_Tanggal.Date != GlobalVar.DateOfServer.Date)
                    {
                        KotakPesan.Warning("Tanggal server tidak sama dengan tanggal transaksi. Tidak bisa hapus transaksi");
                        return;
                    }
                    else if (!SecurityManager.AskPasswordManager())
                    {
                        return;
                    }


                    if (PeriodeClosing.IsKasirClosed(_Tanggal))
                    {
                        MessageBox.Show("Sudah Closing!");
                        return;
                    }
                    Guid headerID  = (Guid)gridUtm.SelectedCells[0].OwningRow.Cells["RowID"].Value;
                    Guid rowID     = (Guid)gridDetail.SelectedCells[0].OwningRow.Cells["RowIDDetail"].Value;
                    Guid rowIDBank = (Guid)gridDetail.SelectedCells[0].OwningRow.Cells["RowIDBank"].Value;
                    if (MessageBox.Show(Messages.Question.AskDelete, "Delete", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        using (Database db = new Database(GlobalVar.DBFinance))
                        {
                            db.BeginTransaction();
                            Class.TransferBank.DeleteDetail(db, rowID);

                            db.Commands.Clear();
                            db.Commands.Add(db.CreateCommand("usp_BankDetail_DELETE"));
                            db.Commands[0].Parameters.Add(new Parameter("@rowIDDetail", SqlDbType.UniqueIdentifier, rowID));
                            db.Commands[0].Parameters.Add(new Parameter("@headerIDBank1", SqlDbType.UniqueIdentifier, rowIDBank));
                            db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy2", SqlDbType.VarChar, SecurityManager.UserID));
                            db.Commands[0].ExecuteNonQuery();
                            db.CommitTransaction();
                        }
                        //gridDetail.Rows.Remove(gridDetail.SelectedCells[0].OwningRow);

                        RefreshRowBuktiTransfer(headerID);
                        #region "Tambahan"
                        int i = 0;
                        int n = 0;
                        i = gridDetail.SelectedCells[0].RowIndex;
                        n = gridDetail.SelectedCells[0].ColumnIndex;
                        DataRowView dv = (DataRowView)gridDetail.SelectedCells[0].OwningRow.DataBoundItem;

                        DataRow dr = dv.Row;

                        dr.Delete();
                        dtDetail.AcceptChanges();
                        gridDetail.Focus();
                        gridDetail.RefreshEdit();
                        if (gridDetail.RowCount > 0)
                        {
                            if (i == 0)
                            {
                                gridDetail.CurrentCell = gridDetail.Rows[0].Cells[n];
                                gridDetail.RefreshEdit();
                            }
                            else
                            {
                                gridDetail.CurrentCell = gridDetail.Rows[i - 1].Cells[n];
                                gridDetail.RefreshEdit();
                            }
                        }
                        #endregion
                    }
                }
                else
                {
                    MessageBox.Show("Belum Ada Data", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Exemplo n.º 8
0
        private void cmdDelete_Click(object sender, EventArgs e)
        {
            if (dgHeaderBKK.SelectedCells[0].OwningRow.Cells["Src"].Value.ToString() != "OUT")
            {
                return;
            }

            DateTime _Tanggal = (DateTime)dgHeaderBKK.SelectedCells[0].OwningRow.Cells["tglBukti"].Value;

            if (_Tanggal.Date != GlobalVar.DateOfServer.Date)
            {
                KotakPesan.Warning("Tanggal Bukti transaksi Tidak sama dengan Tanggal server. Tidak bisa hapus record.");
                return;
            }
            if (PeriodeClosing.IsKasirClosed(_Tanggal))
            {
                MessageBox.Show("Sudah Closing!");
                return;
            }
            if (dgDetailBKK.SelectedCells.Count > 0)
            {
                MessageBox.Show("Anda tidak diperkenankan menghapus data ini");
                return;
            }
            string ques = "No Bukti : " + dgHeaderBKK.SelectedCells[0].OwningRow.Cells["noBukti"].Value.ToString() + " Akan Dihapus?";

            if ((dgHeaderBKK.SelectedCells.Count > 0) && (MessageBox.Show(ques, "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes))
            {
                Guid _rowID = (Guid)dgHeaderBKK.SelectedCells[0].OwningRow.Cells["RowID"].Value;
                try
                {
                    this.Cursor = Cursors.WaitCursor;
                    using (Database db = new Database(GlobalVar.DBFinance))
                    {
                        db.Commands.Add(db.CreateCommand("usp_Bukti_DELETE"));
                        db.Commands[0].Parameters.Add(new Parameter("@rowID", SqlDbType.UniqueIdentifier, _rowID));
                        db.Commands[0].ExecuteNonQuery();
                    }
                    #region "Tambahan"
                    int i = 0;
                    int n = 0;
                    i = dgHeaderBKK.SelectedCells[0].RowIndex;
                    n = dgHeaderBKK.SelectedCells[0].ColumnIndex;
                    DataRowView dv = (DataRowView)dgHeaderBKK.SelectedCells[0].OwningRow.DataBoundItem;

                    DataRow dr = dv.Row;

                    dr.Delete();
                    dtBKK.AcceptChanges();
                    dgHeaderBKK.Focus();
                    dgHeaderBKK.RefreshEdit();
                    if (dgHeaderBKK.RowCount > 0)
                    {
                        if (i == 0)
                        {
                            dgHeaderBKK.CurrentCell = dgHeaderBKK.Rows[0].Cells[n];
                            dgHeaderBKK.RefreshEdit();
                        }
                        else
                        {
                            dgHeaderBKK.CurrentCell = dgHeaderBKK.Rows[i - 1].Cells[n];
                            dgHeaderBKK.RefreshEdit();
                        }
                    }
                    #endregion
                    //di remark
                    //HeaderRefresh();
                    //DetailRefresh();
                }
                catch (Exception ex)
                {
                    Error.LogError(ex);
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            }
        }
Exemplo n.º 9
0
        private void cmdDelete_Click(object sender, EventArgs e)
        {
            if (selectMode == enumSelectMode.Header)
            {
                if (gridHeader.SelectedCells.Count > 0)
                {
                    DateTime _Tanggal = (DateTime)gridHeader.SelectedCells[0].OwningRow.Cells["hdrTglVoucher"].Value;
                    if (_Tanggal.Date != GlobalVar.DateOfServer.Date)
                    {
                        KotakPesan.Warning("Tanggal server tidak sama dengan tanggal transaksi. \n Tidak bisa hapus transaksi");
                        return;
                    }
                    if (PeriodeClosing.IsKasirClosed(_Tanggal))
                    {
                        MessageBox.Show("Sudah Closing!");
                        return;
                    }
                    Guid rowID = (Guid)gridHeader.SelectedCells[0].OwningRow.Cells["hdrRowID"].Value;
                    if ((int)dtDetail.Compute("count(Nomor)", "") > 0)
                    {
                        KotakPesan.Warning("Sudah ada record di detail, tidak bisa hapus record. \n Silahkan hapus record detail terlebih dahulu.");
                        return;
                    }

                    if (MessageBox.Show("Data Ini Akan Dihapus?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        if (!SecurityManager.AskPasswordManager())
                        {
                            return;
                        }
                        else
                        {
                            try
                            {
                                using (Database db = new Database(GlobalVar.DBFinance))
                                {
                                    VoucherJournal.DeleteVoucherJournal(db, rowID);
                                }



                                #region "Tambahan"
                                int i = 0;
                                int n = 0;
                                i = gridHeader.SelectedCells[0].RowIndex;
                                n = gridHeader.SelectedCells[0].ColumnIndex;
                                DataRowView dv = (DataRowView)gridHeader.SelectedCells[0].OwningRow.DataBoundItem;

                                DataRow dr = dv.Row;

                                dr.Delete();
                                dtHeader.AcceptChanges();
                                gridHeader.Focus();
                                gridHeader.RefreshEdit();
                                if (gridHeader.RowCount > 0)
                                {
                                    if (i == 0)
                                    {
                                        gridHeader.CurrentCell = gridHeader.Rows[0].Cells[n];
                                        gridHeader.RefreshEdit();
                                    }
                                    else
                                    {
                                        gridHeader.CurrentCell = gridHeader.Rows[i - 1].Cells[n];
                                        gridHeader.RefreshEdit();
                                    }
                                }
                                #endregion
                            }
                            catch (Exception ex)
                            {
                                Error.LogError(ex);
                            }
                        }
                    }
                }
            }
            else
            {
                if (gridDetail.SelectedCells.Count > 0)
                {
                    DateTime _Tanggal = (DateTime)gridHeader.SelectedCells[0].OwningRow.Cells["hdrTglVoucher"].Value;
                    if (PeriodeClosing.IsKasirClosed(_Tanggal))
                    {
                        MessageBox.Show("Sudah Closing!");
                        return;
                    }
                    if (MessageBox.Show("Apakah giro ini tidak jadi dititipkan?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Guid _GiroID = (Guid)gridDetail.SelectedCells[0].OwningRow.Cells["GiroID"].Value;
                        Guid _RowID  = (Guid)gridHeader.SelectedCells[0].OwningRow.Cells["hdrRowID"].Value;
                        try
                        {
                            using (Database db = new Database(GlobalVar.DBFinance))
                            {
                                db.Commands.Add(db.CreateCommand("usp_Giro_BatalTitip"));
                                db.Commands[0].Parameters.Add(new Parameter("@GiroID", SqlDbType.UniqueIdentifier, _GiroID));
                                db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                                db.Commands[0].ExecuteNonQuery();
                            }
                            HeaderRowRefresh(_RowID);
                            #region "Tambahan"
                            int i = 0;
                            int n = 0;
                            i = gridDetail.SelectedCells[0].RowIndex;
                            n = gridDetail.SelectedCells[0].ColumnIndex;
                            DataRowView dv = (DataRowView)gridDetail.SelectedCells[0].OwningRow.DataBoundItem;

                            DataRow dr = dv.Row;

                            dr.Delete();
                            dtDetail.AcceptChanges();
                            gridDetail.Focus();
                            gridDetail.RefreshEdit();
                            if (gridDetail.RowCount > 0)
                            {
                                if (i == 0)
                                {
                                    gridDetail.CurrentCell = gridDetail.Rows[0].Cells[n];
                                    gridDetail.RefreshEdit();
                                }
                                else
                                {
                                    gridDetail.CurrentCell = gridDetail.Rows[i - 1].Cells[n];
                                    gridDetail.RefreshEdit();
                                }
                            }
                            #endregion
                        }
                        catch (Exception ex)
                        {
                            Error.LogError(ex);
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            if (dataSudahAda())
            {
                KotakPesan.Warning("Data Sudah Ada di database");
                txtNama.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txtNama.Text))
            {
                KotakPesan.Warning("Anda belum mengisi data Nama");
                txtNama.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txtLokasi.Text))
            {
                KotakPesan.Warning("Anda belum mengisi data Lokasi");
                txtLokasi.Focus();
                return;
            }
            try
            {
                switch (formMode)
                {
                case enumFormMode.NEW:

                    using (Database db = new Database(GlobalVar.DBFinance))
                    {
                        db.Open();
                        DataTable dt = new DataTable();
                        db.Commands.Add(db.CreateCommand("[usp_BankKota_INSERT]"));
                        db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, RowID));
                        db.Commands[0].Parameters.Add(new Parameter("@Nama", SqlDbType.VarChar, txtNama.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@Lokasi", SqlDbType.VarChar, txtLokasi.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@StatusAktif", SqlDbType.Bit, cbaktif.Checked));
                        db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserName));
                        dt = db.Commands[0].ExecuteDataTable();
                        db.Close();
                        db.Dispose();
                        KotakPesan.Information("Insert Berhasil");
                    }
                    break;

                case enumFormMode.UPDATE:
                    using (Database db = new Database(GlobalVar.DBFinance))
                    {
                        db.Open();
                        DataTable dt = new DataTable();
                        db.Commands.Add(db.CreateCommand("[usp_BankKota_UPDATE]"));
                        db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, RowID));
                        db.Commands[0].Parameters.Add(new Parameter("@Nama", SqlDbType.VarChar, txtNama.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@Lokasi", SqlDbType.VarChar, txtLokasi.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@StatusAktif", SqlDbType.Bit, cbaktif.Checked));
                        db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserName));
                        dt = db.Commands[0].ExecuteDataTable();
                        db.Close();
                        db.Dispose();
                        KotakPesan.Information("Update Berhasil");
                    }
                    break;
                }
                this.DialogResult = DialogResult.OK;
                frmBankKotaBrowse frmcaller = (frmBankKotaBrowse)this.Caller;
                frmcaller.RefreshData();
                this.Close();
                frmcaller.Show();
            }
            catch (Exception ex)
            {
                Error.LogError(ex);
            }
        }