public int AddOrderProdutioncustom(OrderProductioncustom oData) { methodName = "AddOrderProductioncustom"; traceID = 1; using (var uow = new UnitOfWork(AppConfig.Current.ContextName)) { using (var trans = uow.BeginTransaction()) { try { traceID = 2; OrderProductioncustom oNewumum = new OrderProductioncustom(); oNewumum.MapFrom(oData); oNewumum = uow.OrderProductioncustom.Add(oNewumum); uow.Save(); if (oNewumum.IdOrderProductionCustom > 0) { traceID = 3; oData.IdOrderProductionCustom = oNewumum.IdOrderProductionCustom; ListOrderProduction oNewListOrderJual = new ListOrderProduction(); oNewListOrderJual.MapFrom(oData); traceID = 4; oNewListOrderJual.IdOrder = oData.IdOrderProductionCustom; // oNewListOrderJual.Jumlah = oData.JumlahCustom; oNewListOrderJual.Sku = oData.NamaCustom; // oNewListOrderJual.HargaPokok = oData.HargaCustom; // oNewListOrderJual.SatuanDasar = oData.SatuanCustom; oNewListOrderJual.TotalOrder = oData.TotalCustom; uow.ListOrderProduction.Add(oNewListOrderJual); } traceID = 5; uow.Save(); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw new AppException(500, methodName, traceID, ex); } } } return(oData.IdOrderProductionCustom); }
public int AddOrderProdutioninput(OrderProductioninput oData) { methodName = "AddOrderProductioninput"; traceID = 1; using (var uow = new UnitOfWork(AppConfig.Current.ContextName)) { using (var trans = uow.BeginTransaction()) { try { traceID = 2; OrderProductioninput oNewumum = new OrderProductioninput(); oNewumum.MapFrom(oData); oNewumum = uow.OrderProductioninput.Add(oNewumum); uow.Save(); if (oNewumum.IdOrderProduction > 0) { traceID = 3; oData.IdOrderProduction = oNewumum.IdOrderProduction; ListOrderProduction oNewListOrderJual = new ListOrderProduction(); oNewListOrderJual.MapFrom(oData); traceID = 4; oNewListOrderJual.IdOrder = oData.IdOrderProduction; oNewListOrderJual.Jumlah = oData.JumlahProduk; oNewListOrderJual.TotalOrder = oData.TotalOrderProduk; uow.ListOrderProduction.Add(oNewListOrderJual); } traceID = 5; uow.Save(); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw new AppException(500, methodName, traceID, ex); } } } return(oData.IdOrderProduction); }
public bool EditProductioninput(ListOrderProduction oData, production oDatas) { methodName = "EditProductioninput"; traceID = 1; using (var uow = new UnitOfWork(AppConfig.Current.ContextName)) { traceID = 2; var oDBData = uow.ListOrderProduction.Get(oData.Id); if (oDBData != null) { using (var trans = uow.BeginTransaction()) { try { traceID = 3; oDBData.MapFrom(oData); uow.ListOrderProduction.Update(oDBData); traceID = 4; OrderProductioninput oDBListorderjual = uow.OrderProductioninput.SingleOrDefault(m => m.IdOrderProduction == oData.IdOrder); if (oDBListorderjual != null) { traceID = 5; oDBListorderjual.MapFrom(oData); traceID = 6; uow.OrderProductioninput.Update(oDBListorderjual); } else { traceID = 7; OrderProductioninput oNewListorderjual = new OrderProductioninput(); oNewListorderjual.MapFrom(oData); traceID = 8; uow.OrderProductioninput.Add(oNewListorderjual); } traceID = 9; OrderProductioncustom oDBListorderjual1 = uow.OrderProductioncustom.SingleOrDefault(m => m.IdOrderProductionCustom == oData.IdOrder); if (oDBListorderjual1 != null) { traceID = 10; oDBListorderjual1.MapFrom(oData); traceID = 11; uow.OrderProductioncustom.Update(oDBListorderjual1); } else { traceID = 12; traceID = 13; } traceID = 14; uow.Save(); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw new AppException(500, methodName, traceID, ex); } } } } return(true); }
private void SaveProduction_Click(object sender, RoutedEventArgs e) { if (txtProductionNumber.Text == "") { MessageBox.Show("please fill in the blank fields", ("Form Validation"), MessageBoxButton.OK, MessageBoxImage.Error); return; } ProductionBLL productionBLL = new ProductionBLL(); ProductionBLL ProductionBLL = new ProductionBLL(); production production = new production(); production.IdKodeTransaksi = 28; if (this.dokumenSelected != null) { production.IdDocumentReference = this.dokumenSelected.Id; production.DokumenReference = this.dokumenSelected.NoReferensiDokumen; } production.Tanggal = DateTime.Parse(tanggal.Text); if (this.lokasiSelected != null) { production.IdLokasi = this.lokasiSelected.Id; production.Location = this.lokasiSelected.NamaTempatLokasi; } if (this.kontakSelected != null) { production.IdKontak = this.kontakSelected.Id; production.NamaPetugas = this.kontakSelected.NamaA; } production.Note = txtNote.Text; production.ProductionNumber = double.Parse(txtProductionNumber.Text); production.TotalDebitAkunPersediaanProduk = double.Parse(txtTotal.Text); production.TotalKreditAkunPersediaanProduk = double.Parse(txtTotalinput.Text); if (this.dataDepartemenSelected != null) { production.IdDepartmen = this.dataDepartemenSelected.Id; } if (this.dataProyekSelected != null) { production.IdProyek = this.dataProyekSelected.Id; } if (ProductionBLL.AddProduction(production) > 0) { // this.ClearForm(); MessageBox.Show("Productions successfully added !"); } else { MessageBox.Show("Productions failed to add !"); } if (DGSKUProduction.Items.Count > 0) { foreach (var item in DGSKUProduction.Items) { if (item is ListOrderProduction) { ListOrderProduction oNewData1 = (ListOrderProduction)item; if (this.lokasiSelected != null) { oNewData1.IdLokasi = this.lokasiSelected.Id; oNewData1.NamaLokasi = this.lokasiSelected.NamaTempatLokasi; } oNewData1.Tanggal = DateTime.Parse(tanggal.Text); oNewData1.CheckboxAktif = false; oNewData1.IdTransaksi = production.Id; if (this.dataDepartemenSelected != null) { oNewData1.IdDepartemen = this.dataDepartemenSelected.Id; } if (this.dataProyekSelected != null) { oNewData1.IdProyek = this.dataProyekSelected.Id; } if (productionBLL.EditProductioninput(oNewData1, production) == true) { } } } } if (DGSKUFinishedProduction.Items.Count > 0) { foreach (var item in DGSKUFinishedProduction.Items) { if (item is OrderFinishedproduk) { OrderFinishedproduk oNewData1 = (OrderFinishedproduk)item; if (this.lokasiSelected != null) { oNewData1.IdLokasi = this.lokasiSelected.Id; oNewData1.NamaLokasi = this.lokasiSelected.NamaTempatLokasi; } oNewData1.Tanggal = DateTime.Parse(tanggal.Text); oNewData1.CheckboxAktif = false; if (this.dataDepartemenSelected != null) { oNewData1.IdDepartemen = this.dataDepartemenSelected.Id; } if (this.dataProyekSelected != null) { oNewData1.IdProyek = this.dataProyekSelected.Id; } if (productionBLL.EditFinishedproduk(oNewData1, production) == true) { } } } Production v = new Production(); Switcher.SwitchNewProduction(v); } }