public int ChangeTotal(NewTotal nt) { SqlConnection connection = new SqlConnection(connectionString); SqlCommand command = new SqlCommand("usp_changeTotal"); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@ConsignmentID", nt.ConsignmentID)); command.Parameters.Add(new SqlParameter("@NewTotal", nt.NewTotalString)); command.Connection = connection; connection.Open(); SqlDataAdapter adapter = new SqlDataAdapter(command); DataTable table = new DataTable(); adapter.Fill(table); connection.Close(); if (table.Rows[0][0].ToString() == nt.NewTotalString) { return(1); } else { return(0); } }
public void ChangeTotalTest() { NewTotal nt = new NewTotal(); nt.ConsignmentID = GetConsignmentID(); nt.NewTotalString = "TESTTOTAL2"; int result = controller.ChangeTotal(nt); Assert.AreEqual(result, 1); }
protected void BtnUpdate_Click(object sender, EventArgs e) { if (ValidateInput()) { int id = Convert.ToInt32(LblId.Text); int quantity = Convert.ToInt32(TbQuantity.Text); double price = Convert.ToDouble(LblPrice.Text); double NewTotal; NewTotal = ComputeNewTotal(price, quantity); CartDetails cd = new CartDetails("", id, LblName.Text, price, quantity, "", NewTotal.ToString()); int result = cd.UpdateCartQuantity(); if (result == 1) { LblMsg.Text = "Quantity updated successfully"; LblMsg.ForeColor = Color.Green; } else { LblMsg.Text = "Error in changing Quantity! Inform System Administrator!"; LblMsg.ForeColor = Color.Red; } Response.Redirect("Cart.aspx"); } }