private void btn4_Click(object sender, RoutedEventArgs e) { Service2Client x = new Service2Client(); tblStock stk = new tblStock { stockId = Convert.ToInt32(txt1.Text), stockName = txt2.Text, quantity = Convert.ToInt32(txt3.Text), quantity_remaining = Convert.ToInt32(txt3.Text), addedBy = 1, status = txt4.Text }; if (!x.updateStockById(stk)) { stat.Content = "invalid id"; } else { stat.Content = "data updated"; } txt2.Text = ""; txt3.Text = ""; txt4.Text = ""; }
private void TxtQuantity_TextChanged(object sender, EventArgs e) { if (txtQuantity.Text.Length > 0) { int productid = Convert.ToInt32(cboProductName.SelectedValue.ToString()); tblStock tb = db.tblStocks.Where(p => p.ProductId == productid).FirstOrDefault(); int quantity = Convert.ToInt32(txtQuantity.Text); if (tb.Quantity > quantity) { if (txtUnitPrice.Text.Length > 0) { decimal rate = Convert.ToDecimal(0.15); txtTotal.Text = (Convert.ToInt32(txtQuantity.Text) * Convert.ToDecimal(txtUnitPrice.Text)).ToString(); } else { MessageBox.Show("Please Select Product"); cboProductName.Select(); txtQuantity.Text = ""; } } else { MessageBox.Show("You Have Quantity #" + tb.Quantity + " " + " In Your Stock"); } } else { txtTotal.Text = ""; } }
private void btn2_Click(object sender, RoutedEventArgs e) { Service2Client x = new Service2Client(); tblStock stk1 = x.getStockRowbyId(Convert.ToInt32(txt1.Text)); tblStock stk = new tblStock { stockId = Convert.ToInt32(txt1.Text), stockName = txt2.Text, quantity = Convert.ToInt32(txt3.Text), quantity_remaining = Convert.ToInt32(txt3.Text), addedBy = 1, status = txt4.Text }; if (stk1.stockName == null) { x.setStock(stk); stat.Content = "stock has been added"; } else { stat.Content = "stockID already exists"; } txt2.Text = ""; txt3.Text = ""; txt4.Text = ""; }
void Sil() { Liste.AllowUserToAddRows = false; try { for (int i = 0; i < Liste.RowCount; i++) { int pid = int.Parse(Liste.Rows[i].Cells[0].Value.ToString()); string lot = Liste.Rows[i].Cells[2].Value.ToString(); tblStock st = _db.tblStocks.First(x => x.ProductID == pid && x.LotSerial == lot); st.Quantity -= int.Parse(Liste.Rows[i].Cells[4].Value.ToString()); _db.SubmitChanges(); } var srg = (from s in _db.tblPurchasings where s.PurNo == int.Parse(txtAlisNo.Text) select s).ToList(); _db.tblPurchasings.DeleteAllOnSubmit(srg); _db.SubmitChanges(); _m.YeniKayit("Kayıt başarıyla silindi."); Temizle(); } catch (Exception e) { _m.Hata(e); } }
public ActionResult DeleteConfirmed(int id) { tblStock tblStock = db.tblStocks.Find(id); db.tblStocks.Remove(tblStock); db.SaveChanges(); return(RedirectToAction("Index")); }
public tblStock addslinstock(int slid) { var add = new tblStock() { SLId = slid, AvailableStock = 0, }; return(add); }
protected void btnRegistrar_Click(object sender, EventArgs e) { var almacen = ddlAlmacen.SelectedItem.Value; var producto = ddlProducto.SelectedItem.Value; var movimiento = ddlMovimiento.SelectedItem.Value; DateTime fechact = DateTime.Now; ControllerAlmacen ctrlAlm = new ControllerAlmacen(); CultureInfo culture = new CultureInfo("en-US"); var cantidadExistente = (from existe in contexto.tblStock where existe.fkProducto == Int32.Parse(producto) select existe); var actualizar = 1; foreach (tblStock ord in cantidadExistente) { actualizar += 1; var suma = decimal.Parse(txtCantidad.Text, culture) + ord.dblCantidad; tblMovimiento mov = new tblMovimiento(); mov.strTipo = movimiento; mov.fecha = fechact; mov.dblValAnt = ord.dblCantidad; mov.dblValNvo = suma; mov.fkStock = ord.idStock; mov.fkEmpleado = Int32.Parse(lbEmpleado.Text); ord.dblCantidad = suma; ctrlAlm.InsertarMovimientoAlmacen(mov); contexto.SubmitChanges(); this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "exito()", true); this.LimpiarCampos(); } if (actualizar == 1) { tblStock stock = new tblStock(); stock.dblCantidad = decimal.Parse(txtCantidad.Text, culture); stock.fkProducto = Int32.Parse(producto); ctrlAlm.InsertarEntradaAlmacen(stock); tblMovimiento mov = new tblMovimiento(); mov.strTipo = movimiento; mov.fecha = fechact; mov.dblValAnt = 0; mov.dblValNvo = Int32.Parse(txtCantidad.Text); mov.fkStock = stock.idStock; mov.fkEmpleado = Int32.Parse(lbEmpleado.Text); ctrlAlm.InsertarMovimientoAlmacen(mov); this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "exito()", true); this.LimpiarCampos(); } }
public ActionResult Edit([Bind(Include = "stockId,stockName,quantity,quantity_remaining,addedBy,status")] tblStock tblStock) { if (ModelState.IsValid) { db.Entry(tblStock).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.addedBy = new SelectList(db.tblUsers, "uid", "fname", tblStock.addedBy); return(View(tblStock)); }
void YeniKaydet() { Liste.AllowUserToAddRows = false; try { tblSalesDown[] sud = new tblSalesDown[Liste.RowCount]; tblSalesUp sup = new tblSalesUp(); for (int i = 0; i < Liste.RowCount; i++) { int pid = int.Parse(Liste.Rows[i].Cells[0].Value.ToString()); string lot = Liste.Rows[i].Cells[2].Value.ToString(); sud[i] = new tblSalesDown(); sud[i].SalesID = int.Parse(txtSatisNo.Text); sud[i].ProductID = pid; sud[i].LotSerial = lot; sud[i].SalesPrice = decimal.Parse(Liste.Rows[i].Cells[4].Value.ToString()); sud[i].Quantity = int.Parse(Liste.Rows[i].Cells[5].Value.ToString()); sup.SalesID = int.Parse(txtSatisNo.Text); sup.CompanyID = _db.tblCompanies.First(x => x.Name == txtFirma.Text).ID; sup.Date = DateTime.Parse(dtpTarih.Text); sup.CityID = _db.tblCities.First(x => x.City == cbSehir.Text).Id; sup.EmployeeID = _db.tblEmployees.First(x => x.Name == txtPer.Text).ID; sup.ShipperID = _db.tblShippers.First(x => x.Name == txtKargo.Text).ID; AccountingDBDataContext _gb = new AccountingDBDataContext(); tblStock st = _gb.tblStocks.First(x => x.ProductID == pid && x.LotSerial == lot); if (st.Quantity.Value - int.Parse(Liste.Rows[i].Cells[5].Value.ToString()) > 0) { st.Quantity -= int.Parse(Liste.Rows[i].Cells[5].Value.ToString()); _gb.SubmitChanges(); _db.tblSalesDowns.InsertOnSubmit(sud[i]); _db.tblSalesUps.InsertOnSubmit(sup); } else { MessageBox.Show("Elimizde Yeterli Ürün Yok!"); } } _db.SubmitChanges(); _m.YeniKayit("Kayıt başarılı."); } catch (Exception e) { _m.Hata(e); } }
void YeniKaydet() { Liste.AllowUserToAddRows = false; try { tblPurchasing[] pur = new tblPurchasing[Liste.RowCount]; tblStock[] stk = new tblStock[Liste.RowCount]; for (int i = 0; i < Liste.RowCount; i++) { int pid = int.Parse(Liste.Rows[i].Cells[0].Value.ToString()); string lot = Liste.Rows[i].Cells[2].Value.ToString(); pur[i] = new tblPurchasing(); pur[i].PurNo = int.Parse(txtAlisNo.Text); //pur[i].PurNo = int.Parse(Liste.Rows[i].Cells[5].Value.ToString()); pur[i].CompanyID = _db.tblCompanies.First(x => x.Name == txtFirma.Text).ID; pur[i].ProductID = int.Parse(Liste.Rows[i].Cells[0].Value.ToString()); pur[i].LotSerial = Liste.Rows[i].Cells[2].Value.ToString(); pur[i].Date = DateTime.Parse(dtpTarih.Text); pur[i].PurchasingPrice = decimal.Parse(Liste.Rows[i].Cells[3].Value.ToString()); pur[i].Quantity = int.Parse(Liste.Rows[i].Cells[4].Value.ToString()); pur[i].EmployeeID = _db.tblEmployees.First(x => x.Name == txtPersonel.Text).ID; _db.tblPurchasings.InsertOnSubmit(pur[i]); AccountingDBDataContext _gb = new AccountingDBDataContext(); stk[i] = new tblStock(); var srg = (from s in _gb.tblStocks where s.ProductID == int.Parse(Liste.Rows[i].Cells[0].Value.ToString()) && s.LotSerial == Liste.Rows[i].Cells[2].Value.ToString() select s).ToList(); if (srg.Count == 0) { stk[i].ProductID = int.Parse(Liste.Rows[i].Cells[0].Value.ToString()); stk[i].LotSerial = Liste.Rows[i].Cells[2].Value.ToString(); stk[i].Quantity = int.Parse(Liste.Rows[i].Cells[4].Value.ToString()); _gb.tblStocks.InsertOnSubmit(stk[i]); } else { tblStock st = _gb.tblStocks.First(x => x.ProductID == pid && x.LotSerial == lot); st.Quantity += int.Parse(Liste.Rows[i].Cells[4].Value.ToString()); } _gb.SubmitChanges(); } _db.SubmitChanges(); _m.YeniKayit("Kayıt başarılı!!"); } catch (Exception e) { _m.Hata(e); } }
public void DeleteTest() { WealthDataContext wdc = new WealthDataContext(); tblStock stocks = (from u in wdc.tblStocks where u.Ticker == "VEU" select u).FirstOrDefault(); wdc.tblStocks.DeleteOnSubmit(stocks); wdc.SubmitChanges(); tblStock stockDelete = (from u in wdc.tblStocks where u.Ticker == "VEU" select u).FirstOrDefault(); Assert.IsNull(stockDelete); }
// GET: tblStocks/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblStock tblStock = db.tblStocks.Find(id); if (tblStock == null) { return(HttpNotFound()); } return(View(tblStock)); }
public void UpdateTest() { WealthDataContext wdc = new WealthDataContext(); tblStock stocks = (from u in wdc.tblStocks where u.Ticker == "VTI" select u).FirstOrDefault(); stocks.Ticker = "VEU"; wdc.SubmitChanges(); tblStock stockUpdate = (from u in wdc.tblStocks where u.Ticker == "VEU" select u).FirstOrDefault(); Assert.IsNotNull(stockUpdate); }
private void BtnSave_Click(object sender, EventArgs e) { tblSalesInvoice tb = new tblSalesInvoice(); tb.InvoiceNo = txtInvoiceNo.Text; tb.InvoiceDate = Convert.ToDateTime(txtInvoiceDate.Text); tb.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text); tb.CustomerId = customerid; db.tblSalesInvoices.Add(tb); db.SaveChanges(); tblCustomerPayment tbvenpay = new tblCustomerPayment(); tbvenpay.CustomerId = customerid; tbvenpay.PaymentDate = Convert.ToDateTime(txtInvoiceDate.Text); tbvenpay.TotalAmount = Convert.ToDecimal(txtGrandTotal.Text); tbvenpay.PaymentAmount = Convert.ToDecimal(txtPaidAmount.Text); tbvenpay.RemainingAmount = Convert.ToDecimal(txtRemainingAmount.Text); tbvenpay.PaymentMode = rbdCash.Checked ? "Cash" : "Cheque"; db.tblCustomerPayments.Add(tbvenpay); if (db.SaveChanges() > 0) { foreach (DataGridViewRow dr in dataGridView1.Rows) { tblSale pur = new tblSale(); pur.SalesInvoiceId = tb.SalesInvoiceId; pur.ProductId = Convert.ToInt32(dr.Cells["colProductId"].Value); pur.Quantity = Convert.ToInt32(dr.Cells["colQuantity"].Value); pur.UnitPrice = Convert.ToDecimal(dr.Cells["colUnitPrice"].Value); pur.Total = Convert.ToDecimal(dr.Cells["colTotal"].Value); pur.SalesDate = Convert.ToDateTime(txtInvoiceDate.Text); pur.Tax = Convert.ToDecimal(dr.Cells["colTax"].Value); db.tblSales.Add(pur); if (db.SaveChanges() > 0) { tblStock tbst = db.tblStocks.Where(p => p.ProductId == pur.ProductId).FirstOrDefault(); if (tbst != null) { int puranoquantity = Convert.ToInt32(tbst.Quantity); tbst.Quantity = puranoquantity - Convert.ToInt32(dr.Cells["colQuantity"].Value); db.SaveChanges(); } } } } MessageBox.Show("Sales Done"); }
public ActionResult Edit([Bind(Include = "StockID,ProductID,Make,Quantity,UnitID,SizeID,RatePerUnit,TaxID,Tax,TaxAmount,Discount,DiscountAmount,TotalAmount,Remark,IsActive,CreatedOn,UpdatedOn,CreatedBy,UpdatedBy,SGST,CGST")] tblStock tblStock) { if (ModelState.IsValid) { db.Entry(tblStock).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SizeID = new SelectList(db.tblSizes, "SizeID", "SizeName", tblStock.SizeID); ViewBag.TaxID = new SelectList(db.tblTaxes, "TaxID", "TaxName", tblStock.TaxID); ViewBag.UnitID = new SelectList(db.tblUnits, "UnitID", "Name", tblStock.UnitID); ViewBag.CreatedBy = new SelectList(db.tblUsers, "Id", "UserName", tblStock.CreatedBy); ViewBag.UpdatedBy = new SelectList(db.tblUsers, "Id", "UserName", tblStock.UpdatedBy); return(View(tblStock)); }
// GET: tblStocks/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblStock tblStock = db.tblStocks.Find(id); if (tblStock == null) { return(HttpNotFound()); } ViewBag.addedBy = new SelectList(db.tblUsers, "uid", "fname", tblStock.addedBy); return(View(tblStock)); }
public bool InsertarEntradaAlmacen(tblStock _TBL_Stock) { bool respuesta = false; try { contexto.tblStock.InsertOnSubmit(_TBL_Stock); contexto.SubmitChanges(); respuesta = true; } catch (Exception ex) { System.Console.WriteLine(ex.ToString()); respuesta = false; } return(respuesta); }
public void InsertTest() { WealthDataContext wdc = new WealthDataContext(); tblStock otblstock = new tblStock(); otblstock.Id = Guid.NewGuid(); otblstock.UserId = Guid.NewGuid(); otblstock.Ticker = "VTI"; wdc.tblStocks.InsertOnSubmit(otblstock); wdc.SubmitChanges(); tblStock stocks = (from u in wdc.tblStocks where u.Ticker == "VTI" select u).FirstOrDefault(); Assert.IsNotNull(stocks); }
// GET: Stocks/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblStock tblStock = db.tblStocks.Find(id); if (tblStock == null) { return(HttpNotFound()); } ViewBag.SizeID = new SelectList(db.tblSizes, "SizeID", "SizeName", tblStock.SizeID); ViewBag.TaxID = new SelectList(db.tblTaxes, "TaxID", "TaxName", tblStock.TaxID); ViewBag.UnitID = new SelectList(db.tblUnits, "UnitID", "Name", tblStock.UnitID); ViewBag.CreatedBy = new SelectList(db.tblUsers, "Id", "UserName", tblStock.CreatedBy); ViewBag.UpdatedBy = new SelectList(db.tblUsers, "Id", "UserName", tblStock.UpdatedBy); return(View(tblStock)); }
public void Delete() { try { WealthDataContext oDc = new WealthDataContext(); tblStock stock = oDc.tblStocks.FirstOrDefault(p => p.Id == this.Id); if (stock != null) { oDc.tblStocks.DeleteOnSubmit(stock); oDc.SubmitChanges(); } } catch (Exception ex) { CErrorLog err = new CErrorLog(); err.LogError(ex.Message); throw ex; } }
private void Button_Click(object sender, RoutedEventArgs e) { Service2Client x = new Service2Client(); tblStock stk = x.getStockRowbyId(Convert.ToInt32(txt1.Text)); if (stk.stockName == null) { stat.Content = "No Stock Found for this ID"; txt2.Text = ""; txt3.Text = ""; txt4.Text = ""; } else { txt2.Text = stk.stockName; txt3.Text = stk.quantity.ToString(); txt4.Text = stk.status; stat.Content = "Succes!! found record !!"; } }
public void LoadById(Guid id) { try { WealthDataContext oDc = new WealthDataContext(); tblStock stock = oDc.tblStocks.FirstOrDefault(p => p.Id == id); if (stock != null) { this.Id = id; this.Ticker = stock.Ticker; this.Price = GetPrice(this.Ticker); //this.UserId = stock.UserId; } } catch (Exception ex) { CErrorLog err = new CErrorLog(); err.LogError(ex.Message); throw ex; } }
public void Insert() { WealthDataContext oDc = new WealthDataContext(); try { var results = (from s in oDc.tblStocks join u in oDc.tblUsers on s.UserId equals u.Id where u.Id == CLogin.UserLoggedIn & s.Id == this.Id select new { s.Id, custId = s.UserId, s.Ticker, s.CurrentPricePerShare, }).FirstOrDefault(); if (results == null) { tblStock stock = new tblStock(); stock.Id = Guid.NewGuid(); stock.UserId = CLogin.UserLoggedIn; stock.Ticker = this.Ticker.ToUpper(); stock.CurrentPricePerShare = GetPrice(this.Ticker); oDc.tblStocks.InsertOnSubmit(stock); oDc.SubmitChanges(); } } catch (Exception ex) { CErrorLog err = new CErrorLog(); err.LogError(ex.Message); throw ex; } }
public JsonStock(tblStock other) { // copy values here }
private void BtnSave_Click(object sender, EventArgs e) { tblPurchaseInvoice tb = new tblPurchaseInvoice(); tb.InvoiceNo = txtInvoiceNo.Text; tb.InvoiceDate = Convert.ToDateTime(txtInvoiceDate.Text); tb.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text); tb.VendorId = vendorid; db.tblPurchaseInvoices.Add(tb); db.SaveChanges(); var tbv = db.tblVendorPayments.OrderByDescending(a => a.VendorPaymentId).Select(x => new { VendorId = x.VendorId, VendorName = x.tblVendor.Name, PaymentDate = x.PaymentDate, TotalAmount = x.TotalAmount, PaymentAmount = x.PaymentAmount, RemainingAmount = x.RemainingAmount }).Where(b => b.VendorId == vendorid).Take(1).FirstOrDefault(); tblVendorPayment tbvenpay = new tblVendorPayment(); if (tbv != null) { tbvenpay.VendorId = vendorid; tbvenpay.PaymentDate = Convert.ToDateTime(txtInvoiceDate.Text); tbvenpay.TotalAmount = Convert.ToDecimal(txtGrandTotal.Text) + Convert.ToDecimal(tbv.RemainingAmount); tbvenpay.PaymentAmount = Convert.ToDecimal(txtPaidAmount.Text); tbvenpay.RemainingAmount = (Convert.ToDecimal(txtGrandTotal.Text) + Convert.ToDecimal(tbv.RemainingAmount)) - Convert.ToDecimal(txtPaidAmount.Text); } else { tbvenpay.VendorId = vendorid; tbvenpay.PaymentDate = Convert.ToDateTime(txtInvoiceDate.Text); tbvenpay.TotalAmount = Convert.ToDecimal(txtGrandTotal.Text); tbvenpay.PaymentAmount = Convert.ToDecimal(txtPaidAmount.Text); tbvenpay.RemainingAmount = Convert.ToDecimal(txtRemainingAmount.Text); tbvenpay.PaymentMode = rbdCash.Checked ? "Cash" : "Cheque"; } db.tblVendorPayments.Add(tbvenpay); if (db.SaveChanges() > 0) { foreach (DataGridViewRow dr in dataGridView1.Rows) { tblPurchase pur = new tblPurchase(); pur.PurchaseInvoiceId = tb.PurchaseInvoiceId; pur.ProductId = Convert.ToInt32(dr.Cells["colProductId"].Value); pur.Quantity = Convert.ToInt32(dr.Cells["colQuantity"].Value); pur.UnitPrice = Convert.ToDecimal(dr.Cells["colUnitPrice"].Value); pur.Total = Convert.ToDecimal(dr.Cells["colTotal"].Value); pur.PurchaseDate = Convert.ToDateTime(txtInvoiceDate.Text); pur.Tax = Convert.ToDecimal(dr.Cells["colTax"].Value); db.tblPurchases.Add(pur); if (db.SaveChanges() > 0) { tblStock tbst = db.tblStocks.Where(p => p.ProductId == pur.ProductId).FirstOrDefault(); if (tbst != null) { int puranoquantity = Convert.ToInt32(tbst.Quantity); tbst.Quantity = puranoquantity + Convert.ToInt32(dr.Cells["colQuantity"].Value); db.SaveChanges(); } else { tblStock tbstock = new tblStock(); tbstock.ProductId = Convert.ToInt32(dr.Cells["colProductId"].Value); tbstock.Quantity = Convert.ToInt32(dr.Cells["colQuantity"].Value); db.tblStocks.Add(tbstock); db.SaveChanges(); } } } } MessageBox.Show("Purchase Done"); }
public void addstocksl(tblStock obj) { context.tblStocks.Add(obj); }
private void Liste_CellEndEdit(object sender, DataGridViewCellEventArgs e) { try { DataGridViewComboBoxCell comboCell = (DataGridViewComboBoxCell)Liste.CurrentRow.Cells[2]; if (e.ColumnIndex == 1) { Liste.CurrentRow.Cells[0].Value = _db.tblProducts.First(x => x.Name == Liste.CurrentRow.Cells[1].Value.ToString()).ID; var lts = (from s in _db.tblStocks where s.ProductID == int.Parse(Liste.CurrentRow.Cells[0].Value.ToString()) && s.Quantity > 0 select s).ToList(); //Liste.CurrentRow.Cells[1].ReadOnly = true; int a = lts.Count; comboCell.Items.Clear(); if (lts.Count > 0) { int d = 0; foreach (var k in lts) { bool lt = true; #region AYNI ÜRÜN İÇİN KULLANILAN LOT/SERİNOYU İKİNCİ DEFA GETİRMEMESİ İÇİN KONTROL int c = lts.Count; if (d != 0) { c = d; } for (int i = 0; i < Liste.RowCount; i++) { if (Liste.Rows[i].Cells[2].Value != null && k.LotSerial + "-" + k.Quantity == Liste.Rows[i].Cells[2].Value.ToString()) { lt = false; c -= 1; d = c; } } #endregion if (lt) { comboCell.Items.Add(k.LotSerial + "-" + k.Quantity); } else if (c == 0) { comboCell.Items.Add("geçerli lot yok"); comboCell.Value = "geçerli lot yok"; } } } else { MessageBox.Show("ürün yok"); Liste.CurrentRow.Cells[1].ReadOnly = false; comboCell.Items.Clear(); } } if (e.ColumnIndex == 2) { Liste.CurrentRow.Cells[5].Value = (Liste.CurrentRow.Cells[1].Value + "/" + Liste.CurrentRow.Cells[2].Value).ToUpper(); string a = Liste.CurrentRow.Cells[5].Value.ToString(); for (int i = 0; i < Liste.RowCount - 1; i++) { int b = Liste.CurrentCell.RowIndex; if (Liste.Rows[i].Cells[5].Value.ToString() == a && i != b) { MessageBox.Show("Bu kayıt var, kontrol edin."); comboCell.Value = ""; Liste.Rows[b].Cells[5].Value = ""; break; } } } if (e.ColumnIndex == 3) { try { tblStock lt = _db.tblStocks.First(x => x.ProductID == int.Parse(Liste.CurrentRow.Cells[0].Value.ToString()) && (x.LotSerial + "-" + x.Quantity) == comboCell.Value.ToString()); if (Liste.CurrentRow.Cells[3].Value.ToString() != "" && lt.Quantity < int.Parse(Liste.CurrentRow.Cells[3].Value.ToString())) { Liste.CurrentRow.Cells[3].Value = ""; MessageBox.Show(Liste.CurrentRow.Cells[1].Value.ToString() + " " + lt.LotSerial + " lot numaralı ürün stokta yeteri kadar yoktur.", "Stok Hatası", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception) { MessageBox.Show("Adet alanına geçerli değer giriniz"); Liste.CurrentRow.Cells[3].Value = ""; } } if (e.ColumnIndex == 4) { bool kon = true; if (Liste.RowCount < Liste.CurrentCell.RowIndex + 2) { Liste.Rows.Add(); Liste.Rows[Liste.CurrentCell.RowIndex + 1].ReadOnly = false; } Liste.Rows[Liste.CurrentCell.RowIndex + 1].ReadOnly = false; Liste.CurrentRow.ReadOnly = true; for (int i = 0; i < Liste.ColumnCount; i++) { if (Liste.CurrentRow.Cells[i].Value != null) { if (Liste.CurrentRow.Cells[i].Value.ToString() == "") { kon = false; MessageBox.Show(Liste.Columns[i].HeaderText + "Alanı Boş bırakılamaz"); Liste.CurrentCell.Value = ""; Liste.Rows[Liste.CurrentCell.RowIndex + 1].ReadOnly = true; Liste.CurrentRow.ReadOnly = false; } } if (kon && Liste.CurrentRow.Cells[i].Value == null /* && Liste.Rows[i].Cells[1].Value !=null*/) { MessageBox.Show(Liste.Columns[i].HeaderText + "Alanı Boş bırakılamaz"); Liste.CurrentCell.Value = ""; Liste.Rows[Liste.CurrentCell.RowIndex + 1].ReadOnly = true; Liste.CurrentRow.ReadOnly = false; break; } } } } catch (Exception ex) { _m.Hata(ex); } }
private void YeniKaydet() { Liste.AllowUserToAddRows = false; bool kon = true; try { tblSalesDown[] saled = new tblSalesDown[Liste.RowCount]; tblSalesUp saleu = new tblSalesUp(); tblStock[] stk = new tblStock[Liste.RowCount]; AccountingDBDataContext _gb = new AccountingDBDataContext(); AccountingDBDataContext _eb = new AccountingDBDataContext(); for (int i = 0; i < Liste.RowCount - 1; i++) { for (int a = 0; a < Liste.ColumnCount - 1; a++) { var d = Liste.Rows[i].Cells[a].Value; if (d == null) { MessageBox.Show("Alan boş bırakılamaz" + (i + 1) + ".satır " + a + ". sütunu kontrol edin"); kon = false; break; } } } //HÜCRE BOŞ BIRAKILAMAZ if (kon && txtFirma.Text != "" && txtPersonel.Text != "" && cbKargo.Text != "") //BOŞ ALAN BIRAKILMIŞSA KAYIT YAPILMASINI ÖNLEMEK İÇİN KULLANILAN İF { #region SALESUP TABLOSUNA YAPILACAK KAYIT saleu.SalesID = int.Parse(txtSatisNo.Text); saleu.EmployeeID = _eb.tblEmployees.First(x => x.Name == txtPersonel.Text).ID; saleu.CompanyID = _eb.tblCompanies.First(x => x.Name == txtFirma.Text).ID; saleu.Date = DateTime.Parse(dtpTarih.Text); saleu.CityID = cbSehir.SelectedIndex + 1; saleu.ShipperID = _eb.tblShippers.First(x => x.Name == cbKargo.Text).ID; _eb.tblSalesUps.InsertOnSubmit(saleu); #endregion for (int i = 0; i < Liste.RowCount; i++)//SALES DOWNA YAPILACAK OLAN KAYIT VE STOCK TABLOSUNDAKİ DEĞİŞTİRİLECEK QUANTİTY { if (Liste.Rows[i].Cells[1].Value != null) { int pid = int.Parse(Liste.Rows[i].Cells[0].Value.ToString()); string[] lotseri = Liste.Rows[i].Cells[2].Value.ToString().Split('-'); Array.Resize(ref lotseri, lotseri.Length - 1); string lot = string.Join("-", lotseri); saled[i] = new tblSalesDown(); saled[i].SalesID = int.Parse(txtSatisNo.Text); saled[i].ProductID = pid; saled[i].LotSerial = lot; saled[i].SalesPrice = decimal.Parse(Liste.Rows[i].Cells[4].Value.ToString()); saled[i].Quantity = int.Parse(Liste.Rows[i].Cells[3].Value.ToString()); #region SATIŞ YAPILAN ÜRÜNÜN STOCK TABLSOUNDAKİ ADET SAYISININ AZALTILMASI stk[i] = new tblStock(); var srg = (from s in _gb.tblStocks where s.ProductID == pid && s.LotSerial == lot select s ).ToList(); if (srg.Count > 0 && _db.tblStocks.First(x => x.ProductID == pid && x.LotSerial == lot).Quantity >= int.Parse(Liste.Rows[i].Cells[3].Value.ToString())) { tblStock st = _gb.tblStocks.First(x => x.ProductID == pid && x.LotSerial == lot); st.Quantity -= int.Parse(Liste.Rows[i].Cells[3].Value.ToString()); _db.tblSalesDowns.InsertOnSubmit(saled[i]); //_gb.tblStocks.InsertOnSubmit(stk[i]); //bu çalışırsa tblstock içine yeni bi null dolu kayıt ekliyor. kont = true; } else { MessageBox.Show(Liste.Rows[i].Cells[5].Value.ToString() + "ürün stokta yeteri kadar yoktur.", "Stok Hatası", MessageBoxButtons.OK, MessageBoxIcon.Warning); } #endregion } } if (kont) //SATIŞ YAPIALCAK ÜRÜNÜN SAYISI ELİMİZDEKİ ÜRÜNDEN FAZLAYSA DEĞİŞİKLERİ GERÇEKLEŞTİR { _gb.SubmitChanges(); _eb.SubmitChanges(); _db.SubmitChanges(); _m.YeniKayit("Satış başarılı."); Temizle(); _f.Satis(); Close(); } } else { MessageBox.Show("Eksik bilgi girdiniz. Lütfen tüm bilgileri giriniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception e) { _m.Hata(e); } }
public EditPOModel() { Order = new PM_Order(); stock = new tblStock(); Items = new tblItem(); }