public bool insertDummySalesDetails(DummySalesDetailsBLL ds) { bool isSuccess = false; SqlConnection con = new SqlConnection(myconnstrng); try { //inserting transaction details string sql = "INSERT INTO DummySales_Transactions_Details (Product_ID,Cust_ID,Product_Name,Unit,Qty,Rate,Dicount_Per,GST_Type,GST_Per,Total) VALUES(@Product_ID,@Cust_ID,@Product_Name,@Unit,@Qty,@Rate,@Discount_Per,@GST_Type,@GST_Per,@Total)"; SqlCommand cmd = new SqlCommand(sql, con); cmd.Parameters.AddWithValue("@Invoice_No", 1); cmd.Parameters.AddWithValue("@Product_ID", ds.Product_ID); cmd.Parameters.AddWithValue("@Cust_ID", ds.Cust_ID); cmd.Parameters.AddWithValue("@Product_Name", ds.Product_Name); cmd.Parameters.AddWithValue("@Unit", ds.Unit); cmd.Parameters.AddWithValue("@Qty", ds.Qty); cmd.Parameters.AddWithValue("@Rate", ds.Rate); cmd.Parameters.AddWithValue("@Discount_Per", ds.Discount_Per); cmd.Parameters.AddWithValue("@GST_Type", ds.GST_Type); cmd.Parameters.AddWithValue("@GST_Per", ds.GST_Per); cmd.Parameters.AddWithValue("@Total", ds.Total); //Unit,Qty,Rate,Discount_Per,GST_Type,GST_Per,Total con.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSuccess = true; } else { isSuccess = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { } return(isSuccess); }
public void save() { string sname = textCust_Name.Text; if (comboTransactionType.Text != "") { if (sname != "") { if (dgvAddedProducts.Rows.Count != 0) { customerBLL c = cDAL.getCustomerIdFromName(sname); decimal subTotal, totalDiscount, totalSgst, totalCgst, totalIgst, grandTotal; string type = comboTransactionType.Text; decimal.TryParse(textSubTotal.Text, out subTotal); decimal.TryParse(textSubDiscount.Text, out totalDiscount); decimal.TryParse(textSgst.Text, out totalSgst); decimal.TryParse(textCgst.Text, out totalCgst); decimal.TryParse(textIgst.Text, out totalIgst); decimal.TryParse(textGrandTotal.Text, out grandTotal); challanBLL.Transaction_Type = type; challanBLL.Cust_ID = c.Cust_ID; challanBLL.Sub_Total = subTotal; challanBLL.TDiscount = totalDiscount; challanBLL.TSGST = totalSgst; challanBLL.TCGST = totalCgst; challanBLL.TIGST = totalIgst; challanBLL.Grand_Total = grandTotal; challanBLL.DummySalesDetails = salesDT; bool isSuccess = false; // using (TransactionScope scope = new TransactionScope())// { int salesid = -1; bool b = challanDAL.insertDummySales(challanBLL, out salesid); for (int i = 0; i < salesDT.Rows.Count; i++) { DummySalesDetailsBLL cdBLL = new DummySalesDetailsBLL(); string productName = salesDT.Rows[i][1].ToString(); ProductMasterBLL p = ProductMasterDAL.GetProductIDFromName(productName); cdBLL.Product_ID = p.Product_ID; cdBLL.Cust_ID = c.Cust_ID; cdBLL.Product_Name = salesDT.Rows[i][1].ToString(); cdBLL.Unit = salesDT.Rows[i][2].ToString(); cdBLL.Qty = Math.Round(decimal.Parse(salesDT.Rows[i][3].ToString()), 2); cdBLL.Rate = Math.Round(decimal.Parse(salesDT.Rows[i][4].ToString()), 2); cdBLL.Discount_Per = Math.Round(decimal.Parse(salesDT.Rows[i][6].ToString()), 2); cdBLL.GST_Type = salesDT.Rows[i][7].ToString(); cdBLL.GST_Per = Math.Round(decimal.Parse(salesDT.Rows[i][8].ToString()), 2); cdBLL.Total = Math.Round(decimal.Parse(salesDT.Rows[i][9].ToString()), 2); bool y = DummySalesDetailsDAL.insertDummySalesDetails(cdBLL); isSuccess = b && y; isSuccess = true; } isSuccess = b; if (isSuccess == true) { //scope.Complete(); MessageBox.Show("Transaction Completed"); //clear(); } else { MessageBox.Show("Transaction Failed"); } } } else { MessageBox.Show("Please Add product Details"); } } else { MessageBox.Show("Please Select Customer Details"); } } else { MessageBox.Show("Please Select Purchase Type GST OR NOGST"); } }