public static void PrintNotaAction(Penjualan obj) { var list = CreateReportModel(obj); HelperPrint print = new HelperPrint(); print.PrintNota(list, "TrireksaApp.Reports.Layouts.NotaComplete.rdlc", null); }
internal async Task <bool> Update(int id, Penjualan penj) { var item = await client.PutAsync <Penjualan>("", id, penj); var data = Source.Where(O => O.Id == id).FirstOrDefault(); if (item != default(Penjualan) && data != null) { data.CustomerIsPay = item.CustomerIsPay; data.Colly = item.Colly; data.Etc = item.Etc; data.FromCity = item.FromCity; data.ToCity = item.ToCity; data.PackingCosts = item.PackingCosts; data.PayType = item.PayType; data.PortType = item.PortType; data.Price = item.Price; data.ReciverID = item.ReciverID; data.ShiperID = item.ShiperID; data.STT = item.STT; data.Tax = item.Tax; data.Total = item.Total; data.TypeOfWeight = item.TypeOfWeight; data.UserID = item.UserID; data.Content = item.Content; data.DoNumber = item.DoNumber; data.Id = item.Id; data.ChangeDate = item.ChangeDate; data.Note = item.Note; SourceView.Refresh(); return(true); } return(false); }
public frmBrowse(string tabel) { InitializeComponent(); this.tabel = tabel; if (tabel == "barang") { dgvBrowse.DataSource = Barang.FindAll(); } else if (tabel == "customer") { dgvBrowse.DataSource = Customer.FindAll(); } else if (tabel == "supplier") { dgvBrowse.DataSource = Supplier.FindAll(); } else if (tabel == "penjualan") { dgvBrowse.DataSource = Penjualan.FindAll(); } else if (tabel == "pembelian") { dgvBrowse.DataSource = Pembelian.FindAll(); } dgvBrowse.Refresh(); data = new Dictionary <string, string> { }; dt = (DataTable)dgvBrowse.DataSource; }
public ActionResult DeleteConfirmed(int id) { Penjualan penjualan = db.Penjualan.Find(id); db.Penjualan.Remove(penjualan); db.SaveChanges(); return(RedirectToAction("Index")); }
private async void Proccess(Penjualan value) { await Task.Delay(200); this.PenjualanId = value.PenjualanId; this.TanggalBayar = DateTime.Now; var pelunasan = this.context.GetPelunasanUtang().Where(x => x.PenjualanId == value.PenjualanId); this.Bayar = Selected.Total - pelunasan.Sum(x => x.Bayar); }
public async Task <IActionResult> Post(int orderid, Penjualan model) { try { return(Ok(await service.CreatePenjualan(orderid, model))); } catch (Exception ex) { return(BadRequest(new ErrorMessage(ex.Message))); } }
public async Task <IActionResult> Put(int id, Penjualan penjualan) { try { return(Ok(await service.UpdatePenjualan(id, penjualan))); } catch (Exception ex) { return(BadRequest(new ErrorMessage(ex.Message))); } }
public async Task <Penjualan> Add(Penjualan item) { var result = await client.PostAsync <Penjualan>("", item); if (result != null) { Source.Add(result); SourceView.Refresh(); } return(result); }
public async Task <IActionResult> Put(int id, Penjualan value) { try { return(Ok(await context.Update(id, value))); } catch (Exception ex) { return(BadRequest(new ErrorMessage(ex.Message))); } }
public async Task <IActionResult> Post(Penjualan value) { try { return(Ok(await context.InsertAndGetItem(value))); } catch (Exception ex) { return(BadRequest(new ErrorMessage(ex.Message))); } }
private static List <Reports.Models.NotaReportModel> CreateReportModel(Penjualan obj) { var MainVM = Common.ResourcesBase.GetMainWindowViewModel(); var item = obj; var userP = ResourcesBase.UserIsLogin.FirstName; List <Reports.Models.NotaReportModel> list = new List <Reports.Models.NotaReportModel>(); var data = new Reports.Models.NotaReportModel { STT = string.Format("{0:D5}", item.STT), Content = item.Content, DoNumber = item.DoNumber, Note = item.Note, PayTypeName = item.PayType.ToString(), Pcs = item.Colly.Count, PortTypeName = item.PortType.ToString(), Price = item.Price, ChangeDate = item.ChangeDate, UserName = userP, Tax = item.Tax, PackingCosts = item.PackingCosts, Etc = item.Etc, }; var weight = item.Colly.Sum(O => O.Weight); data.Costs = weight * item.Price; data.TaxValue = (item.Tax * data.Costs) / 100; if (item.TypeOfWeight == TypeOfWeight.Volume) { data.Volume = weight; } else { data.Weight = weight; } data.GradTotal = data.Costs + data.PackingCosts + data.Etc + data.TaxValue; var shiperTlp = string.Concat("Tlp/Hp. ", item.Shiper.Phone1, "/", item.Shiper.Phone2, "/", item.Shiper.Handphone); var recieverTlp = string.Concat("Tlp/Hp. ", item.Reciver.Phone1, "/", item.Reciver.Phone2, "/", item.Reciver.Handphone); data.Shiper = string.Concat(item.Shiper.Name, Environment.NewLine, item.Shiper.Address, Environment.NewLine, shiperTlp); var ShiperCity = MainVM.CityCollection.Source.Where(O => O.Id == item.Shiper.CityID).FirstOrDefault(); data.OriginPortCode = ShiperCity.CityCode; data.ShiperCity = ShiperCity.CityName; var ReciverCity = MainVM.CityCollection.Source.Where(O => O.Id == item.Reciver.CityID).FirstOrDefault(); data.DestinationPortCode = ReciverCity.CityCode; data.ReciverCity = ReciverCity.CityName; data.Reciver = string.Concat(item.Reciver.Name, Environment.NewLine, item.Reciver.Address, Environment.NewLine, recieverTlp); data.STTQRCode = Helper.GenerateQRCodeBitmap(item.STT.ToString(), 20); list.Add(data); return(list); }
public ActionResult Edit([Bind(Include = "intSalesOrderId,intCustomerId,intProductId,dtSalesOrder,intQty")] Penjualan penjualan) { if (ModelState.IsValid) { db.Entry(penjualan).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.intCustomerId = new SelectList(db.Customer, "intCustomerId", "txtCustomerName", penjualan.intCustomerId); ViewBag.intProductId = new SelectList(db.Produk, "intProductId", "txtProductCode", penjualan.intProductId); return(View(penjualan)); }
public void Post(Penjualan penjualan) { var penjualanDetails = penjualan.PenjualanDetails; foreach (var detail in penjualanDetails) { var shu = shuRepository.FindByBarangIdAndUkuran(detail.BarangId, detail.Ukuran); shu.Stock = shu.Stock - detail.Jumlah; shuRepository.Put(shu); } penjualanRepository.Post(penjualan); }
public PenjualanViewModel() { DataBarang = new ObservableCollection <Barang>(dbo.Barangs.ToList()); datapenjualan = new ObservableCollection <Penjualan>(); modelpenjualan = new Penjualan(); CreateCommand = new Command(async() => await CreatePenjualanAsync()); UpdateCommand = new Command(async() => await UpdatePenjualanAsync()); DeleteCommand = new Command(async() => await DeletePenjualanAsync()); ReadCommand = new Command(async() => await ReadPenjualanAsync()); ReadCommand.Execute(null); }
public void AddPenjualan(DateTime date, double nominal) { var newSales = new Penjualan(date, nominal); bool checktgl = _itemsPenjualan.Where(x => x.Tanggal == date).Count() == 0 ? true : false; if (checktgl) { this._itemsPenjualan.Add(newSales); } else { throw new DateAlreadyExistException(); } Calculate(); }
// GET: Penjualan/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Penjualan penjualan = db.Penjualan.Find(id); if (penjualan == null) { return(HttpNotFound()); } return(View(penjualan)); }
private void NewAction(object obj) { try { Selected = new Penjualan(); Selected.NomorFaktur = context.GetNewFaktur(); Selected.Tanggal = DateTime.Now; Selected.JatuhTempo = DateTime.Now.AddMonths(1); Selected.User = AppState.UserLogin; SelectedItem = null; } catch (Exception ex) { Message.Error(ex.Message); } }
// GET: Penjualan/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Penjualan penjualan = db.Penjualan.Find(id); if (penjualan == null) { return(HttpNotFound()); } ViewBag.intCustomerId = new SelectList(db.Customer, "intCustomerId", "txtCustomerName", penjualan.intCustomerId); ViewBag.intProductId = new SelectList(db.Produk, "intProductId", "txtProductCode", penjualan.intProductId); return(View(penjualan)); }
public static void PrintPreviewNotaAction(Penjualan obj) { var list = CreateReportModel(obj); var helperPrint = new HelperPrint(); var content = new Reports.Contents.ReportContent(helperPrint.CreateNotaDataSource(list), "TrireksaApp.Reports.Layouts.NotaComplete.rdlc", null); var dlg = new ModernWindow { Content = content, Title = "Nota", Style = (Style)App.Current.Resources["BlankWindow"], ResizeMode = System.Windows.ResizeMode.CanResizeWithGrip, WindowState = WindowState.Maximized, }; dlg.ShowDialog(); }
private void btnSimpan_Click(object sender, EventArgs e) { DataGridView data = this.ParentForm.dataGridViewTransaksiPenjualan; int row = data.Rows.Count; Penjualan penjualan = new Penjualan(); PenjualanDetail pDetail; for (int i = 0; i < row - 1; i++) { var kodeBarang = int.Parse(data.Rows[i].Cells[0].Value.ToString()); var namaBarang = data.Rows[i].Cells[1].Value.ToString(); var jumlahJual = int.Parse(data.Rows[i].Cells[2].Value.ToString()); var hargaJual = decimal.Parse(data.Rows[i].Cells[3].Value.ToString(), NumberStyles.Number, CultureInfo.GetCultureInfo("de")); var diskon = float.Parse(data.Rows[i].Cells[4].Value.ToString(), NumberStyles.Number, CultureInfo.GetCultureInfo("de")); var subtotal = decimal.Parse(data.Rows[i].Cells[5].Value.ToString(), NumberStyles.Number, CultureInfo.GetCultureInfo("de")); pDetail = new PenjualanDetail() { Penjualan = penjualan, BarangId = kodeBarang, Harga = hargaJual, Jumlah = jumlahJual, SubTotal = subtotal, Diskon = diskon }; penjualan.PenjualanDetails.Add(pDetail); } penjualan.KodeTransaksi = this.ParentForm.textBoxKodeTransaksi.Text; penjualan.Tanggal = DateTime.Now; penjualan.TotalHargaJual = decimal.Parse(labelTotal.Text, NumberStyles.Number, CultureInfo.GetCultureInfo("de")); var pengguna = LoginContext.Pengguna; var pelanggan = pelangganService.Get(int.Parse(this.ParentForm.textBoxKodePelanggan.Text)); penjualan.PenggunaId = pengguna.Id; penjualan.PelangganId = pelanggan.Id; penjualanService.Post(penjualan); this.Dispose(); this.ParentForm.Clear(); }
private void frmLihatTransaksi_Shown(object sender, EventArgs e) { mtcDaftarTransaksi.SelectTab(0); dgvPembelian.DataSource = Pembelian.FindAll(); dgvPembelian.Refresh(); dgvPembelianDetail.DataSource = PembelianDetail.FindAll(); dgvPembelianDetail.Refresh(); dgvPenjualan.DataSource = Penjualan.FindAll(); dgvPenjualan.Refresh(); dgvPenjualanDetail.DataSource = PenjualanDetail.FindAll(); dgvPenjualanDetail.Refresh(); dtPembelian = (DataTable)dgvPembelian.DataSource; dtPembelianDetail = (DataTable)dgvPembelianDetail.DataSource; dtPenjualan = (DataTable)dgvPenjualan.DataSource; dtPenjualanDetail = (DataTable)dgvPenjualanDetail.DataSource; }
private async Task CreatePenjualanAsync() { try { dbo.Penjualans.Add(ModelPenjualan); dbo.SaveChanges(); MessageBox.Show("Berhasil menambahkan data"); ModelPenjualan = new Penjualan(); OnReload?.Invoke(); } catch (Exception ex) { MessageBox.Show("Gagal menambahkan data"); } finally { await ReadPenjualanAsync(); } }
public ActionResult Create(Penjualan penjualann) { try { using (DbModels dbModel = new DbModels()) { penjualann.dtSalesOrder = DateTime.Now; dbModel.Penjualans.Add(penjualann); dbModel.SaveChanges(); } // TODO: Add insert logic here return(RedirectToAction("Index")); } catch { return(View()); } }
public async Task <Penjualan> InsertAndGetItem(Penjualan value) { var date = DateTime.Now; value.ChangeDate = date; value.UpdateDate = date; if (value.Colly != null && value.Colly.Count > 0) { try { if (value.Stt == 0) { value.Stt = await NewSTT(); } db.Set <Penjualan>().Add(value); if (value.FromCityNavigation != null) { db.Entry(value.FromCityNavigation).State = EntityState.Unchanged; } if (value.ToCityNavigation != null) { db.Entry(value.ToCityNavigation).State = EntityState.Unchanged; } db.Entry(value.Shiper).State = EntityState.Unchanged; db.Entry(value.Reciver).State = EntityState.Unchanged; if (await db.SaveChangesAsync() <= 0) { throw new SystemException(MessageCollection.Message(MessageType.SaveFail)); } } catch (Exception ex) { throw new SystemException(ex.Message); } } else { throw new SystemException("Item Barang Belum ada"); } return(value); }
internal bool Delete(Penjualan selected) { try { var saved = true; if (saved) { var existData = Source.Where(x => x.PenjualanId == selected.PenjualanId).FirstOrDefault(); if (existData != null) { Source.Remove(selected); } return(true); } throw new SystemException("Data Tidak Terhapus"); } catch (Exception ex) { throw new SystemException(ex.Message); } }
public frmPenjualan() { InitializeComponent(); Penjualan Penjualan = new Penjualan(); penjualanBindingSource.DataSource = Penjualan; itemPenjualanBindingSource.DataSource = Penjualan.ItemPenjualan; pelangganBindingSource.DataSource = BaseFramework.DefaultDataPersistance .FastLoadEntities <Pelanggan>( "NoPelanggan,NamaPelanggan", "Aktif=true", "NoPelanggan"); itemBindingSource.DataSource = BaseFramework.DefaultDataPersistance .FastLoadEntities <Item>("KodeItem,NamaItem", "Aktif=true", "KodeItem"); }
public Task <Penjualan> CreatePenjualan(int orderid, Penjualan model) { var trans = dbContext.Database.BeginTransaction(); try { dbContext.ChangeTracker.Clear(); dbContext.Entry(model.Customer).State = EntityState.Unchanged; dbContext.Entry(model.Gudang).State = EntityState.Unchanged; dbContext.Entry(model.Salesman).State = EntityState.Unchanged; var tracker = dbContext.ChangeTracker.Entries(); foreach (var item in model.Items) { dbContext.Entry(item.Product).State = EntityState.Unchanged; dbContext.Entry(item.Unit).State = EntityState.Unchanged; } if (model.OrderPenjualan != null) { dbContext.Entry(model.OrderPenjualan).State = EntityState.Modified; model.OrderPenjualan.Status = OrderStatus.Diproses; } dbContext.ChangeTracker.DisplayTrackedEntities(); dbContext.Penjualan.Add(model); dbContext.SaveChanges(); trans.Commit(); return(Task.FromResult(model)); } catch (Exception ex) { trans.Rollback(); throw new SystemException(ex.Message); } }
public Task <Penjualan> UpdatePenjualan(int penjualanId, Penjualan order) { throw new NotImplementedException(); }
public Task <Penjualan> UpdatePenjualan(int penjualanId, Penjualan order) { //dbContext.ChangeTracker.Clear(); var trans = dbContext.Database.BeginTransaction(); try { var lastPenjualan = dbContext.Penjualan.AsNoTracking().Where(x => x.Id == penjualanId).Include(x => x.Items) .FirstOrDefault(); if (lastPenjualan == null) { throw new SystemException("Penjualan Not Found !"); } order.Activity = order.Activity == ActivityStatus.None ? ActivityStatus.Created :order.Activity; //order.OrderPenjualan.Status = OrderStatus.Diproses; dbContext.Entry(lastPenjualan).CurrentValues.SetValues(order); foreach (var item in order.Items) { if (item.Id <= 0) { if (item.Product != null) { dbContext.Entry(item.Product).State = EntityState.Unchanged; dbContext.Entry(item.Product.UnitSelected).State = EntityState.Unchanged; } dbContext.Penjualanitem.Add(item); } else { var oldItem = lastPenjualan.Items.SingleOrDefault(x => x.Id == item.Id); if (item.Unit != oldItem.Unit || item.Discount != oldItem.Discount || item.Price != oldItem.Price || item.Quantity != oldItem.Quantity ) { oldItem.Unit = item.Unit; oldItem.Discount = item.Discount; oldItem.Price = item.Price; oldItem.Quantity = item.Quantity; } } } //remove foreach (var item in lastPenjualan.Items) { var existsDb = order.Items.Where(x => x.Id == item.Id).FirstOrDefault(); if (existsDb == null) { lastPenjualan.Items.Remove(item); } } dbContext.SaveChanges(); trans.Commit(); return(Task.FromResult(order)); } catch (Exception ex) { trans.Rollback(); throw new SystemException(ex.Message); } }
internal bool Save(Penjualan selected) { using (var db = new OcphDbContext()) { var trans = db.BeginTransaction(); try { var penjualanDTO = Mapper.Map <PenjualanDto>(selected); penjualanDTO.UserId = AppState.UserLogin.UserId; if (penjualanDTO.Customer.CustomerId == null) { var custId = db.Customers.InsertAndGetLastID(new CustomerDto { KodeCustomer = null, NamaCustomer = null, Status = CustomerStatus.None, NoTelepon = "", Alamat = penjualanDTO.Customer.Alamat }); if (custId <= 0) { throw new SystemException("Data Tidak Tersimpan"); } penjualanDTO.CustomerId = custId; } else { penjualanDTO.CustomerId = selected.Customer.CustomerId; } if (selected.PenjualanId == null) { var Id = db.Penjualans.InsertAndGetLastID(penjualanDTO); if (Id > 0) { penjualanDTO.PenjualanId = Id; foreach (var item in selected.Details) { item.PenjualanId = Id; var itemPenjualan = Mapper.Map <ItemPenjualanDto>(item); var detailSaved = db.DetailPenjualan.Insert(itemPenjualan); if (detailSaved) { db.Barangs.MinStock(item, item.Jumlah); } } Source.Add(selected); trans.Commit(); return(true); } } else { var saved = true; if (saved) { var existData = Source.Where(x => x.PenjualanId == selected.PenjualanId).FirstOrDefault(); if (existData != null) { existData = Mapper.Map <Penjualan>(selected); } return(true); } } throw new SystemException("Data Tidak Tersimpan"); } catch (Exception ex) { trans.Rollback(); if (ex.Message == "Data Duplikat") { throw new SystemException($"Nomor Faktur {selected.NomorFaktur} Sudah Ada"); } else { throw new SystemException(ex.Message); } } } }