private void grdGrid_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (type == "Buy Order") { Buy.FrmBuyOrder form = (Buy.FrmBuyOrder)Application.OpenForms["FrmBuyOrder"]; form.grdGrid.CellValueChanged -= form.grdGrid_CellValueChanged; decimal price = decimal.Parse(grdGrid.GetFocusedRowCellValue("Fiyatı").ToString()); for (int i = 0; i < form.grdGrid.RowCount - 1; i++) { if (form.grdGrid.GetRowCellValue(i, "Kart Kodu").ToString() == cardCode) { form.grdGrid.SetRowCellValue(i, "Birim Fiyat", price); } } form.Calculate(); form.grdGrid.CellValueChanged += form.grdGrid_CellValueChanged; this.Close(); } else if (type == "Sell Order") { Sell.FrmSellOrder form = (Sell.FrmSellOrder)Application.OpenForms["FrmSellOrder"]; form.grdGrid.CellValueChanged -= form.grdGrid_CellValueChanged; decimal price = decimal.Parse(grdGrid.GetFocusedRowCellValue("Fiyatı").ToString()); for (int i = 0; i < form.grdGrid.RowCount - 1; i++) { if (form.grdGrid.GetRowCellValue(i, "Kart Kodu").ToString() == cardCode) { form.grdGrid.SetRowCellValue(i, "Birim Fiyat", price); } } form.Calculate(); form.grdGrid.CellValueChanged += form.grdGrid_CellValueChanged; this.Close(); } } }
private void gridView1_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode == Keys.Space) { if (gridView1.GetFocusedRowCellValue("Seçim").ToString() == "True") { gridView1.SetFocusedRowCellValue("Seçim", false); } else { gridView1.SetFocusedRowCellValue("Seçim", true); } } else if (e.KeyCode == Keys.Enter) { string barcode = ""; string oldBarcode, state = ""; int miktar; int LastListRef; DataRow row; gridView1.Columns[2].UnGroup(); #region Plug if (gelen == "Plug") { FrmOperation form = (FrmOperation)Application.OpenForms["FrmOperation"]; for (int i = 0; i < gridView1.RowCount; i++) { if (gridView1.GetRowCellValue(i, "Seçim").ToString() == "True") { if (form.grdGrid.RowCount - 1 > 0) { for (int a = 0; a < form.grdGrid.RowCount - 1; a++) { barcode = gridView1.GetRowCellValue(i, "Barkod").ToString(); oldBarcode = form.grdGrid.GetRowCellValue(a, "Barkod").ToString(); if (barcode == oldBarcode) { miktar = int.Parse(form.grdGrid.GetRowCellValue(a, "Miktar").ToString()); miktar++; form.grdGrid.SetRowCellValue(a, "Miktar", miktar); state = "true"; break; } else { state = "false"; } } if (state == "false") { row = form.dtBox.NewRow(); row["Kart Ref"] = int.Parse(gridView1.GetRowCellValue(i, "Ref").ToString()); row["Kart Kodu"] = gridView1.GetRowCellValue(i, "Kart Kodu").ToString(); row["Kart Adı"] = gridView1.GetRowCellValue(i, "Kart Adı").ToString(); row["Renk"] = gridView1.GetRowCellValue(i, "Renk").ToString(); row["Beden"] = gridView1.GetRowCellValue(i, "Beden").ToString(); row["Barkod"] = gridView1.GetRowCellValue(i, "Barkod").ToString(); row["Birim Ref"] = gridView1.GetRowCellValue(i, "Birim Ref").ToString(); row["Birim Kodu"] = gridView1.GetRowCellValue(i, "Birim Kodu").ToString(); row["Miktar"] = 1; form.dtBox.Rows.Add(row); } } else { row = form.dtBox.NewRow(); row["Kart Ref"] = int.Parse(gridView1.GetRowCellValue(i, "Ref").ToString()); row["Kart Kodu"] = gridView1.GetRowCellValue(i, "Kart Kodu").ToString(); row["Kart Adı"] = gridView1.GetRowCellValue(i, "Kart Adı").ToString(); row["Renk"] = gridView1.GetRowCellValue(i, "Renk").ToString(); row["Beden"] = gridView1.GetRowCellValue(i, "Beden").ToString(); row["Barkod"] = gridView1.GetRowCellValue(i, "Barkod").ToString(); row["Birim Ref"] = gridView1.GetRowCellValue(i, "Birim Ref").ToString(); row["Birim Kodu"] = gridView1.GetRowCellValue(i, "Birim Kodu").ToString(); row["Miktar"] = 1; form.dtBox.Rows.Add(row); } } } } #endregion #region Sell List else if (gelen == "List") { Sell.FrmSellPrices form = (Sell.FrmSellPrices)Application.OpenForms["FrmSellPrices"]; for (int i = 0; i < gridView1.RowCount; i++) { if (gridView1.GetRowCellValue(i, "Seçim").ToString() == "True") { if (form.grdGrid.RowCount - 1 > 0) { for (int a = 0; a < form.grdGrid.RowCount - 1; a++) { barcode = gridView1.GetRowCellValue(i, "Barkod").ToString(); oldBarcode = form.grdGrid.GetRowCellValue(a, "Barkod").ToString(); if (barcode == oldBarcode) { state = "true"; break; } else { state = "false"; } } if (state == "false") { row = form.dtBox.NewRow(); row["Kart Ref"] = int.Parse(gridView1.GetRowCellValue(i, "Ref").ToString()); row["Kart Kodu"] = gridView1.GetRowCellValue(i, "Kart Kodu").ToString(); row["Kart Adı"] = gridView1.GetRowCellValue(i, "Kart Adı").ToString(); row["Renk"] = gridView1.GetRowCellValue(i, "Renk").ToString(); row["Beden"] = gridView1.GetRowCellValue(i, "Beden").ToString(); row["Barkod"] = gridView1.GetRowCellValue(i, "Barkod").ToString(); row["Birim Ref"] = gridView1.GetRowCellValue(i, "Birim Ref").ToString(); row["Birim Kodu"] = gridView1.GetRowCellValue(i, "Birim Kodu").ToString(); row["Fiyat"] = 1; form.dtBox.Rows.Add(row); } } else { row = form.dtBox.NewRow(); row["Kart Ref"] = int.Parse(gridView1.GetRowCellValue(i, "Ref").ToString()); row["Kart Kodu"] = gridView1.GetRowCellValue(i, "Kart Kodu").ToString(); row["Kart Adı"] = gridView1.GetRowCellValue(i, "Kart Adı").ToString(); row["Renk"] = gridView1.GetRowCellValue(i, "Renk").ToString(); row["Beden"] = gridView1.GetRowCellValue(i, "Beden").ToString(); row["Barkod"] = gridView1.GetRowCellValue(i, "Barkod").ToString(); row["Birim Ref"] = gridView1.GetRowCellValue(i, "Birim Ref").ToString(); row["Birim Kodu"] = gridView1.GetRowCellValue(i, "Birim Kodu").ToString(); row["Fiyat"] = 1; form.dtBox.Rows.Add(row); } } } } #endregion #region Kampanya else if (gelen == "Campaing") { Sell.FrmCampaings form = (Sell.FrmCampaings)Application.OpenForms["FrmCampaings"]; for (int i = 0; i < gridView1.RowCount; i++) { if (gridView1.GetRowCellValue(i, "Seçim").ToString() == "True") { if (form.grdGrid.RowCount - 1 > 0) { for (int a = 0; a < form.grdGrid.RowCount - 1; a++) { barcode = gridView1.GetRowCellValue(i, "Barkod").ToString(); oldBarcode = form.grdGrid.GetRowCellValue(a, "Barkod").ToString(); if (barcode == oldBarcode) { state = "true"; break; } else { state = "false"; } } if (state == "false") { row = form.dtBox.NewRow(); row["Kart Ref"] = int.Parse(gridView1.GetRowCellValue(i, "Ref").ToString()); row["Kart Kodu"] = gridView1.GetRowCellValue(i, "Kart Kodu").ToString(); row["Kart Adı"] = gridView1.GetRowCellValue(i, "Kart Adı").ToString(); row["Renk"] = gridView1.GetRowCellValue(i, "Renk").ToString(); row["Beden"] = gridView1.GetRowCellValue(i, "Beden").ToString(); row["Barkod"] = gridView1.GetRowCellValue(i, "Barkod").ToString(); form.dtBox.Rows.Add(row); } } else { row = form.dtBox.NewRow(); row["Kart Ref"] = int.Parse(gridView1.GetRowCellValue(i, "Ref").ToString()); row["Kart Kodu"] = gridView1.GetRowCellValue(i, "Kart Kodu").ToString(); row["Kart Adı"] = gridView1.GetRowCellValue(i, "Kart Adı").ToString(); row["Renk"] = gridView1.GetRowCellValue(i, "Renk").ToString(); row["Beden"] = gridView1.GetRowCellValue(i, "Beden").ToString(); row["Barkod"] = gridView1.GetRowCellValue(i, "Barkod").ToString(); form.dtBox.Rows.Add(row); } } } } #endregion #region İndirim else if (gelen == "Discount") { Sell.FrmDiscount form = (Sell.FrmDiscount)Application.OpenForms["FrmDiscount"]; for (int i = 0; i < gridView1.RowCount; i++) { if (gridView1.GetRowCellValue(i, "Seçim").ToString() == "True") { if (form.grdGrid.RowCount - 1 > 0) { for (int a = 0; a < form.grdGrid.RowCount - 1; a++) { barcode = gridView1.GetRowCellValue(i, "Barkod").ToString(); oldBarcode = form.grdGrid.GetRowCellValue(a, "Barkod").ToString(); if (barcode == oldBarcode) { state = "true"; break; } else { state = "false"; } } if (state == "false") { row = form.dtBox.NewRow(); row["İndirim Tipi"] = 400; row["Kart Ref"] = int.Parse(gridView1.GetRowCellValue(i, "Ref").ToString()); row["Kart Kodu"] = gridView1.GetRowCellValue(i, "Kart Kodu").ToString(); row["Kart Adı"] = gridView1.GetRowCellValue(i, "Kart Adı").ToString(); row["Renk"] = gridView1.GetRowCellValue(i, "Renk").ToString(); row["Beden"] = gridView1.GetRowCellValue(i, "Beden").ToString(); row["Barkod"] = gridView1.GetRowCellValue(i, "Barkod").ToString(); row["Birim Ref"] = gridView1.GetRowCellValue(i, "Birim Ref").ToString(); row["Birim Kodu"] = gridView1.GetRowCellValue(i, "Birim Kodu").ToString(); string paramBarcode = gridView1.GetRowCellValue(i, "Barkod").ToString(); db.AddParameterValue("@branchRef", branchRef); db.AddParameterValue("@barcode", paramBarcode); row["Eski Fiyat"] = decimal.Parse(db.GetScalarValue("select dbo.Tools_GetLastActiveSellPrice(@barcode,@branchRef)").ToString()); form.dtBox.Rows.Add(row); } } else { row = form.dtBox.NewRow(); row["İndirim Tipi"] = 400; row["Kart Ref"] = int.Parse(gridView1.GetRowCellValue(i, "Ref").ToString()); row["Kart Kodu"] = gridView1.GetRowCellValue(i, "Kart Kodu").ToString(); row["Kart Adı"] = gridView1.GetRowCellValue(i, "Kart Adı").ToString(); row["Renk"] = gridView1.GetRowCellValue(i, "Renk").ToString(); row["Beden"] = gridView1.GetRowCellValue(i, "Beden").ToString(); row["Barkod"] = gridView1.GetRowCellValue(i, "Barkod").ToString(); row["Birim Ref"] = gridView1.GetRowCellValue(i, "Birim Ref").ToString(); row["Birim Kodu"] = gridView1.GetRowCellValue(i, "Birim Kodu").ToString(); string paramBarcode = gridView1.GetRowCellValue(i, "Barkod").ToString(); db.AddParameterValue("@branchRef", branchRef); db.AddParameterValue("@barcode", paramBarcode); row["Eski Fiyat"] = decimal.Parse(db.GetScalarValue("select dbo.Tools_GetLastActiveSellPrice(@barcode,@branchRef)").ToString()); form.dtBox.Rows.Add(row); } } } } #endregion #region Buy List else if (gelen == "Buy") { Buy.FrmBuyList form = (Buy.FrmBuyList)Application.OpenForms["FrmBuyList"]; for (int i = 0; i < gridView1.RowCount; i++) { if (gridView1.GetRowCellValue(i, "Seçim").ToString() == "True") { if (form.grdGrid.RowCount - 1 > 0) { for (int a = 0; a < form.grdGrid.RowCount - 1; a++) { barcode = gridView1.GetRowCellValue(i, "Barkod").ToString(); oldBarcode = form.grdGrid.GetRowCellValue(a, "Barkod").ToString(); if (barcode == oldBarcode) { state = "true"; break; } else { state = "false"; } } if (state == "false") { row = form.dtBox.NewRow(); row["Kart Ref"] = int.Parse(gridView1.GetRowCellValue(i, "Ref").ToString()); row["Kart Kodu"] = gridView1.GetRowCellValue(i, "Kart Kodu").ToString(); row["Kart Adı"] = gridView1.GetRowCellValue(i, "Kart Adı").ToString(); row["Renk"] = gridView1.GetRowCellValue(i, "Renk").ToString(); row["Beden"] = gridView1.GetRowCellValue(i, "Beden").ToString(); row["Barkod"] = gridView1.GetRowCellValue(i, "Barkod").ToString(); row["Birim Ref"] = gridView1.GetRowCellValue(i, "Birim Ref").ToString(); row["Birim Kodu"] = gridView1.GetRowCellValue(i, "Birim Kodu").ToString(); row["Fiyat"] = 1; form.dtBox.Rows.Add(row); } } else { row = form.dtBox.NewRow(); row["Kart Ref"] = int.Parse(gridView1.GetRowCellValue(i, "Ref").ToString()); row["Kart Kodu"] = gridView1.GetRowCellValue(i, "Kart Kodu").ToString(); row["Kart Adı"] = gridView1.GetRowCellValue(i, "Kart Adı").ToString(); row["Renk"] = gridView1.GetRowCellValue(i, "Renk").ToString(); row["Beden"] = gridView1.GetRowCellValue(i, "Beden").ToString(); row["Barkod"] = gridView1.GetRowCellValue(i, "Barkod").ToString(); row["Birim Ref"] = gridView1.GetRowCellValue(i, "Birim Ref").ToString(); row["Birim Kodu"] = gridView1.GetRowCellValue(i, "Birim Kodu").ToString(); row["Fiyat"] = 1; form.dtBox.Rows.Add(row); } } } } #endregion #region Buy Order if (gelen == "Buy Order") { Buy.FrmBuyOrder form = (Buy.FrmBuyOrder)Application.OpenForms["FrmBuyOrder"]; for (int i = 0; i < gridView1.RowCount; i++) { if (gridView1.GetRowCellValue(i, "Seçim").ToString() == "True") { if (form.grdGrid.RowCount - 1 > 0) { for (int a = 0; a < form.grdGrid.RowCount - 1; a++) { barcode = gridView1.GetRowCellValue(i, "Barkod").ToString(); oldBarcode = form.grdGrid.GetRowCellValue(a, "Barkod").ToString(); if (barcode == oldBarcode) { miktar = int.Parse(form.grdGrid.GetRowCellValue(a, "Miktar").ToString()); miktar++; form.grdGrid.SetRowCellValue(a, "Miktar", miktar); state = "true"; break; } else { state = "false"; } } if (state == "false") { row = form.dtBox.NewRow(); row["Kart Ref"] = int.Parse(gridView1.GetRowCellValue(i, "Ref").ToString()); row["Kart Kodu"] = gridView1.GetRowCellValue(i, "Kart Kodu").ToString(); row["Kart Adı"] = gridView1.GetRowCellValue(i, "Kart Adı").ToString(); row["Renk"] = gridView1.GetRowCellValue(i, "Renk").ToString(); row["Beden"] = gridView1.GetRowCellValue(i, "Beden").ToString(); row["Barkod"] = gridView1.GetRowCellValue(i, "Barkod").ToString(); row["Birim Ref"] = gridView1.GetRowCellValue(i, "Birim Ref").ToString(); row["Birim Kodu"] = gridView1.GetRowCellValue(i, "Birim Kodu").ToString(); row["Miktar"] = 1; db.AddParameterValue("@barcode", gridView1.GetRowCellValue(i, "Barkod").ToString()); db.AddParameterValue("@branchRef", form.ledBranch.GetValue()); string price = db.GetScalarValue("select dbo.Tools_GetLastActiveBuyPrice(@barcode,@branchRef)").ToString(); row["Birim Fiyat"] = price; decimal total = 1 * decimal.Parse(price); row["Toplam Tutar"] = total; form.dtBox.Rows.Add(row); } } else { row = form.dtBox.NewRow(); row["Kart Ref"] = int.Parse(gridView1.GetRowCellValue(i, "Ref").ToString()); row["Kart Kodu"] = gridView1.GetRowCellValue(i, "Kart Kodu").ToString(); row["Kart Adı"] = gridView1.GetRowCellValue(i, "Kart Adı").ToString(); row["Renk"] = gridView1.GetRowCellValue(i, "Renk").ToString(); row["Beden"] = gridView1.GetRowCellValue(i, "Beden").ToString(); row["Barkod"] = gridView1.GetRowCellValue(i, "Barkod").ToString(); row["Birim Ref"] = gridView1.GetRowCellValue(i, "Birim Ref").ToString(); row["Birim Kodu"] = gridView1.GetRowCellValue(i, "Birim Kodu").ToString(); row["Miktar"] = 1; db.AddParameterValue("@barcode", gridView1.GetRowCellValue(i, "Barkod").ToString()); db.AddParameterValue("@branchRef", form.ledBranch.GetValue()); string price = db.GetScalarValue("select dbo.Tools_GetLastActiveBuyPrice(@barcode,@branchRef)").ToString(); row["Birim Fiyat"] = price; decimal total = 1 * decimal.Parse(price); row["Toplam Tutar"] = total; form.dtBox.Rows.Add(row); } } } form.Calculate(); } #endregion #region Sell Order if (gelen == "Sell Order") { Sell.FrmSellOrder form = (Sell.FrmSellOrder)Application.OpenForms["FrmSellOrder"]; for (int i = 0; i < gridView1.RowCount; i++) { if (gridView1.GetRowCellValue(i, "Seçim").ToString() == "True") { if (form.grdGrid.RowCount - 1 > 0) { for (int a = 0; a < form.grdGrid.RowCount - 1; a++) { barcode = gridView1.GetRowCellValue(i, "Barkod").ToString(); oldBarcode = form.grdGrid.GetRowCellValue(a, "Barkod").ToString(); if (barcode == oldBarcode) { miktar = int.Parse(form.grdGrid.GetRowCellValue(a, "Miktar").ToString()); miktar++; form.grdGrid.SetRowCellValue(a, "Miktar", miktar); state = "true"; break; } else { state = "false"; } } if (state == "false") { row = form.dtBox.NewRow(); row["Kart Ref"] = int.Parse(gridView1.GetRowCellValue(i, "Ref").ToString()); row["Kart Kodu"] = gridView1.GetRowCellValue(i, "Kart Kodu").ToString(); row["Kart Adı"] = gridView1.GetRowCellValue(i, "Kart Adı").ToString(); row["Renk"] = gridView1.GetRowCellValue(i, "Renk").ToString(); row["Beden"] = gridView1.GetRowCellValue(i, "Beden").ToString(); row["Barkod"] = gridView1.GetRowCellValue(i, "Barkod").ToString(); row["Birim Ref"] = gridView1.GetRowCellValue(i, "Birim Ref").ToString(); row["Birim Kodu"] = gridView1.GetRowCellValue(i, "Birim Kodu").ToString(); row["Miktar"] = 1; db.AddParameterValue("@barcode", gridView1.GetRowCellValue(i, "Barkod").ToString()); db.AddParameterValue("@branchRef", form.ledBranch.GetValue()); string price = db.GetScalarValue("select dbo.Tools_GetLastActiveSellPrice(@barcode,@branchRef)").ToString(); row["Birim Fiyat"] = price; decimal total = 1 * decimal.Parse(price); row["Toplam Tutar"] = total; form.dtBox.Rows.Add(row); } } else { row = form.dtBox.NewRow(); row["Kart Ref"] = int.Parse(gridView1.GetRowCellValue(i, "Ref").ToString()); row["Kart Kodu"] = gridView1.GetRowCellValue(i, "Kart Kodu").ToString(); row["Kart Adı"] = gridView1.GetRowCellValue(i, "Kart Adı").ToString(); row["Renk"] = gridView1.GetRowCellValue(i, "Renk").ToString(); row["Beden"] = gridView1.GetRowCellValue(i, "Beden").ToString(); row["Barkod"] = gridView1.GetRowCellValue(i, "Barkod").ToString(); row["Birim Ref"] = gridView1.GetRowCellValue(i, "Birim Ref").ToString(); row["Birim Kodu"] = gridView1.GetRowCellValue(i, "Birim Kodu").ToString(); row["Miktar"] = 1; db.AddParameterValue("@barcode", gridView1.GetRowCellValue(i, "Barkod").ToString()); db.AddParameterValue("@branchRef", form.ledBranch.GetValue()); string price = db.GetScalarValue("select dbo.Tools_GetLastActiveSellPrice(@barcode,@branchRef)").ToString(); row["Birim Fiyat"] = price; decimal total = 1 * decimal.Parse(price); row["Toplam Tutar"] = total; form.dtBox.Rows.Add(row); } } } form.Calculate(); } #endregion this.DialogResult = DialogResult.OK; this.Close(); } } catch (Exception ex) { helper.WriteLog(ex); } }