public List <SanPham> getProducts(DataType type, ref bool flag) { try { dataConnector.Connect(); DataTable table = dataConnector.GetTable("PRODUCT_PHONE", ref flag); DataTable tableImage = dataConnector.GetTable("IMAGE_PHONE", ref flag); List <SanPham> sanPhams = new List <SanPham>(); for (int i = 0; i < table.Rows.Count; i++) { Image[] image = new Image[4]; for (int img = 0; img < 4; img++) { MemoryStream mem = new MemoryStream((byte[])tableImage.Rows[i][img + 1]); image[img] = Image.FromStream(mem); } DienThoai dienThoai = new DienThoai(table.Rows[i][0].ToString(), table.Rows[i][1].ToString(), table.Rows[i][2].ToString(), table.Rows[i][3].ToString(), float.Parse(table.Rows[i][4].ToString()), float.Parse(table.Rows[i][5].ToString()), int.Parse(table.Rows[i][6].ToString()), 0, image); sanPhams.Add(dienThoai); } return(sanPhams); } catch (Exception e) { Debug.WriteLine(e.Message); flag = false; } return(null); }
public List <DanhMucSanPham> getCategory(DataType type, ref bool flag) { try { dataConnector.Connect(); DataTable table = dataConnector.GetTable("CATEGORY_PHONE", ref flag); List <DanhMucSanPham> sanPhams = new List <DanhMucSanPham>(); for (int i = 0; i < table.Rows.Count; i++) { MemoryStream mem = new MemoryStream((byte[])table.Rows[i][1]); Image image = Image.FromStream(mem); DanhMucSanPham sp = new DanhMucSanPham((string)table.Rows[i][0], image); sanPhams.Add(sp); Debug.WriteLine(i + " " + sp.Loai); } return(sanPhams); }catch (Exception e) { Debug.WriteLine("Err Get du lieu Category :" + e); flag = false; } return(null); }
public void Connect_ShouldReturnUpdatedFields_WhenRun() { Mast mast = new Mast() { VOAAddressLine1 = "Address One", VOAAddressLine2 = "Address Two", VOAAddressLine3 = "Address Three", VOAAddressLine4 = "Address Four", VOAMastOperator = "asasd", VOAOccupier = "Occupier", VOARateableValue = "300", VOAShared = "Shared", VOASharedWith = "Many" }; DataConnector <Mast> mastsConnector = new DataConnector <Mast>(); List <PDFField> fields = new List <PDFField>() { new PDFField() { Name = "VOAShared", Value = "Shared" }, new PDFField() { Name = "FOoo", Value = "" } }; List <PDFField> result = mastsConnector.Connect(fields, mast); //Preserve count Assert.AreEqual(fields.Count, result.Count); //Preserve order Assert.AreEqual(fields[0].Name, result[0].Name); string updatedResult = result.Where(x => x.Name == "VOAShared").FirstOrDefault().Value; Assert.AreEqual(mast.VOAShared, updatedResult); }