Ejemplo n.º 1
0
 private void frmAmbilDODariBOFilter2nd_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (this.DialogResult == DialogResult.OK)
     {
         frmDOBeliBrowser formCaller = (frmDOBeliBrowser)this.Caller;
         formCaller.RefreshDataOrderPembelianDetail();
     }
 }
Ejemplo n.º 2
0
 private void frmDOBeliUpdate_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (this.DialogResult == DialogResult.OK)
     {
         if (this.Caller is frmDOBeliBrowser)
         {
             frmDOBeliBrowser formCaller = (frmDOBeliBrowser)this.Caller;
             formCaller.RefreshDataOrderPembelian();
             formCaller.FindHeader("HeaderRowID", _rowID.ToString());
             formCaller.opendetail();
         }
     }
 }
Ejemplo n.º 3
0
        private void cmdSAVE_Click(object sender, EventArgs e)
        {
            if (!ValidateInput())
            {
                return;
            }

            if (_formMode == enumFormMode.New)
            {
                if (CekInputBarang())
                {
                    MessageBox.Show("Barang ID:" + lookupStock.BarangID + " sudah diinput");
                    return;
                }
            }

            if ((txtQtyOrder.GetIntValue + txtQtyAkhir.GetIntValue) > txtQtyMax.GetIntValue && (string.IsNullOrEmpty(txtKet.Text)))
            {
                MessageBox.Show("Nilai Order " + lookupStock.NamaStock + " Melebihi batas Stok Maksimum." + System.Environment.NewLine +
                                "Kelebihan " + ((txtQtyOrder.GetIntValue + txtQtyAkhir.GetIntValue) - txtQtyMax.GetIntValue).ToString() + System.Environment.NewLine +
                                "Harus isi alasan di keterangan");
                txtKet.Focus();
                return;
            }

            if (TxtHarga.GetDoubleValue > _hisHarga)
            {
                Double       selisih      = (TxtHarga.GetDoubleValue - _hisHarga);
                DialogResult dialogResult = MessageBox.Show("Harga beli lebih mahal RP " + selisih.ToString("#,##0.00") + " dari harga beli terakhir. \r\n pakah anda ingin melanjutkan.?", "Perhatian", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.No)
                {
                    TxtHarga.Focus();
                    return;
                }
            }
            if (TxtHarga.GetDoubleValue < _hisHarga)
            {
                Double       selisih      = (_hisHarga - TxtHarga.GetDoubleValue);
                DialogResult dialogResult = MessageBox.Show("Harga beli lebih Murah RP " + selisih.ToString("#,##0.00") + " dari harga beli terakhir. \r\n pakah anda ingin melanjutkan.?", "Perhatian", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.No)
                {
                    TxtHarga.Focus();
                    return;
                }
            }

            /*
             * if ( (txtQtyTambahan.GetIntValue + txtQtyAkhir.GetIntValue) < txtQtyMin.GetIntValue)
             * {
             *  MessageBox.Show("Nilai Order " + lookupStock.NamaStock + " Kurang dari  Stok Minimum ." + System.Environment.NewLine +
             *     "Kekurangan " + ((txtQtyTambahan.GetIntValue + txtQtyAkhir.GetIntValue) - txtQtyMin.GetIntValue).ToString()
             *     );
             * }
             */
            try
            {
                this.Cursor = Cursors.WaitCursor;
                switch (_formMode)
                {
                case enumFormMode.New:
                    _rowID = Guid.NewGuid();
                    using (Database db = new Database())
                    {
                        db.Commands.Add(db.CreateCommand("usp_OrderPembelianDetail_INSERT"));
                        db.Commands[0].Parameters.Add(new Parameter("@rowID", SqlDbType.UniqueIdentifier, _rowID));
                        db.Commands[0].Parameters.Add(new Parameter("@headerID", SqlDbType.UniqueIdentifier, dtDO.Rows[0]["RowID"]));
                        db.Commands[0].Parameters.Add(new Parameter("@recordID", SqlDbType.VarChar, Tools.CreateFingerPrint()));
                        db.Commands[0].Parameters.Add(new Parameter("@headerRecID", SqlDbType.VarChar, dtDO.Rows[0]["RecordID"]));
                        db.Commands[0].Parameters.Add(new Parameter("@barangID", SqlDbType.VarChar, lookupStock.BarangID));
                        db.Commands[0].Parameters.Add(new Parameter("@qtyDO", SqlDbType.Int, 0));
                        db.Commands[0].Parameters.Add(new Parameter("@qtyBO", SqlDbType.Int, txtQtyBO.GetIntValue));
                        db.Commands[0].Parameters.Add(new Parameter("@qtyTambahan", SqlDbType.Int, txtQtyOrder.GetIntValue));
                        db.Commands[0].Parameters.Add(new Parameter("@qtyJual", SqlDbType.Int, txtQtyJual.GetIntValue));
                        db.Commands[0].Parameters.Add(new Parameter("@qtyAkhir", SqlDbType.Int, txtQtyAkhir.GetIntValue));
                        db.Commands[0].Parameters.Add(new Parameter("@keterangan", SqlDbType.VarChar, txtKet.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@kodeGudang", SqlDbType.VarChar, GlobalVar.Gudang));
                        db.Commands[0].Parameters.Add(new Parameter("@catatan", SqlDbType.VarChar, ""));
                        db.Commands[0].Parameters.Add(new Parameter("@HARGA", SqlDbType.Money, double.Parse(TxtHarga.Text)));
                        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();
                    }
                    this.DialogResult = DialogResult.OK;
                    MessageBox.Show("Data telah disimpan");
                    Clear();
                    lookupStock.Focus();

                    break;

                case enumFormMode.Update:
                    using (Database db = new Database())
                    {
                        db.Commands.Add(db.CreateCommand("usp_OrderPembelianDetail_UPDATE"));
                        db.Commands[0].Parameters.Add(new Parameter("@rowID", SqlDbType.UniqueIdentifier, _rowID));
                        db.Commands[0].Parameters.Add(new Parameter("@headerID", SqlDbType.UniqueIdentifier, dtDODetail.Rows[0]["HeaderID"]));
                        db.Commands[0].Parameters.Add(new Parameter("@recordID", SqlDbType.VarChar, dtDODetail.Rows[0]["RecordID"]));
                        db.Commands[0].Parameters.Add(new Parameter("@headerRecID", SqlDbType.VarChar, dtDODetail.Rows[0]["HeaderRecID"]));
                        db.Commands[0].Parameters.Add(new Parameter("@barangID", SqlDbType.VarChar, lookupStock.BarangID));
                        db.Commands[0].Parameters.Add(new Parameter("@qtyDO", SqlDbType.Int, dtDODetail.Rows[0]["QtyDO"]));
                        db.Commands[0].Parameters.Add(new Parameter("@qtyBO", SqlDbType.Int, txtQtyBO.GetIntValue));
                        db.Commands[0].Parameters.Add(new Parameter("@qtyTambahan", SqlDbType.Int, txtQtyOrder.GetIntValue));
                        db.Commands[0].Parameters.Add(new Parameter("@qtyJual", SqlDbType.Int, txtQtyJual.GetIntValue));
                        db.Commands[0].Parameters.Add(new Parameter("@HARGA", SqlDbType.Money, double.Parse(TxtHarga.Text)));
                        db.Commands[0].Parameters.Add(new Parameter("@qtyAkhir", SqlDbType.Int, txtQtyAkhir.GetIntValue));
                        db.Commands[0].Parameters.Add(new Parameter("@keterangan", SqlDbType.VarChar, txtKet.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@kodeGudang", SqlDbType.VarChar, dtDODetail.Rows[0]["KodeGudang"]));
                        db.Commands[0].Parameters.Add(new Parameter("@catatan", SqlDbType.VarChar, dtDODetail.Rows[0]["Catatan"]));
                        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();
                    }
                    this.DialogResult = DialogResult.OK;
                    MessageBox.Show("Data telah disimpan");
                    this.Close();
                    break;
                }
            }
            catch (Exception ex)
            {
                Error.LogError(ex);
            }
            finally
            {
                this.Cursor = Cursors.Default;
                this.Close();
                frmDOBeliBrowser formCaller = (frmDOBeliBrowser)this.Caller;
                formCaller.opendetail();
            }
        }