public bool AddDetails(SalesDetial SD) { try { string connectionString = @"Server=FARHANAMOSTO-PC; Database=SmallBusiness; Integrated Security=True"; SqlConnection sqlConnection = new SqlConnection(connectionString); string commandString = @"INSERT INTO SalesDetails (Sales_MID,CategoriesID, ProductId,Quantity,MRP,TotalMRP)Values(" + SD.Sales_MID + "," + SD.CategoriesID + "," + SD.ProductId + "," + SD.Quantity + "," + SD.MRP + "," + SD.TotalMRP + ")"; SqlCommand sqlCommand = new SqlCommand(commandString, sqlConnection); sqlConnection.Open(); int isExecuted = sqlCommand.ExecuteNonQuery(); sqlConnection.Close(); if (isExecuted > 0) { return(true); } else { return(false); } } catch { throw; } }
public void AddInfo() { try { int availqnt = Convert.ToInt16(availableQuantityTextBox.Text); availqnt = availqnt - Convert.ToInt32(quantityTextBox.Text); if (availqnt < ReorderLevel) { MessageBox.Show("Available Quantity goes below the reorder level,Item can not be added"); return; } SalesDetial SalesDetial = new SalesDetial(); SalesDetial.Sales_DID = Sales_DID++; SalesDetial.CategoriesID = Convert.ToInt32(categoryComboBox.SelectedValue); SalesDetial.ProductId = Convert.ToInt32(productComboBox.SelectedValue); SalesDetial.Quantity = Convert.ToInt32(quantityTextBox.Text); SalesDetial.MRP = float.Parse(mrpTextBox.Text); SalesDetial.TotalMRP = float.Parse(toatlMrpTextBox.Text); listSalesDetials.Add(SalesDetial); salesdDtaGridView.DataSource = null; salesdDtaGridView.DataSource = listSalesDetials; double GrandTotal = listSalesDetials.Sum(x => x.TotalMRP); grandTotalTextBox.Text = GrandTotal.ToString(); double LoyaltyPoint = Convert.ToDouble(loyalityPointTextBox.Text); double Discount = LoyaltyPoint / 10; discountTextBox.Text = Discount.ToString(); double DiscountAmount = GrandTotal * (Discount / 100); discountAmountTextBox.Text = DiscountAmount.ToString(); double PayableAmount = GrandTotal - DiscountAmount; payableAmountTextBox.Text = PayableAmount.ToString(); CustLoyaltyPoint = LoyaltyPoint - (LoyaltyPoint / 10); CustLoyaltyPoint = CustLoyaltyPoint + (GrandTotal / 1000); categoryComboBox.Text = "-Select Category Name-"; productComboBox.Text = "-Select Product Name-"; availableQuantityTextBox.Text = ""; quantityTextBox.Text = ""; mrpTextBox.Text = ""; toatlMrpTextBox.Text = ""; } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
public void UpdateInfo() { SalesDetial supdate = new SalesDetial(); supdate.Sales_DID = UpdateId; supdate.CategoriesID = int.Parse(categoryComboBox.SelectedValue.ToString()); supdate.ProductId = int.Parse(productComboBox.SelectedValue.ToString()); supdate.Quantity = Convert.ToInt16(quantityTextBox.Text); supdate.MRP = Convert.ToInt16(mrpTextBox.Text); supdate.TotalMRP = Convert.ToInt16(toatlMrpTextBox.Text); SalesDetial sdelete = new SalesDetial(); sdelete = listSalesDetials.Where(x => x.Sales_DID == UpdateId).FirstOrDefault(); listSalesDetials.Remove(sdelete); listSalesDetials.Add(supdate); salesdDtaGridView.DataSource = null; salesdDtaGridView.DataSource = listSalesDetials; AddButton.Text = "Add"; }
public bool AddDetails(SalesDetial SD) { return(_SalesMasterRepository.AddDetails(SD)); }