Beispiel #1
0
 private void frmServiceTransjUpdate_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (this.DialogResult == DialogResult.OK)
     {
         if (this.Caller is frmServiceBrowser)
         {
             frmServiceBrowser formCaller = (frmServiceBrowser)this.Caller;
             formCaller.RefreshDataNotaPOS();
             formCaller.FindRow(FormTools.detailIndex.detail2, "RowID", _rowID.ToString());
         }
     }
 }
Beispiel #2
0
        private void cmdSAVE_Click(object sender, EventArgs e)
        {
            if (!ValidateInput())
            {
                return;
            }
            if (lookupToko1.KodeToko == "" || lookupToko1.KodeToko == "[CODE]" && (Perbaikan_ != "UMUM" || Perbaikan_ == "INSTANSI" || Perbaikan_ == "SEKOLAH"))
            {
                MessageBox.Show("Toko Harus di isi");
                return;
            }
            double Qty = 0, Hrg = 0;

            Qty = Convert.ToDouble(txtQty.Text);
            Hrg = Convert.ToDouble(txtHargaSat.Text);

            if (Qty == 0)
            {
                MessageBox.Show("QTY masih kosong");
                return;
            }
            if (Hrg == 0)
            {
                MessageBox.Show("Harga Jual masih kosong");
                return;
            }

            try
            {
                using (Database db = new Database())
                {
                    DataTable dtc = new DataTable();
                    db.Commands.Add(db.CreateCommand("usp_StokBengkelCekIdbrg_LIST"));
                    db.Commands[0].Parameters.Add(new Parameter("@id_brg", SqlDbType.VarChar, lkpStokBkl.KodeStokBkl));
                    dtc = db.Commands[0].ExecuteDataTable();
                    if (dtc.Rows.Count == 0)
                    {
                        MessageBox.Show("Barang ini tidak ada di master stok bengkel");
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                Error.LogError(ex);
            }

            try
            {
                this.Cursor = Cursors.WaitCursor;
                switch (_formMode)
                {
                case FormTools.enumFormMode.New:
                    _rowID = Guid.NewGuid();
                    using (Database db = new Database())
                    {
                        db.Commands.Add(db.CreateCommand("usp_bkl_djual_INSERT"));
                        db.Commands[0].Parameters.Add(new Parameter("@rowID", SqlDbType.UniqueIdentifier, _rowID));
                        db.Commands[0].Parameters.Add(new Parameter("@headerID", SqlDbType.UniqueIdentifier, (Guid)dtService.Rows[0]["RowID"]));
                        db.Commands[0].Parameters.Add(new Parameter("@Idtr", SqlDbType.VarChar, HtrID_));
                        db.Commands[0].Parameters.Add(new Parameter("@id_brg", SqlDbType.VarChar, lkpStokBkl.KodeStokBkl));
                        db.Commands[0].Parameters.Add(new Parameter("@nama_stok", SqlDbType.VarChar, lkpStokBkl.NamaStokBkl));
                        db.Commands[0].Parameters.Add(new Parameter("@j_nota", SqlDbType.Decimal, txtQty.GetDoubleValue));
                        db.Commands[0].Parameters.Add(new Parameter("@h_jual", SqlDbType.Decimal, txtHargaSat.GetDoubleValue));
                        db.Commands[0].Parameters.Add(new Parameter("@satuan", SqlDbType.VarChar, txtSatuan.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@RowStokBkl", SqlDbType.UniqueIdentifier, lkpStokBkl.RowStokBkl));
                        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].Parameters.Add(new Parameter("@Gudang", SqlDbType.VarChar, GlobalVar.Gudang));
                        db.Commands[0].Parameters.Add(new Parameter("@kd_toko", SqlDbType.VarChar, lookupToko1.KodeToko));
                        db.Commands[0].ExecuteNonQuery();
                    }
                    UpdateServiceFlagStokBkl();
                    this.DialogResult = DialogResult.OK;
                    MessageBox.Show("Data telah disimpan");
                    //Clear();

                    if (this.Caller is frmServiceBrowser)
                    {
                        frmServiceBrowser formCaller = (frmServiceBrowser)this.Caller;
                        formCaller.RefreshDataJual();
                        formCaller.FindRow(FormTools.detailIndex.detail3, "RowID4", _rowID.ToString());
                    }
                    this.Close();
                    break;

                case FormTools.enumFormMode.Update:
                    using (Database db = new Database())
                    {
                        db.Commands.Add(db.CreateCommand("usp_bkl_djual_UPDATE"));
                        db.Commands[0].Parameters.Add(new Parameter("@rowID", SqlDbType.UniqueIdentifier, _rowID));
                        db.Commands[0].Parameters.Add(new Parameter("@headerID", SqlDbType.UniqueIdentifier, dtServiceJual.Rows[0]["HeaderID"]));
                        db.Commands[0].Parameters.Add(new Parameter("@j_nota", SqlDbType.Decimal, txtQty.GetDoubleValue));
                        db.Commands[0].Parameters.Add(new Parameter("@h_jual", SqlDbType.Decimal, txtHargaSat.GetDoubleValue));
                        db.Commands[0].Parameters.Add(new Parameter("@satuan", SqlDbType.VarChar, txtSatuan.Text));
                        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");
                    if (this.Caller is frmServiceBrowser)
                    {
                        frmServiceBrowser formCaller = (frmServiceBrowser)this.Caller;
                        formCaller.RefreshDataJual();
                        formCaller.FindRow(FormTools.detailIndex.detail3, "RowID4", _rowID.ToString());
                    }
                    this.Close();
                    break;
                }
            }
            catch (Exception ex)
            {
                Error.LogError(ex);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }