public bool Update(SalePriceColumns salepriceitem) { var result = false; try { string sql = string.Format("UPDATE selling_price SET price_1 = {1}, price_2 = {2}, price_3 = {3}, price_4 = {4}, price_5 = {5}, updated_by = '{6}' WHERE prodid = {0}", salepriceitem.prodid, salepriceitem.price_1, salepriceitem.price_2, salepriceitem.price_3, salepriceitem.price_4, salepriceitem.price_5, salepriceitem.created_by ); var count = dbConnection.Execute(sql, salepriceitem); result = count > 0; } catch (Exception ex) { Logger.Log(ex, true); } return(result); }
private void btsave_Click(object sender, EventArgs e) { var dataBefore = new SalePriceColumns(); dataBefore.price_1 = SalePriceData.price_1; dataBefore.price_2 = SalePriceData.price_2; dataBefore.price_3 = SalePriceData.price_3; dataBefore.price_4 = SalePriceData.price_4; dataBefore.price_5 = SalePriceData.price_5; SalePriceData.price_1 = Utils.ToNumbers(tblevel1.Text); SalePriceData.price_2 = Utils.ToNumbers(tblevel2.Text); SalePriceData.price_3 = Utils.ToNumbers(tblevel3.Text); SalePriceData.price_4 = Utils.ToNumbers(tblevel4.Text); SalePriceData.price_5 = Utils.ToNumbers(tblevel5.Text); bool havechanges = false; if (dataBefore.price_1 == SalePriceData.price_1 && dataBefore.price_2 == SalePriceData.price_2 && dataBefore.price_3 == SalePriceData.price_3 && dataBefore.price_4 == SalePriceData.price_4 && dataBefore.price_5 == SalePriceData.price_5) { havechanges = true; } if (havechanges) { MessageBox.Show("Tidak ada data yang anda ubah"); SalePriceData.price_1 = dataBefore.price_1; SalePriceData.price_2 = dataBefore.price_2; SalePriceData.price_3 = dataBefore.price_3; SalePriceData.price_4 = dataBefore.price_4; SalePriceData.price_5 = dataBefore.price_5; } else if (salePriceRepo.Update(SalePriceData)) { MessageBox.Show("Harga jual telah berhasil di ubah"); Close(); } else { MessageBox.Show("Harga jua gagal di ubah"); SalePriceData.price_1 = dataBefore.price_1; SalePriceData.price_2 = dataBefore.price_2; SalePriceData.price_3 = dataBefore.price_3; SalePriceData.price_4 = dataBefore.price_4; SalePriceData.price_5 = dataBefore.price_5; } }
private void btsellingprice_Click(object sender, EventArgs e) { if (gvproducts.SelectedRows.Count == 0) { MessageBox.Show("Anda tidak bisa lanjut ke layar berikutnya, silahkan tambah baru barang"); } else { var selectedRowId = (int)gvproducts.SelectedRows[0].Cells["id"].Value; var selectedSalePrice = salePriceRepo.GetById(selectedRowId); var selectedproduct = productRepository.GetById(selectedRowId); if (selectedSalePrice == null) { var NewSalePrice = new SalePriceColumns(); NewSalePrice.prodid = selectedRowId; NewSalePrice.created_by = userdata.username; if (salePriceRepo.Add(NewSalePrice)) { var newsaleprice = salePriceRepo.GetById(selectedRowId); if (newsaleprice != null) { var form = new ManageSalePrice(); form.userdata = userdata; form.SalePriceData = newsaleprice; form.ProductData = selectedproduct; form.ShowDialog(); } } else { MessageBox.Show("Error pada daftar harga jual"); } } else { var form = new ManageSalePrice(); form.userdata = userdata; form.SalePriceData = selectedSalePrice; form.ProductData = selectedproduct; form.ShowDialog(); } } }
public bool Add(SalePriceColumns salepriceitem) { var result = false; try { string sql = string.Format("insert into selling_price (prodid, created_by ) values ({0}, '{1}')", salepriceitem.prodid, salepriceitem.created_by ); var count = dbConnection.Execute(sql, salepriceitem); result = count > 0; } catch (Exception ex) { Logger.Log(ex, true); } return(result); }