private void InsertIntoInvoiceProducts(DataTable orders) { for (int i = 0; i < orders.Rows.Count; i++) { string GiftBox = orders.Rows[i]["GiftBox"].ToString(); double giftPrice; string sqlquery = "insert into tblInvoiceProducts VALUES (@invoice, @sku, @size, @qty, @giftbox, @giftboxprice, @skuprice)"; SqlCommand com = new SqlCommand(sqlquery, DatabaseAssist.ConnectToLexlets); if (GiftBox == "Yes") { GiftBox = "Silver Box - Bracelet"; giftPrice = 4.50; } else { GiftBox = "No"; giftPrice = 0; } com.Parameters.AddWithValue("@invoice", Convert.ToInt32(orders.Rows[i]["Order"])); com.Parameters.AddWithValue("@sku", Convert.ToInt32(orders.Rows[i]["SKU"])); com.Parameters.AddWithValue("@size", orders.Rows[i]["Size"]); com.Parameters.AddWithValue("@qty", Convert.ToInt32(orders.Rows[i]["Qty"])); com.Parameters.AddWithValue("@GiftBox", GiftBox); com.Parameters.AddWithValue("@GiftBoxprice", giftPrice); com.Parameters.AddWithValue("@skuprice", Convert.ToDouble(orders.Rows[i]["ItemPrice"])); if (DatabaseAssist.ConnectToDatabase() == true) { com.ExecuteNonQuery(); DatabaseAssist.ConnectToLexlets.Close(); } DatabaseAssist.UpdateProductQtySold(Convert.ToInt32(orders.Rows[i]["SKU"]), Convert.ToInt32(orders.Rows[i]["Qty"]), "Add"); } }
private void UpdateStockFullRefund() { List <int> SkuList = new List <int>(); List <int> QtyList = new List <int>(); List <string> Gift = new List <string>(); foreach (Label Labels in pnlItems.Controls.OfType <Label>()) { if (Labels.Name.Contains("Sku")) { SkuList.Add(Convert.ToInt32(Labels.Text)); } if (Labels.Name.Contains("Gift")) { Gift.Add(Labels.Text); } } foreach (ComboBox qty in pnlItems.Controls.OfType <ComboBox>()) { if (qty.Name.Contains("Quantity")) { QtyList.Add(Convert.ToInt32(qty.SelectedItem)); } } for (int i = 0; i < SkuList.Count; i++) { DatabaseAssist.UpdateMaterialQty(SkuList[i], QtyList[i], "Add"); DatabaseAssist.UpdateProductQtySold(SkuList[i], QtyList[i], "Remove"); if (Gift[i] != "No ") { DatabaseAssist.UpdateGiftBoxes(Gift[i], QtyList[i], "Add"); } } }
private void UpdateStockPartRefund() { List <int> SkuList = new List <int>(); List <int> QtyList = new List <int>(); List <string> Gift = new List <string>(); for (int i = 0; i < dgvRefunds.Rows.Count - 1; i++) { SkuList.Add((Convert.ToInt16(dgvRefunds.Rows[i].Cells[2].Value))); QtyList.Add((Convert.ToInt16(dgvRefunds.Rows[i].Cells[6].Value))); Gift.Add(dgvRefunds.Rows[i].Cells[8].Value.ToString()); } for (int i = 0; i < SkuList.Count; i++) { DatabaseAssist.UpdateMaterialQty(SkuList[i], QtyList[i], "Add"); DatabaseAssist.UpdateProductQtySold(SkuList[i], QtyList[i], "Remove"); if (Gift[i] != "No " && chkGift.Checked == true) { DatabaseAssist.UpdateGiftBoxes(Gift[i], QtyList[i], "Add"); } } }