private void SaveInsert()
        {
            try
            {
                Validasi();

                //DateTime tglTerakhir;
                //using (Database db = new Database())
                //{
                //    db.Commands.Add(db.CreateCommand("usp_fnGetStokOpname"));
                //    db.Commands[0].Parameters.Add(new Parameter("@tgl", SqlDbType.DateTime, DateTime.Now));
                //    db.Commands[0].Parameters.Add(new Parameter("@kodeBarang", SqlDbType.VarChar, kodeBarang));
                //    db.Commands[0].Parameters.Add(new Parameter("@kodeGudang", SqlDbType.VarChar, GlobalVar.Gudang));
                //    tglTerakhir = (DateTime)db.Commands[0].ExecuteScalar();
                //}

                //if (dtTglOpname.DateValue <= tglTerakhir)
                //{
                //    MessageBox.Show("Tanggal opname harus lebih besar dari tanggal [" + tglTerakhir.ToString("dd/MM/yyyy") + "] opname terkahir");
                //    dtTglOpname.Focus();
                //    return;
                //}
                try
                {
                    using (Database db = new Database())
                    {
                        db.Commands.Add(db.CreateCommand("usp_OpnameHistory_INSERT"));

                        db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, Guid.NewGuid()));
                        db.Commands[0].Parameters.Add(new Parameter("@RecordID", SqlDbType.VarChar, Tools.CreateFingerPrint()));
                        db.Commands[0].Parameters.Add(new Parameter("@TglOpname", SqlDbType.DateTime, dtTglOpname.DateValue));
                        db.Commands[0].Parameters.Add(new Parameter("@QtyOpname", SqlDbType.Int, tbQtyOpname.GetIntValue));
                        db.Commands[0].Parameters.Add(new Parameter("@KodeBarang", SqlDbType.VarChar, kodeBarang));
                        db.Commands[0].Parameters.Add(new Parameter("@KodeGudang", SqlDbType.VarChar, GlobalVar.Gudang));
                        db.Commands[0].Parameters.Add(new Parameter("@Keterangan", SqlDbType.VarChar, tbPenghitung.Text.Trim() + " - " + tbKeterangan.Text.Trim()));
                        db.Commands[0].Parameters.Add(new Parameter("@Syncflag", SqlDbType.Bit, 0));
                        db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                        db.Commands[0].ExecuteNonQuery();
                    }
                    MessageBox.Show("Insert stok opname harian berhasil");

                    frmStokOpnameBrowse frmCaller = (frmStokOpnameBrowse)this.Caller;
                    frmCaller.RefreshDataDetail();

                    this.Close();
                }
                catch (System.Exception ex)
                {
                    Error.LogError(ex);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void SaveUpdate()
        {
            try
            {
                Validasi();

                if (dtTglOpname.DateValue != DateTime.Today)
                {
                    MessageBox.Show("Tanggal opname harus hari ini.");
                    dtTglOpname.Focus();
                    return;
                }

                try
                {
                    this.keterangan = tbPenghitung.Text.Trim() + " - " + tbKeterangan.Text.Trim();

                    using (Database db = new Database())
                    {
                        db.Commands.Add(db.CreateCommand("usp_OpnameHistory_UPDATE"));

                        db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, this.rowID));
                        db.Commands[0].Parameters.Add(new Parameter("@QtyOpname", SqlDbType.Int, tbQtyOpname.GetIntValue));
                        db.Commands[0].Parameters.Add(new Parameter("@KodeBarang", SqlDbType.VarChar, this.kodeBarang));
                        db.Commands[0].Parameters.Add(new Parameter("@KodeGudang", SqlDbType.VarChar, GlobalVar.Gudang));
                        db.Commands[0].Parameters.Add(new Parameter("@Keterangan", SqlDbType.VarChar, this.keterangan));
                        db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                        db.Commands[0].ExecuteNonQuery();
                    }
                    MessageBox.Show("Update stok opname harian berhasil");

                    frmStokOpnameBrowse frmCaller = (frmStokOpnameBrowse)this.Caller;
                    frmCaller.RefreshDataDetail();

                    this.Close();
                }
                catch (System.Exception ex)
                {
                    Error.LogError(ex);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }