/// <summary> /// Runs the provided SQL string and fills the invoice variable with the results. /// </summary> /// <param name="sSQL"></param> /// <returns></returns> public List <clsItems> getItems(string sSQL) { try { DataSet ds = new DataSet(); items = new List <clsItems>(); clsItems item; int numRows = 0; ds = da.ExecuteSQLStatement(sSQL, ref numRows); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { item = new clsItems(); item.ItemCode = ds.Tables[0].Rows[i][0].ToString(); item.ItemDesc = ds.Tables[0].Rows[i][1].ToString(); item.ItemCost = Convert.ToDouble(ds.Tables[0].Rows[i][2]); items.Add(item); } return(items); } catch (Exception ex) { throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { clsItems AnItem = new clsItems(); AnItem = (clsItems)Session["AnItem"]; Response.Write(AnItem.ItemDescription + "" + AnItem.ItemQuantity + "" + AnItem.ItemPricePerUnit + "" + AnItem.ItemDateOfAvailability); }
protected void Page_Load(object sender, EventArgs e) { clsItems AnItem = new clsItems(); AnItem = (clsItems)Session["AnItem"]; Response.Write(AnItem.ItemNo); }
public List <clsItems> getItems() { List <clsItems> lstItems = new List <clsItems>(); clsItems clsItems = new clsItems(); sqlClient = new SqlClient(); string sql = string.Empty; try { sql = "Select * from tblItems with(nolock)"; DataTable dataTable = sqlClient.ExecuteQuery(sql, null); if (dataTable.Rows.Count > 0) { lstItems = (from DataRow dr in dataTable.Rows select new clsItems() { Id = Convert.ToInt32(dr["Id"]), Name = Convert.ToString(dr["Name"]), Price = Convert.ToDouble(dr["Price"]), Desc = Convert.ToString(dr["Desc"]) }).ToList(); } } catch (Exception ex) { // Logs } return(lstItems); }
public void UpdateMethodOK() { clsItemsCollection AllItems = new clsItemsCollection(); clsItems TestItems = new clsItems(); Int32 PrimaryKey = 0; TestItems.ItemDescription = "test"; TestItems.ItemQuantity = 1; TestItems.ItemPricePerUnit = 1; TestItems.ItemDateOfAvailability = DateTime.Now.Date; TestItems.ItemAvailability = true; AllItems.ThisItem = TestItems; PrimaryKey = AllItems.Add(); TestItems.ItemNo = PrimaryKey; //modify the test data TestItems.ItemDescription = "another item"; TestItems.ItemQuantity = 9; TestItems.ItemPricePerUnit = 5; TestItems.ItemDateOfAvailability = DateTime.Now.Date; TestItems.ItemAvailability = false; //set the record based on the new test data AllItems.ThisItem = TestItems; AllItems.Update(); AllItems.ThisItem.Find(PrimaryKey); //test to see ThisItem matches the test data Assert.AreEqual(AllItems.ThisItem, TestItems); }
/// <summary> /// Updates the currently selected item. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgItemList_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { //Makes sure the user cannot edit / delete items. btnEditItem.IsEnabled = false; btnSaveEdit.IsEnabled = false; btnCancelEdit.IsEnabled = false; btnDeleteItem.IsEnabled = false; //Reenable the Item code box if it was previously being edited. txtItemCode.IsEnabled = true; //Object to hold the selected item from dgItemList clsItems item = (clsItems)dgItemList.SelectedItem; //Makes sure the item exists if (item != null) { //Enable the user to edit / delete the selected item btnEditItem.IsEnabled = true; btnDeleteItem.IsEnabled = true; //Fills the text boxes with the appropriate info txtItemCode.Text = item.ItemCode; txtItemDesc.Text = item.ItemDesc; txtItemCost.Text = item.ItemCost.ToString(); } } catch (System.Exception ex) { HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name, ex.Message); } }
/// <summary> /// Runs the provided SQL string and fills the items variable with the results; /// </summary> /// <param name="sSQL"></param> /// <returns></returns> public List <clsItems> getItems() { try { DataSet ds = new DataSet(); int iRef = 0; itemsResult = new List <clsItems>(); var query = sql.SelectItems(); clsItems items; ds = db.ExecuteSQLStatement(query, ref iRef); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { items = new clsItems(); items.ItemCode = ds.Tables[0].Rows[i][0].ToString(); items.ItemDesc = ds.Tables[0].Rows[i][1].ToString(); items.ItemCost = Convert.ToDouble(ds.Tables[0].Rows[i][2].ToString()); itemsResult.Add(items); } } catch (Exception ex) { throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message); } return(itemsResult); }
public void GetGridData() { clsItems obj = new clsItems(); GridView1.DataSource = obj.GetDeptItems(Convert.ToInt32(ddlDeptName.SelectedItem.Value)); GridView1.DataBind(); }
public clsItems getItembyId(long id) { List <clsItems> lstItems = new List <clsItems>(); clsItems clsItems = new clsItems(); sqlClient = new SqlClient(); string sql = string.Empty; try { sql = $"Select * from tblItems with (nolock) where Id = {id}"; DataTable dataTable = sqlClient.ExecuteQuery(sql, null); if (dataTable.Rows.Count > 0) { lstItems = (from DataRow dr in dataTable.Rows select new clsItems() { Id = Convert.ToInt32(dr["Id"]), Name = Convert.ToString(dr["Name"]), Price = Convert.ToDouble(dr["Price"]), Desc = Convert.ToString(dr["Desc"]) }).ToList(); clsItems = lstItems.FirstOrDefault(); clsItems.File = Convert.ToBase64String(subGetImage(Convert.ToString(clsItems.Id))); } } catch (Exception ex) { } return(clsItems); }
public void ValidMethodOK() { clsItems AnItem = new clsItems(); String Error = ""; Error = AnItem.Valid(ItemDescription, ItemQuantity, ItemPricePerUnit, ItemDateOfAvailability); Assert.AreEqual(Error, ""); }
public void ItemPricePerUnitPropertyOK() { clsItems AnItem = new clsItems(); Decimal TestData = Convert.ToDecimal("1"); AnItem.ItemPricePerUnit = TestData; Assert.AreEqual(AnItem.ItemPricePerUnit, TestData); }
public void ItemNoPropertyOK() { clsItems AnItem = new clsItems(); Int32 TestData = 11; AnItem.ItemNo = TestData; Assert.AreEqual(AnItem.ItemNo, TestData); }
public void ItemDateOfAvailabilityPropertyOK() { clsItems AnItem = new clsItems(); DateTime TestData = DateTime.Now.Date; AnItem.ItemDateOfAvailability = TestData; Assert.AreEqual(AnItem.ItemDateOfAvailability, TestData); }
public void ItemQuantityPropertyOK() { clsItems AnItem = new clsItems(); Int32 TestData = 1; AnItem.ItemQuantity = TestData; Assert.AreEqual(AnItem.ItemQuantity, TestData); }
public void ItemDescriptionPropertyOK() { clsItems AnItem = new clsItems(); String TestData = "test"; AnItem.ItemDescription = TestData; Assert.AreEqual(AnItem.ItemDescription, TestData); }
public void ItemAvailabilityPropertyOK() { clsItems AnItem = new clsItems(); Boolean TestData = true; AnItem.ItemAvailability = TestData; Assert.AreEqual(AnItem.ItemAvailability, TestData); }
public void ItemPricePerUnitCannotBeLetters() { clsItems AnItem = new clsItems(); String Error = ""; string ItemPricePerUnit = "fifteen pounds"; Error = AnItem.Valid(ItemDescription, ItemQuantity, ItemPricePerUnit, ItemDateOfAvailability); Assert.AreEqual(Error, ""); }
public void ItemPricePerUnitMinPlusOne() { clsItems AnItem = new clsItems(); String Error = ""; string ItemPricePerUnit = "0.010"; Error = AnItem.Valid(ItemDescription, ItemQuantity, ItemPricePerUnit, ItemDateOfAvailability); Assert.AreEqual(Error, ""); }
public void FindMethodOK() { clsItems AnItem = new clsItems(); Boolean Found = false; Int32 ItemNo = 12; Found = AnItem.Find(ItemNo); Assert.IsTrue(Found); }
public void ItemQuantityNotNull() { clsItems AnItem = new clsItems(); String Error = ""; string ItemQuantity = ""; Error = AnItem.Valid(ItemDescription, ItemQuantity, ItemPricePerUnit, ItemDateOfAvailability); Assert.AreNotEqual(Error, ""); }
public void ItemQuantityMaxPlusOne() { clsItems AnItem = new clsItems(); String Error = ""; string ItemQuantity = ""; ItemQuantity = ItemQuantity.PadRight(10001, '1'); //this will fail Error = AnItem.Valid(ItemDescription, ItemQuantity, ItemPricePerUnit, ItemDateOfAvailability); Assert.AreNotEqual(Error, ""); }
public void ItemDescriptionMaxPlusOne() { clsItems AnItem = new clsItems(); String Error = ""; string ItemDescription = ""; ItemDescription = ItemDescription.PadRight(51, 'a'); Error = AnItem.Valid(ItemDescription, ItemQuantity, ItemPricePerUnit, ItemDateOfAvailability); Assert.AreNotEqual(Error, ""); }
public void ItemQuantityMaxLessOne() { clsItems AnItem = new clsItems(); String Error = ""; string ItemQuantity = ""; ItemQuantity = ItemQuantity.PadRight(9999, '1'); Error = AnItem.Valid(ItemDescription, ItemQuantity, ItemPricePerUnit, ItemDateOfAvailability); Assert.AreEqual(Error, ""); }
public void ItemDateOfAvailabilityMin() { clsItems AnItem = new clsItems(); String Error = ""; DateTime TestDate; TestDate = DateTime.Now.Date; string ItemDateOfAvailability = TestDate.ToString(); Error = AnItem.Valid(ItemDescription, ItemQuantity, ItemPricePerUnit, ItemDateOfAvailability); Assert.AreEqual(Error, ""); }
public void GetData() { Session["EID"] = Session["EmpId"]; int empid = Convert.ToInt32(Session["EID"]); clsItems obj = new clsItems(); GridView1.DataSource = obj.GetItemsNotChecked(empid); GridView1.DataBind(); if (GridView1.Rows.Count == 0) { lblMessage.Text = "No Items for Approve"; } }
protected void btnOK_Click(object sender, EventArgs e) { clsItems AnItem = new clsItems(); AnItem.ItemDescription = TxtItemDescription.Text; AnItem.ItemQuantity = Convert.ToInt32(TxtItemQuantity.Text); AnItem.ItemPricePerUnit = Convert.ToDecimal(TxtItemPricePerUnit.Text); AnItem.ItemDateOfAvailability = Convert.ToDateTime(TxtItemDateOfAvailability.Text); AnItem.ItemAvailability = ItemAvailability.Checked; Session["AnItem"] = AnItem; Response.Redirect("ItemViewer.aspx"); }
public void ItemDateOfAvailabilityInvalidFormat() { clsItems AnItem = new clsItems(); String Error = ""; string ItemDescription = "chairs"; string ItemQuantity = "2"; string ItemPricePerUnit = "2.30"; string ItemDateOfAvailability = "this is just words!"; ItemDateOfAvailability = "2nd February 2020"; Error = AnItem.Valid(ItemDescription, ItemQuantity, ItemPricePerUnit, ItemDateOfAvailability); Assert.AreNotEqual(Error, ""); }
public void TestItemPricePerUnitFound() { clsItems AnItem = new clsItems(); Boolean Found = false; Boolean OK = true; Int32 ItemNo = 12; Found = AnItem.Find(ItemNo); if (AnItem.ItemPricePerUnit != Convert.ToDecimal("25")) { OK = false; } Assert.IsTrue(OK); }
public void TestItemNoFound() { clsItems AnItem = new clsItems(); Boolean Found = false; Boolean OK = true; Int32 ItemNo = 12; Found = AnItem.Find(ItemNo); if (AnItem.ItemNo != 12) { OK = false; } Assert.IsTrue(OK); }
public void TestItemDateOfAvailabilityFound() { clsItems AnItem = new clsItems(); Boolean Found = false; Boolean OK = true; Int32 ItemNo = 12; Found = AnItem.Find(ItemNo); if (AnItem.ItemDateOfAvailability != Convert.ToDateTime("02/02/2020")) { OK = false; } Assert.IsTrue(OK); }