public bool RemoveQuotationrequests(int id) { methodName = "RemoveQuotationrequests"; traceID = 1; using (var uow = new UnitOfWork(AppConfig.Current.ContextName)) { using (var trans = uow.BeginTransaction()) { try { traceID = 2; Quotationrequest oDBQuotationrequest = uow.Quotationrequest.SingleOrDefault(m => m.IdPermintaanPenawaranHarga == id); if (oDBQuotationrequest != null) { traceID = 3; uow.Quotationrequest.Remove(id); uow.Save(); } traceID = 5; trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw new AppException(500, methodName, traceID, ex); } } } return(true); }
public bool EditQuotationrequests(Quotationrequest oData) { methodName = "EditQuotationrequests"; traceID = 1; using (var uow = new UnitOfWork(AppConfig.Current.ContextName)) { traceID = 2; var oDBData = uow.Quotationrequest.Get(oData.IdPermintaanPenawaranHarga); if (oDBData != null) { using (var trans = uow.BeginTransaction()) { try { traceID = 3; oDBData.MapFrom(oData); uow.Quotationrequest.Update(oDBData); traceID = 4; uow.Save(); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw new AppException(500, methodName, traceID, ex); } } } } return(true); }
public int AddQuotationrequests(Quotationrequest oData) { methodName = "AddQuotationrequests"; traceID = 1; using (var uow = new UnitOfWork(AppConfig.Current.ContextName)) { using (var trans = uow.BeginTransaction()) { try { traceID = 2; Quotationrequest oNewQuotationrequest = new Quotationrequest(); oNewQuotationrequest.MapFrom(oData); oNewQuotationrequest = uow.Quotationrequest.Add(oNewQuotationrequest); uow.Save(); traceID = 3; oData.IdPermintaanPenawaranHarga = oNewQuotationrequest.IdPermintaanPenawaranHarga; uow.Save(); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw new AppException(500, methodName, traceID, ex); } } } return(oData.IdPermintaanPenawaranHarga); }
private void quota_selectedchange(object sender, SelectionChangedEventArgs e) { this.quotationrequestSelected = null; if (cbQuotationNo.SelectedItem != null) { quotationrequestSelected = (Quotationrequest)cbQuotationNo.SelectedItem; this.LoadDataSku(); txtNote.Text = this.quotationrequestSelected.Keterangan; cbLocation.SelectedValue = this.quotationrequestSelected.IdLokasi; dtPurchase.Text = this.quotationrequestSelected.TanggalPermintaanPenawaranHarga.GetValueOrDefault().ToShortDateString(); cbCurrency.SelectedValue = this.quotationrequestSelected.IdMataUang; srnodokumen.Text = this.quotationrequestSelected.NoReferensiDokumen.ToString(); txttax1.Text = this.quotationrequestSelected.IdTransaksi.GetValueOrDefault().ToString(); cbDepartment.SelectedValue = this.quotationrequestSelected.IdDepartemen; cbProyek.SelectedValue = this.quotationrequestSelected.IdProyek; chkComplete.IsChecked = this.quotationrequestSelected.CheckboxSelesai.GetValueOrDefault(); dtDelivery.Text = this.quotationrequestSelected.TanggalPenutupan.GetValueOrDefault().ToShortDateString(); dtAnnual.Text = this.quotationrequestSelected.TanggalBerulang.GetValueOrDefault().ToShortDateString(); srstaff.Text = this.quotationrequestSelected.NamaPetugas; chkannual.IsChecked = this.quotationrequestSelected.CheckboxBerulang.GetValueOrDefault(); cbAnnual.SelectedValue = this.quotationrequestSelected.IdOpsiAnnual.ToString(); txtAnnualFrequency.Text = this.quotationrequestSelected.DurasiBerulang.ToString(); } }
public bool EditOrderProdukBeli(ListOrderBeli oData, Quotationrequest oDatas, produk oDatap) { methodName = "EditOrderProdukBeli"; traceID = 1; using (var uow = new UnitOfWork(AppConfig.Current.ContextName)) { traceID = 2; var oDBData = uow.ListOrderBeli.Get(oData.Id); if (oDBData != null) { using (var trans = uow.BeginTransaction()) { try { traceID = 3; oDBData.MapFrom(oData); uow.ListOrderBeli.Update(oDBData); traceID = 4; OrderProdukBeli oDBListorderbeli = uow.OrderProdukBeli.SingleOrDefault(m => m.IdOrderProdukBeli == oData.IdOrderBeli); if (oDBListorderbeli != null) { traceID = 5; oDBListorderbeli.MapFrom(oData); traceID = 6; uow.OrderProdukBeli.Update(oDBListorderbeli); } else { traceID = 7; OrderProdukBeli oNewListorderbeli = new OrderProdukBeli(); oNewListorderbeli.MapFrom(oData); traceID = 8; uow.OrderProdukBeli.Add(oNewListorderbeli); } traceID = 9; OrderJasaBeli oDBListorderbeli1 = uow.OrderJasaBeli.SingleOrDefault(m => m.IdOrderJasa == oData.IdOrderBeli); if (oDBListorderbeli1 != null) { traceID = 10; oDBListorderbeli1.MapFrom(oData); traceID = 11; // oDBListorderbeli1.TanggalStartdate = oData.TanggalPengiriman; uow.OrderJasaBeli.Update(oDBListorderbeli1); } else { traceID = 12; traceID = 13; } traceID = 4; produk oDproduk = uow.produk.SingleOrDefault(m => m.IdProduk == oData.IdProduk); if (oDproduk != null) { traceID = 5; oData.IdProduk = oDproduk.IdProduk; oData.Checkboxaktif = true; oDproduk.MapFrom(oData); traceID = 6; oData.IdProduk = oDproduk.IdProduk; oData.Checkboxaktif = true; oDproduk.JumlahStok = oDBData.Jumlah + oDproduk.JumlahStok; uow.produk.Update(oDproduk); } else { traceID = 7; traceID = 8; } traceID = 14; uow.Save(); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw new AppException(500, methodName, traceID, ex); } } } } return(true); }
private void SavePurchaseOrder_Click(object sender, RoutedEventArgs e) { if (srvendor.Name == "" || txtemail.Name == "" || txthp.Name == "" || dtPurchase.Text == "" || cbCurrency.Text == "" || srnodokumen.Name == "" || txtPurchaseOrderNo.Text == "" || cbQuotationNo.Name == "" || cbLocation.Text == "" || dtDelivery.Text == "" || cbAnnual.Text == "" || srstaff.Name == "" || txtAnnualFrequency.Text == "" || dtAnnual.Text == "") { MessageBox.Show("please fill in the blank fields", ("Form Validation"), MessageBoxButton.OK, MessageBoxImage.Error); return; } PurchaseordersBLL purchaseordersBLL = new PurchaseordersBLL(); QuotationrequestBLL quotationrequestBLL = new QuotationrequestBLL(); PurchaseOrder oNewData1 = new PurchaseOrder(); oNewData1.KodeTransaksi = "PO"; oNewData1.IdKodeTransaksi = 17; if (this.kontakSelected != null) { oNewData1.IdVendor = this.kontakSelected.Id; oNewData1.NamaVendor = this.kontakSelected.NamaA; } oNewData1.Email = txtemail.Text; oNewData1.NoHp = txthp.Text; oNewData1.TanggalOrderPembelian = DateTime.Parse(dtPurchase.Text); if (this.DataMataUangSelected != null) { oNewData1.IdMataUang = this.DataMataUangSelected.Id; oNewData1.MataUang = this.DataMataUangSelected.NamaMataUang; oNewData1.KursTukar = this.DataMataUangSelected.KursTukar; } if (this.dokumenSelected != null) { oNewData1.IdNoReferensiDokumen = this.dokumenSelected.Id; oNewData1.NoReferensiDokumen = this.dokumenSelected.NoReferensiDokumen; } oNewData1.NoOrderPembelian = double.Parse(txtPurchaseOrderNo.Text); if (this.quotationrequestSelected != null) { oNewData1.IdPermintaanPenawaranHarga = this.quotationrequestSelected.IdPermintaanPenawaranHarga; oNewData1.NoPermintaanPenawaranHarga = this.quotationrequestSelected.NoPemintaanPenawaranHarga; } oNewData1.Keterangan = txtNote.Text; if (this.lokasiSelected != null) { oNewData1.IdLokasi = this.lokasiSelected.Id; oNewData1.NamaLokasi = this.lokasiSelected.NamaTempatLokasi; } if (this.dataDepartemenSelected != null) { oNewData1.IdDepartemen = this.dataDepartemenSelected.Id; } if (this.dataProyekSelected != null) { oNewData1.IdProyek = this.dataProyekSelected.Id; } oNewData1.CheckboxSelesai = chkComplete.IsChecked; oNewData1.CheckboxInclusiveTax = chkinclusive.IsChecked; oNewData1.CheckboxBerulang = chkannual.IsChecked; oNewData1.TanggalPengantaran = DateTime.Parse(dtDelivery.Text); oNewData1.DurasiBerulang = double.Parse(txtAnnualFrequency.Text); oNewData1.TanggalBerulang = DateTime.Parse(dtAnnual.Text); if (this.optionAnnualSelected != null) { oNewData1.IdOpsiAnnual = this.optionAnnualSelected.IdOptionAnnual; oNewData1.Annual = this.optionAnnualSelected.Annual; } if (this.petugasSelected != null) { oNewData1.IdPetugas = this.petugasSelected.Id; oNewData1.NamaPetugas = this.petugasSelected.NamaA; } if (this.termspembayaranSelected != null) { oNewData1.IdTermPembayaran = this.termspembayaranSelected.IdTermPembayaran; oNewData1.TermPembayaran = this.termspembayaranSelected.NamaSkema; } if (this.quotationrequestSelected != null) { oNewData1.IdTransaksi = this.quotationrequestSelected.IdTransaksi; } oNewData1.TotalOrderProduk = double.Parse(txttotalprodukbeforetax.Text); oNewData1.TotalOrderJasa = double.Parse(txttotaljasabeforetax.Text); oNewData1.TotalPajakJasa = double.Parse(txtTotaljasaTax.Text); oNewData1.TotalPajakProduk = double.Parse(txtTotalprodukTax.Text); oNewData1.TotalSebelumPajak = double.Parse(txttotalbeforetax.Text); oNewData1.TotalPajak = double.Parse(txtTotalTax.Text); oNewData1.TotalSetelahPajak = double.Parse(txtAfterTotalTax.Text); oNewData1.RealRecordingTime = DateTime.Now; oNewData1.Checkboxaktif = true; if (purchaseordersBLL.AddPurchaseorders(oNewData1) > 0) { // this.ClearForm(); MessageBox.Show("Purchased Order successfully added !"); } else { MessageBox.Show("Purchased Order failed to add !"); } if (cbQuotationNo.Items.Count > 0) { foreach (var item in cbQuotationNo.Items) { if (item is Quotationrequest) { Quotationrequest oNewData2 = (Quotationrequest)item; oNewData2.Checkboxaktif = false; if (quotationrequestBLL.EditQuotationrequests(oNewData2) == true) { } } } } if (DGSKUorder.Items.Count > 0) { foreach (var item in DGSKUorder.Items) { if (item is ListOrderBeli) { ListOrderBeli oNewData3 = (ListOrderBeli)item; oNewData3.Tanggal = DateTime.Parse(dtPurchase.Text); if (this.lokasiSelected != null) { oNewData3.IdLokasi = this.lokasiSelected.Id; oNewData3.NamaLokasi = this.lokasiSelected.NamaTempatLokasi; } if (this.dataDepartemenSelected != null) { oNewData3.IdDepartemen = this.dataDepartemenSelected.Id; } if (this.dataProyekSelected != null) { oNewData3.IdProyek = this.dataProyekSelected.Id; } if (int.Parse(txttota.Text) == 0) { oNewData3.IdTransaksi = oNewData1.IdOrderPembelian; } oNewData3.Checkboxaktif = false; if (purchaseordersBLL.EditOrderProdukbeli(oNewData3, oNewData1) == true) { } } } } PurchaseDocument v = new PurchaseDocument(); Switcher.SwitchNewPurchasedOrder(v); }