private void cmdYes_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Transfer Opname ?", "Transfer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (PeriodeClosing.IsHPPClosed(dateTextBox1.DateValue.Value))
                {
                    MessageBox.Show("Sudah CLosing HPP");
                    return;
                }
                try
                {
                    this.Cursor = Cursors.WaitCursor;
                    using (Database db = new Database())
                    {
                        db.Commands.Add(db.CreateCommand("psp_Opname_Transfer"));
                        db.Commands[0].Parameters.Add(new Parameter("@TglOpname", SqlDbType.DateTime, dateTextBox1.DateValue));
                        db.Commands[0].Parameters.Add(new Parameter("@KodeGudang", SqlDbType.VarChar, GlobalVar.Gudang));
                        db.Commands[0].Parameters.Add(new Parameter("@lastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                        db.Commands[0].ExecuteNonQuery();

                        MessageBox.Show("Transfer opname telah selesai.");
                        this.Close();
                    }
                }
                catch (Exception ex)
                {
                    Error.LogError(ex);
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            }
        }
        private void cmdTransfer_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Transfer Opname ?", "Transfer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (PeriodeClosing.IsHPPClosed(dateTextBox1.DateValue.Value))
                {
                    MessageBox.Show("Sudah CLosing HPP");
                    return;
                }

                if (dsdata.Tables[0].Rows.Count > 0)
                {
                    Cursor.Current = Cursors.WaitCursor;
                    try
                    {
                        using (Database db = new Database())
                        {
                            db.Commands.Add(db.CreateCommand("usp_Opname_History_Delete"));
                            db.Commands[0].Parameters.Add(new Parameter("@KodeGudang", SqlDbType.VarChar, GlobalVar.Gudang));
                            db.Commands[0].Parameters.Add(new Parameter("@TglOpname", SqlDbType.DateTime, dateTextBox1.DateValue));
                            db.Commands[0].ExecuteNonQuery();
                            db.CommitTransaction();
                        }
                    }
                    catch (Exception ex) { Error.LogError(ex); }
                    finally { Cursor.Current = Cursors.Default; }


                    Cursor.Current = Cursors.WaitCursor;
                    try
                    {
                        int c = 1;
                        foreach (DataRow dr in dsdata.Tables[0].Rows)
                        {
                            string cRecordID = Tools.CreateFingerPrint().ToString().Substring(0, 17) + c.ToString().PadLeft(5, '0');
                            using (Database db = new Database())
                            {
                                db.Commands.Add(db.CreateCommand("psp_Opname_Transfer_INSERT"));
                                db.Commands[0].Parameters.Add(new Parameter("@RecordID", SqlDbType.VarChar, cRecordID));
                                db.Commands[0].Parameters.Add(new Parameter("@TglOpname", SqlDbType.DateTime, dr["TglOpname"]));
                                db.Commands[0].Parameters.Add(new Parameter("@KodeBarang", SqlDbType.VarChar, dr["KodeBarang"].ToString()));
                                db.Commands[0].Parameters.Add(new Parameter("@QtyOpname", SqlDbType.Int, int.Parse(Tools.isNull(dr["Jumlah"], "0").ToString())));
                                db.Commands[0].Parameters.Add(new Parameter("@KodeGudang", SqlDbType.VarChar, GlobalVar.Gudang));
                                db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBY", SqlDbType.VarChar, SecurityManager.UserID));
                                db.Commands[0].ExecuteNonQuery();
                                db.CommitTransaction();
                            }
                            c++;
                        }
                    }
                    catch (Exception ex) { Error.LogError(ex); }
                    finally { Cursor.Current = Cursors.Default; }

                    MessageBox.Show("Proses selesai");
                    //this.Close();
                }
            }
        }