public void SaveCustomerPurchase() { //string www= labbbbb.Text; CustomerPurchaseBL busEmp = new CustomerPurchaseBL(); using (LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities()) { Models.Customer_Purchase cusP = new Models.Customer_Purchase(); string s = txtTotalAmount.Text; cusP.Date = DateTime.Now; cusP.CustomerID = CustomerID; cusP.RecieptNo = txtRecieptNo.Text; double fee = double.Parse(txtTotalAmount.Text, CultureInfo.InvariantCulture); cusP.TotalPrice = (decimal)fee; cusP.RecieptDate = DateTime.Now; //cusP.RecieptDate = Convert.ToDateTime(txtReieptDate.Text.ToString("dd/m/yyyy")); double points = 0; if (Convert.ToDecimal(txtTotalAmount.Text) == 100) { points = double.Parse("10", CultureInfo.InvariantCulture); cusP.LoyaltyPoints = (decimal)points; } else if (Convert.ToDecimal(txtTotalAmount.Text) == 1000) { points = double.Parse("100", CultureInfo.InvariantCulture); cusP.LoyaltyPoints = (decimal)points; } else if (Convert.ToDecimal(txtTotalAmount.Text) < 100) { points = double.Parse("1", CultureInfo.InvariantCulture); cusP.LoyaltyPoints = (decimal)points; } else if (Convert.ToDecimal(txtTotalAmount.Text) > 1000) { points = double.Parse("150", CultureInfo.InvariantCulture); cusP.LoyaltyPoints = (decimal)points; } busEmp.CreateCustomerPurchase(cusP); } }
public void CreateCustomerPurchase(Models.Customer_Purchase model) { using (LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities()) { Models.Customer_Purchase CusPur = new Models.Customer_Purchase(); CusPur.Date = model.Date; CusPur.CustomerID = model.CustomerID; CusPur.EmployeeID = model.EmployeeID; CusPur.LoyaltyPoints = model.LoyaltyPoints; CusPur.TotalPrice = model.TotalPrice; CusPur.RecieptDate = model.RecieptDate; CusPur.RecieptNo = model.RecieptNo; db.Customer_Purchase.Add(CusPur); } }