예제 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.QueryString["productID"] == null)
     {
         Response.Redirect("~/AccessDenied.aspx");
     }
     DAO.Product dp = new DAO.Product();
     pid = int.Parse(Request.QueryString["productID"].ToString());
     Model.Cart c = new Model.Cart();
     if (pid > 0)
     {
         Model.Product p = dp.GetProductsCartById(pid);
         c.Cart_id   = int.Parse(Session["CartId"].ToString());
         c.Pid       = p.Pid;
         c.Pimage    = p.Pimage;
         c.Uid       = int.Parse(Session["UserId"].ToString());
         c.Pname     = p.Pname;
         c.Status    = "pending";
         c.Quantity  = 1;
         c.Amount    = p.Pprice;
         c.Createdon = DateTime.Now;
         Controller.Cart cc = new Controller.Cart();
         Response.Write(cc.AddToCartValidate(c));
         Response.Redirect("ShoppingCart.aspx");
     }
 }
예제 #2
0
        /// <summary>
        /// 添加产成品基本信息
        /// </summary>
        /// <param name="error"></param>
        /// <returns></returns>
        public static bool AddProduct(Model.Product product, ref string error)
        {
            List <string> sqls = new List <string>();

            if (IsExit(product.ProductNumber, product.Version))
            {
                error = "已存在该编号、版本!请重新填写!";
                return(false);
            }

            if (string.IsNullOrEmpty(product.ProductNumber) || string.IsNullOrEmpty(product.Version))
            {
                error = "产成品信息不完整!";
                return(false);
            }
            string sql = string.Format(@" insert into Product (ProductNumber,Version,ProductName,Description,RatedManhour,QuoteManhour,
             CostPrice,SalesQuotation,HalfProductPosition,FinishedGoodsPosition,Remark,IsOldVersion,type,Cargo,Unit,NumberProperties) values 
              ('{0}','{1}','{2}','{3}',{4},{5},'{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}')",
                                       product.ProductNumber, product.Version, product.ProductName, product.Description, product.RatedManhour,
                                       product.QuoteManhour, product.CostPrice, product.SalesQuotation, product.HalfProductPosition,
                                       product.FinishedGoodsPosition, product.Remark, product.IsOldVersion, product.Type, product.Cargo, product.Unit, product.NumberProperties);

            sqls.Add(sql);
            sql = string.Format(@"
insert into ProductStock (ProductNumber ,Version ,WarehouseName ,StockQty ,UpdateTime )
values('{0}','{1}','cpk',0,'{2}')", product.ProductNumber, product.Version, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            sqls.Add(sql);
            if (product.Type == "包")
            {
                sql = string.Format(@"insert into PackageInfo(PackageNumber,PackageName)values('{0}','{1}')", product.ProductNumber, product.ProductName);
                sqls.Add(sql);
            }
            return(SqlHelper.BatchExecuteSql(sqls, ref error));
        }
예제 #3
0
 private DAL.Models.Product ToObject(Model.Product product)
 {
     return(new DAL.Models.Product()
     {
         Name = product.Name
     });
 }
        public List <Model.Product> GetProductByCategory(string category, string searchkey)
        {
            string query = "select p.pid,p.pname,p.pimage,p.scid,pstock,p.pdesc,pprice,pbrand,pgender from category c join subcategory sc on c.cid = sc.cid join products p on p.scid = sc.scid where cname = '" + category + "' and pname like '%" + searchkey + "%'";
            List <Model.Product> productList = new List <Model.Product>();
            SqlDataAdapter       da          = new SqlDataAdapter(query, con);
            DataSet productset = new DataSet();

            da.Fill(productset, "Products");

            for (int i = 0; i < productset.Tables["Products"].Rows.Count; i++)
            {
                Model.Product p = new Model.Product();
                p.Pid     = int.Parse(productset.Tables["Products"].Rows[i][0].ToString());
                p.Pname   = productset.Tables["Products"].Rows[i][1].ToString();
                p.Pimage  = productset.Tables["Products"].Rows[i][2].ToString();
                p.Scid    = int.Parse(productset.Tables["Products"].Rows[i][3].ToString());
                p.Pstock  = int.Parse(productset.Tables["Products"].Rows[i][4].ToString());
                p.Pdesc   = productset.Tables["Products"].Rows[i][5].ToString();
                p.Pprice  = double.Parse(productset.Tables["Products"].Rows[i][6].ToString());
                p.Pbrand  = productset.Tables["Products"].Rows[i][7].ToString();
                p.Pgender = productset.Tables["Products"].Rows[i][8].ToString();
                productList.Add(p);
            }

            return(productList);;
        }
예제 #5
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var id   = Guid.Parse(this.ddlLoanType.SelectedValue);
            int res  = 0;
            var data = proSvc.GetProductByLoanTypeId(id);

            if (data == null)
            {
                data = new Model.Product()
                {
                    LoanType_Id    = Guid.Parse(this.ddlLoanType.SelectedValue),
                    Product_Detail = this.txtProductContent.Value
                };
                res = proSvc.Add(data);
            }
            else
            {
                data.LoanType_Id    = Guid.Parse(this.ddlLoanType.SelectedValue);
                data.Product_Detail = this.txtProductContent.Value;
                res = proSvc.Edit(data);
            }
            var rm = res > 0 ? new ReturnMsg {
                Code    = StatusCode.Ok,
                Message = "编辑产品介绍成功",
                Data    = null
            } : new ReturnMsg {
                Code    = StatusCode.Error,
                Message = "编辑产品介绍失败",
                Data    = null
            };

            Session["Msg"] = rm;
            Response.Redirect("Product_Info.aspx");
        }
예제 #6
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Model.Product u = new Model.Product
            {
                Product_Title   = this.txtName.Text,
                Product_Image   = upFileName(this.FileUpload1, "../../upload/Product/"),
                Product_Intro   = this.textIntro.Text,
                Product_Content = this.txtContent.Text,
                Product_Price   = int.Parse(this.txtPrice.Text)
            };
            var       res = productSvc.Add(u);
            ReturnMsg rm  = res > 0
                ? new ReturnMsg()
            {
                Code    = StatusCode.OK,
                Message = "新增用户信息成功",
                Data    = null
            }
                : new ReturnMsg()
            {
                Code    = StatusCode.Error,
                Message = "新增用户信息失败",
                Data    = null
            };

            Session["Msg"] = rm; //用于传递执行信息的
            Response.Redirect("Product_List.aspx");
        }
예제 #7
0
 //---------------------------------------------------------------------
 public TViewProductViewModel(Product product, ElementViewModel parent = null)
 {
     this.Parent = parent;
     this.Product = product;
     this.Name = product.ToString();
     this.Children = new ReadOnlyCollection<ElementViewModel>((from version in this.Product.Versions
                                                                select new TViewVersionViewModel(version, this)).ToList<ElementViewModel>()).ToList();
 }
예제 #8
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string photo = upFileName(this.FileUpload1, "../../upload/users/");

            Model.Product p = productSvc.GetProductById(Guid.Parse(this.hfId.Value));
            if (photo == "")
            {
                p = new Model.Product
                {
                    Product_Title      = this.txtName.Text,
                    Product_Intro      = this.textIntro.Text,
                    Product_Content    = this.txtContent.Text,
                    Product_Price      = double.Parse(this.txtPrice.Text),
                    Product_UpdateTime = DateTime.Now
                };
            }
            else
            {
                p = new Model.Product
                {
                    Product_Title      = this.txtName.Text,
                    Product_Intro      = this.textIntro.Text,
                    Product_Content    = this.txtContent.Text,
                    Product_Price      = double.Parse(this.txtPrice.Text),
                    Product_Image      = photo,
                    Product_UpdateTime = DateTime.Now
                };
            }

            var       res = productSvc.Edit(p);
            ReturnMsg rm  = res > 0
                ? new ReturnMsg()
            {
                Code    = StatusCode.OK,
                Message = "编辑用户信息成功",
                Data    = null
            }
                : new ReturnMsg()
            {
                Code    = StatusCode.Error,
                Message = "编辑用户信息失败",
                Data    = null
            };

            Session["Msg"] = rm; //用于传递执行信息的
            Response.Redirect("Product_List.aspx");
        }
예제 #9
0
    private void List()
    {
        int currentPage = 1;

        int.TryParse(Request.QueryString["page"], out currentPage);
        if (currentPage <= 0)
        {
            currentPage = 1;
        }

        PagerItem pagerItem = new PagerItem();

        pagerItem.CurrentPage = currentPage;
        pagerItem.PageSize    = 15;
        pagerItem.Keywords    = "";

        IProductBLL productBLL = (IProductBLL)SpringContext.Context.CreateInstance("ProductBLL");
        IList       list       = productBLL.Select(pagerItem);
        int         count      = list.Count;

        StringBuilder result = new StringBuilder();

        result.Append("{result:[");
        if (count > 0)
        {
            for (int i = 0; i < count; i++)
            {
                Model.Product product = (Model.Product)list[i];
                result.Append("{ID:").Append(product.ID).Append(",");
                result.Append("ProductName:\"").Append(product.ProductName).Append("\",");
                result.Append("NormalPrice:").Append(product.NormalPrice).Append(",");
                result.Append("MemberPrice:").Append(product.MemberPrice).Append("}");
                if (i < count - 1)
                {
                    result.Append(",");
                }
            }
        }

        result.Append("]}");

        Response.Write(result.ToString());
        Response.End();
    }
예제 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Product product = new Product()
            {
                Name = "Apple",
                Category = "Fruit",
                Description = "This is a apple."
            };
            string fullName = product.GetType().FullName;

            if (dictionary.ContainsKey(fullName) && dictionary[fullName] != null)
            {
                _product = dictionary[fullName];
            }
            else
            {
                dictionary[fullName] = product;
            }
        }
예제 #11
0
    private void Save()
    {
        string productId = Request.QueryString["productId"];

        Model.Product product = new Model.Product();
        product.ProductName = Request.Form["ProductName"];
        product.NormalPrice = decimal.Parse(Request.Form["NormalPrice"]);
        product.MemberPrice = decimal.Parse(Request.Form["MemberPrice"]);

        if (string.IsNullOrEmpty(productId))
        {
            productBLL.Insert(product);
        }
        else
        {
            product.ID = int.Parse(productId);
            productBLL.Update(product);
        }
        Response.Write("{success: true}");
        Response.End();
    }
예제 #12
0
        public IList<Model.Product> FindAll()
        {
            //var docs = db.GetCollection<Model.Product>("docs").FindAll();
            var prods =
                db.GetCollection<BsonDocument>("products")
                  .FindAll()
                  .SetFields("ProductId", "ProductName", "RRP", "SellingPrice");

            var ld = new List<Model.Product>();
            foreach (BsonDocument docse in prods)
            {
                Model.Product prod = new Model.Product();

                prod.Id = docse.GetValue("ProductId").ToInt32();
                prod.Name = docse.GetValue("ProductName").ToString();
                prod.Price = new Model.Price( Convert.ToDecimal(docse.GetValue("RRP")),Convert.ToDecimal(docse.GetValue("SellingPrice")));
                ld.Add(prod);
            }

            return ld;
        }
예제 #13
0
파일: Product.cs 프로젝트: ecmr/FAMIS
        public Model.Product Select(Model.Product Pdt)
        {
            try
            {
                SqlCommand cmd = new SqlCommand("Select * From [FAMIS].[dbo].[Product] Where product_id =" + Pdt.Product_id, db.Db());
                SqlDataReader dr = cmd.ExecuteReader();

                Model.Product Pd;

                Pd = new Model.Product();

                while (dr.Read())
                {

                    Pd = new Model.Product();

                    if (!dr.IsDBNull(0))
                    {
                        Pd.Product_id = dr.GetInt32(0);
                    }
                    if (!dr.IsDBNull(1))
                    {
                        Pd.Name = dr.GetString(1);
                    }
                    if (!dr.IsDBNull(1))
                    {
                        Pd.Client_id = dr.GetInt32(1);
                    }
                }

                return Pd;

            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #14
0
    /// <summary>
    /// 向购物车添加产品
    /// </summary>
    private void Add()
    {
        string id = Request.QueryString["productId"];

        if (!string.IsNullOrEmpty(id))
        {
            int productId = 0;
            int.TryParse(id, out productId);

            IProductBLL   productBLL = (IProductBLL)SpringContext.Context.CreateInstance("ProductBLL");
            Model.Product product    = productBLL.Select(productId);

            OrderProduct orderProduct = new OrderProduct();
            orderProduct.Num         = 1;
            orderProduct.ProductID   = productId;
            orderProduct.ProductName = product.ProductName;

            IUserBLL   userBLL   = (IUserBLL)SpringContext.Context.CreateInstance("UserBLL");
            ICustomBLL customBLL = (ICustomBLL)SpringContext.Context.CreateInstance("CustomBLL");
            if (customBLL.Select(userBLL.UserID).IsMember)
            {
                orderProduct.Price = product.MemberPrice;
            }
            else
            {
                orderProduct.Price = product.NormalPrice;
            }

            shopCarBLL.Add(orderProduct);

            Response.Write("{success:true}");
        }
        else
        {
            Response.Write("{success:false}");
        }
        Response.End();
    }
예제 #15
0
        public List <Model.Product> GetProducts()
        {
            List <Model.Product> productList = new List <Model.Product>();
            SqlDataAdapter       da          = new SqlDataAdapter("select * from products", con);
            DataSet productset = new DataSet();

            da.Fill(productset, "Products");
            for (int i = 0; i < productset.Tables["Products"].Rows.Count; i++)
            {
                Model.Product p = new Model.Product();
                p.Pid     = int.Parse(productset.Tables["Products"].Rows[i][0].ToString());
                p.Pname   = productset.Tables["Products"].Rows[i][1].ToString();
                p.Pimage  = productset.Tables["Products"].Rows[i][2].ToString();
                p.Scid    = int.Parse(productset.Tables["Products"].Rows[i][3].ToString());
                p.Pstock  = int.Parse(productset.Tables["Products"].Rows[i][4].ToString());
                p.Pdesc   = productset.Tables["Products"].Rows[i][5].ToString();
                p.Pprice  = double.Parse(productset.Tables["Products"].Rows[i][6].ToString());
                p.Pbrand  = productset.Tables["Products"].Rows[i][7].ToString();
                p.Pgender = productset.Tables["Products"].Rows[i][8].ToString();
                productList.Add(p);
            }
            return(productList);
        }
예제 #16
0
 public static void AddProduct(Product product)
 {
     Products.Add(product);
 }
예제 #17
0
 /// <summary>
 /// 获得单个实体对象
 /// </summary>
 /// <param name="whereStr">关键字</param>
 /// <returns>实体对象</returns>
 public Model.Product SelectModel(string whereStr)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append(@"select [Id],[JK_Product_Name],[JK_Product_Type],[JK_Product_DateTime],[JK_Product_Type_Id],[JK_Product_Price],[JK_Product_Imgsrc],[JK_Product_Bewrite],[JK_Product_parameten_1],[JK_Product_parameten_2],[JK_Product_parameten_3],[JK_Product_parameten_4] from [Product] ");
     if (whereStr.Trim() != "")
     {
         strSql.Append(@" where " + whereStr);
     }
     Model.Product model = new Model.Product();
     DataTable dt = DAL.SqlDataHelper.GetDataTable(strSql.ToString());
     if (dt.Rows.Count > 0)
     {
         LoadEntityData(ref model, dt.Rows[0]);
         return model;
     }
     else
     {
         return null;
     }
 }
예제 #18
0
		private void attach_Products(Product entity)
		{
			this.SendPropertyChanging();
			entity.Category = this;
		}
예제 #19
0
 partial void UpdateProduct(Product instance);
예제 #20
0
        void InitializeViewboxesAndLabels(Product product)
        {
            //Name
            Viewbox productViewbox = new Viewbox();
            productViewbox.Height = ProductFieldHeight;
            productViewbox.Width = BorderWidth;
            CurrentHeight += ProductFieldHeight;

            Label productNameLabel = new Label();
            productNameLabel.Width = product.Title.Length * 10 + 1;
            productNameLabel.FontWeight = FontWeights.Bold;
            productNameLabel.Content = product.Title;
            productViewbox.Child = productNameLabel;
            this.wrapPanel.Children.Add(productViewbox);

            //Price
            Viewbox priceViewbox = new Viewbox();
            priceViewbox.Height = ProductFieldHeight;
            priceViewbox.Width = BorderWidth;
            CurrentHeight += ProductFieldHeight;
            Label priceLabel = new Label();
            //priceLabel.Content = Math.Round(product.Price * product.Quantity, 2) + " €";
            priceLabel.Content = Math.Round(product.Price, 2) + " €";
            priceLabel.Width = BorderWidth / 4;

            priceViewbox.Child = priceLabel;
            this.wrapPanel.Children.Add(priceViewbox);

            //Notes
            Viewbox notesViewbox = new Viewbox();
            notesViewbox.Height = ProductFieldHeight;
            notesViewbox.Width = product.Notes.Length * 50 + 1;

            Label notesLabel = new Label();
            notesLabel.Content = product.Notes;

            notesLabel.Width = product.Notes.Length * 10 + 1;
            notesLabel.Height = ProductFieldHeight;
            CurrentHeight += ProductFieldHeight;
            notesViewbox.Child = notesLabel;
            this.wrapPanel.Children.Add(notesViewbox);
            AddLineSeparator(1);
        }
예제 #21
0
        /// <summary>
        /// The greate product dummy.
        /// </summary>
        /// <returns>
        /// The <see cref="Product"/>.
        /// </returns>
        private static Product GreateProductDummy()
        {
            var featureA = new Feature { Description = "feature A Deskription", Name = "Feature A" };

            var featureB = new Feature { Description = "feature A Deskription", Name = "Feature B" };

            var featureC = new Feature { Description = "feature A Deskription", Name = "Feature C" };

            var fl = new List<Feature> { featureC, featureA, featureB };

            var product = new Product
                              {
                                  Id = "PJ1",
                                  Name = "Product J",
                                  Description = "Product J Description",

                              };
            return product;
        }
예제 #22
0
        /// <summary>
        /// 根据条件查询实体记录
        /// </summary>
        /// <param name="whereStr">查询条件</param>
        /// <returns>实体记录</returns>
        public IList<Model.Product> SelectList(int top,string whereStr)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select ");
            if(top>0)
            {
               strSql.Append(" top "+top);
            }
            strSql.Append(" [Id],[JK_Product_Name],[JK_Product_Type],[JK_Product_DateTime],[JK_Product_Type_Id],[JK_Product_Price],[JK_Product_Imgsrc],[JK_Product_Bewrite],[JK_Product_parameten_1],[JK_Product_parameten_2],[JK_Product_parameten_3],[JK_Product_parameten_4] from [Product] ");
            if (whereStr.Trim() != "")
            {
                strSql.Append(@" where " + whereStr);
            }
            DataTable dt = DAL.SqlDataHelper.GetDataTable(strSql.ToString());
            List<Model.Product > list = null;
            if (dt.Rows.Count > 0)
            {
                list = new List<Model.Product >();
                Model.Product  model = null;

                foreach (DataRow dr in dt.Rows)
                {
                    model = new Model.Product ();
                    LoadEntityData(ref model, dr);
                    list.Add(model);
                }
            }
            return list;
        }
예제 #23
0
 /// <summary>
 /// Create a new Product object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="description">Initial value of the Description property.</param>
 /// <param name="price">Initial value of the Price property.</param>
 /// <param name="auditFields">Initial value of the AuditFields property.</param>
 public static Product CreateProduct(global::System.Int32 id, global::System.String name, global::System.String description, global::System.Decimal price, AuditFields auditFields)
 {
     Product product = new Product();
     product.Id = id;
     product.Name = name;
     product.Description = description;
     product.Price = price;
     product.AuditFields = StructuralObject.VerifyComplexObjectIsNotNull(auditFields, "AuditFields");
     return product;
 }
예제 #24
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Products EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProducts(Product product)
 {
     base.AddObject("Products", product);
 }
예제 #25
0
 /// <summary>
 /// 往实体集合中添加记录
 /// </summary>
 /// <param name="list">实体列表</param>
 /// <param name="dt">表</param>
 private void LoadListData(ref IList<Model.Product > list, DataTable dt)
 {
     if (dt.Rows.Count > 0)
     {
         Model.Product  model;
         foreach (DataRow dr in dt.Rows)
         {
             model = new Model.Product ();
             LoadEntityData(ref model, dr);
             list.Add(model);
         }
     }
 }
예제 #26
0
        public static List<Order> GetOrderList(string url)
        {

            List<Order> completeOrder = new List<Order>();

            try
            {
                JObject json = NetworkUtil.GetJson(url);
                JArray orderArray = (JArray)json["orders"];

                foreach (JObject orderArrayItem in orderArray)
                {
                    Order orderitem = new Order();
                    List<Product> productList = new List<Product>();
                    orderitem.OrderID = (int)orderArrayItem["id"];

                    if(!OrderHolder.IsOrderUnique(orderitem.OrderID))
                    {
                        Console.WriteLine("Dropped " + orderitem.OrderID);
                        continue;
                    }

                    orderitem.TableNumber = (string)orderArrayItem["tableNumber"];
                    orderitem.DateTime = (string)orderArrayItem["dateTime"];
                    orderitem.TotalPrice = (double)orderArrayItem["totalPrice"];
                    JArray orders = (JArray)orderArrayItem["orderedProducts"];

                    foreach (JObject order in orders)
                    {

                        Product product = new Product();
                        JObject orderDTO = (JObject)order["productDTO"];
                        product.Name = (string)orderDTO["name"];
                        product.Price = (double)orderDTO["price"];
                        product.Attributes = (string)order["attributes"];
                        product.Quantity = (int)order["quantity"];
                        product.Notes = (string)order["notes"];
                        productList.Add(product);

                    }
                    orderitem.Products = productList;
                    OrderHolder.AddOrder(orderitem);
                    completeOrder.Add(orderitem);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error while parsing json" + ex.Message);
                return null;
            }
            return completeOrder;
        }
예제 #27
0
        private static void CreateProductGroup(XElement element,out ProductGroup productGroup)
        {
            productGroup = new ProductGroup();
            var productGroupElementName = element.Element("productGroupName");
            if (productGroupElementName != null)
            {
                   productGroup.ProductGroupName = productGroupElementName.Value;
            }

            foreach (var productElement in element.Elements("product"))
            {
                var product = new Product ();
                product.Id = productElement.Attribute("id").Value;
                productGroup.Products.Add(product);
                var descriptionElement = productElement.Element("productDescription");
                if (descriptionElement != null)
                {
                    product.Description = descriptionElement.Value;
                }
                var nameElement = productElement.Element("productName");
                if (nameElement!=null)
                {
                    product.Name = nameElement.Value;
                }

                foreach (var versionElement in productElement.Elements("version"))
                {
                    var version = new Version ();
                    product.Versions.Add(version);
                    var versionNumberElement = versionElement.Element("versionNumber");
                    if (versionNumberElement != null)
                    {
                        version.VersionNumber = versionNumberElement.Value;
                    }
                    foreach (var feautureElement in versionElement.Elements("feature"))
                    {
                        var feauture = new Feature();
                        version.Features.Add(feauture);
                        var featureElementName = feautureElement.Element("featureName");
                        if (featureElementName != null)
                        {
                            feauture.Name = featureElementName.Value;
                        }
                        var feautureElementDescription = feautureElement.Element("featureDescription");
                        if (feautureElementDescription != null)
                        {
                            feauture.Description = feautureElementDescription.Value;
                        }
                    }
                }
            }
        }
예제 #28
0
        // Purchases & Sales:
        public static List<Purchase> GetPurchases(DateTime initialDate, DateTime finalDate)
        {
            // Create an empty list of purchases:
            List<Purchase> purchases = new List<Purchase>();

            if (!InitializeCompany())
                return purchases;

            StdBELista purchasesQuery = PriEngine.Engine.Consulta(
                "SELECT CabecCompras.Id AS CabecComprasId, CabecCompras.Nome AS CabecComprasNome, CabecCompras.Entidade AS CabecComprasEntidade, CabecCompras.Moeda AS CabecComprasMoeda, CabecCompras.DataDoc AS CabecComprasDataDoc, CabecCompras.TipoDoc AS CabecComprasTipoDoc, CabecCompras.DataVencimento AS CabecComprasDataVencimento, CabecCompras.DataDescarga AS CabecComprasDataDescarga, " +
                "LinhasCompras.Id AS LinhasComprasId, LinhasCompras.PrecoLiquido AS LinhasComprasPrecoLiquido, " +
                "Artigo.Artigo AS ArtigoId, Artigo.Marca AS ArtigoMarca, Artigo.Modelo AS ArtigoModelo, Artigo.Descricao AS ArticoDescricao, Artigo.TipoArtigo AS ArtigoTipoArtigo, " +
                "Familias.Familia AS FamiliaId, Familias.Descricao AS FamiliaDescricao, " +
                "Iva.Taxa AS IvaTaxa " +
                "FROM CabecCompras " +
                "INNER JOIN LinhasCompras ON LinhasCompras.IdCabecCompras=CabecCompras.Id " +
                "INNER JOIN Artigo ON Artigo.Artigo=LinhasCompras.Artigo " +
                "INNER JOIN Familias ON Artigo.Familia=Familias.Familia " +
                "INNER JOIN Iva ON LinhasCompras.CodIva = Iva.Iva " +
                "WHERE CabecCompras.DataDoc >= '" + initialDate.ToString("yyyyMMdd") + "' AND CabecCompras.DataDoc <= '" + finalDate.ToString("yyyyMMdd") + "' " +
                "ORDER BY CabecCompras.DataDoc"
                );

            while (!purchasesQuery.NoFim())
            {
                Purchase purchase = new Purchase();

                // Set values:
                purchase.ID = purchasesQuery.Valor("LinhasComprasId");
                purchase.DocumentDate = ParseDate(purchasesQuery, "CabecComprasDataDoc");
                purchase.DocumentType = purchasesQuery.Valor("CabecComprasTipoDoc");
                purchase.DueDate = ParseDate(purchasesQuery, "CabecComprasDataVencimento");
                purchase.ReceptionDate = ParseDate(purchasesQuery, "CabecComprasDataDescarga");
                purchase.SupplierId = purchasesQuery.Valor("CabecComprasEntidade");
                purchase.SupplierName = purchasesQuery.Valor("CabecComprasNome");
                purchase.Value = new Money(purchasesQuery.Valor("LinhasComprasPrecoLiquido"), purchasesQuery.Valor("CabecComprasMoeda"));
                purchase.Iva = purchasesQuery.Valor("IvaTaxa") / 100.0;

                Product product = new Product();
                product.Id = purchasesQuery.Valor("ArtigoId");
                product.Brand = purchasesQuery.Valor("ArtigoMarca");
                product.Model = purchasesQuery.Valor("ArtigoModelo");
                product.Description = purchasesQuery.Valor("ArticoDescricao");
                product.FamilyId = purchasesQuery.Valor("FamiliaId");
                product.FamilyDescription = purchasesQuery.Valor("FamiliaDescricao");
                purchase.Product = product;

                // Add purchase to the list:
                purchases.Add(purchase);

                // Next line in the purchase document:
                purchasesQuery.Seguinte();
            }

            return purchases;
        }
예제 #29
0
파일: Product.cs 프로젝트: ecmr/FAMIS
        //Nesse caso vai retornar uma lista de objeto. Não sei se seu retorno vão ter vários, ou um por vez. Se for um por vez, não precisa usar lista.
        public List<Model.Product> Select(String pWhere)
        {
            List<Model.Product> lstProduct = new List<Model.Product>();
            Model.Product Prod;

            SqlCommand cmd = new SqlCommand("Select * From dbo.[Product] " + pWhere, db.Db());
            //SQLHelper.ExecuteReader("string de conexao", CommandType.StoredProcedure, "Procedure", null)
            using (SqlDataReader dr = cmd.ExecuteReader())
            {
                while (dr.Read())
                {
                    Prod = new Model.Product();

                    if (!dr.IsDBNull(0))
                    {
                        Prod.Product_id = dr.GetInt32(0);
                    }
                    if (!dr.IsDBNull(1))
                    {
                        Prod.Name = dr.GetString(1);
                    }
                    if (!dr.IsDBNull(1))
                    {
                        Prod.Client_id = dr.GetInt32(1);
                    }

                    lstProduct.Add(Prod);
                }
            }

            return lstProduct;
        }
예제 #30
0
        public static List<Sale> GetSales(DateTime initialDate, DateTime finalDate)
        {
            // Create an empty list of sales
            List<Sale> sales = new List<Sale>();

            //Initialize company
            if (!InitializeCompany())
                return sales;

            //DataDescarga always null ?
            StdBELista salesQuery = PriEngine.Engine.Consulta(
                "SELECT CabecDoc.Id AS CabecDocId, CabecDoc.Nome AS CabecDocNome, CabecDoc.Entidade AS CabecDocEntidade, CabecDoc.Moeda AS CabecDocMoeda, CabecDoc.TipoDoc AS CabecDocTipoDoc, CabecDoc.Data AS CabecDocData, CabecDoc.DataVencimento AS CabecDocDataVencimento, CabecDoc.DataCarga AS CabecDocDataCarga, CabecDoc.DataDescarga AS CabecDocsDataDescarga, " +
                "LinhasDoc.Id AS LinhasDocId, LinhasDoc.PrecoLiquido AS LinhasDocPrecoLiquido, " +
                "Artigo.Artigo AS ArtigoId, Artigo.Marca AS ArtigoMarca, Artigo.Modelo AS ArtigoModelo, Artigo.Descricao AS ArticoDescricao, Artigo.TipoArtigo AS ArtigoTipoArtigo, " +
                "Familias.Familia AS FamiliaId, Familias.Descricao AS FamiliaDescricao, " +
                "Iva.Taxa AS IvaTaxa " +
                "FROM CabecDoc " +
                "INNER JOIN LinhasDoc ON LinhasDoc.IdCabecDoc = CabecDoc.Id " +
                "INNER JOIN Artigo ON Artigo.Artigo = LinhasDoc.Artigo " +
                "INNER JOIN Familias ON Artigo.Familia = Familias.Familia " +
                "INNER JOIN Iva ON LinhasDoc.CodIva = Iva.Iva " +
                "WHERE CabecDoc.Data >= '" + initialDate.ToString("yyyyMMdd") + "' AND CabecDoc.Data <= '" + finalDate.ToString("yyyyMMdd") + "' " +
                "ORDER BY CabecDoc.Data"
                );

            while (!salesQuery.NoFim())
            {
                Sale sale = new Sale();

                sale.ID = salesQuery.Valor("LinhasDocId");
                sale.DocumentDate = ParseDate(salesQuery, "CabecDocData");
                sale.DocumentType = salesQuery.Valor("CabecDocTipoDoc");
                sale.DueDate = ParseDate(salesQuery, "CabecDocDataVencimento");
                sale.ReceptionDate = ParseDate(salesQuery, "CabecDocsDataDescarga");
                sale.ClientId = salesQuery.Valor("CabecDocEntidade");
                sale.ClientName = salesQuery.Valor("CabecDocNome");
                sale.Value = new Money(salesQuery.Valor("LinhasDocPrecoLiquido"), salesQuery.Valor("CabecDocMoeda"));
                sale.Iva = salesQuery.Valor("IvaTaxa") / 100.0;

                Product product = new Product();
                product.Id = salesQuery.Valor("ArtigoId");
                product.Brand = salesQuery.Valor("ArtigoMarca");
                product.Model = salesQuery.Valor("ArtigoModelo");
                product.Description = salesQuery.Valor("ArticoDescricao");
                product.FamilyId = salesQuery.Valor("FamiliaId");
                product.FamilyDescription = salesQuery.Valor("FamiliaDescricao");
                sale.Product = product;

                sales.Add(sale);

                // Next item:
                salesQuery.Seguinte();
            }

            return sales;
        }
예제 #31
0
 partial void InsertProduct(Product instance);
예제 #32
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Model.Product pro = new Model.Product();
            if (txtTitle.Text == "")
            {
                MessageBox.Alert("产品名称不能为空!", Page);
                txtTitle.Focus();
            }
            else if (hfId.Value == "" && hftypeId.Value == "")
            {
                Response.Redirect("right.aspx");
            }
            else
            {
                pro.Title     = txtTitle.Text;
                pro.IsShow    = Convert.ToInt32(chkShow.Checked);
                pro.IndexShow = Convert.ToInt32(chkIndex.Checked);
                pro.Intro     = fck_intro.Value;
                pro.Details   = fck_detail.Value;
                if (txtTimer.Value == "")
                {
                    pro.CreateTime = DateTime.Now.ToString("yyy-MM-dd");
                }
                else
                {
                    pro.CreateTime = txtTimer.Value;
                }
                //判断缩略图的值
                if (txtImg.Text == "" && hfImgUrl1.Value == "")
                {
                    pro.ImgUrl = "";
                }
                else if (txtImg.Text != "" && hfImgUrl1.Value == "")
                {
                    pro.ImgUrl = txtImg.Text;
                }
                else if (txtImg.Text == "" && hfImgUrl1.Value != "")
                {
                    pro.ImgUrl = hfImgUrl1.Value;
                }
                else if (txtImg.Text != hfImgUrl1.Value)
                {
                    pro.ImgUrl = hfImgUrl1.Value;
                }
                else
                {
                    pro.ImgUrl = txtImg.Text;
                }
                //判断大图的值
                if (txtBigImg.Text == "" && hfImgUrl.Value == "")
                {
                    pro.BigImgUrl = "";
                }
                else if (txtBigImg.Text != "" && hfImgUrl.Value == "")
                {
                    pro.BigImgUrl = txtBigImg.Text;
                }
                else if (txtBigImg.Text == "" && hfImgUrl.Value != "")
                {
                    pro.BigImgUrl = hfImgUrl.Value;
                }
                else if (txtBigImg.Text != hfImgUrl.Value)
                {
                    pro.BigImgUrl = hfImgUrl.Value;
                }
                else
                {
                    pro.BigImgUrl = txtBigImg.Text;
                }

                //判断产品类型的值
                if (hftypeId.Value != "")
                {
                    pro.ProTypeId = Convert.ToInt32(hftypeId.Value);
                    try
                    {
                        ProductBll.AddProduct(pro);
                        MessageBox.AlertAndRedirect("添加成功!", "Product.aspx?typeId=" + pro.ProTypeId, Page);
                    }
                    catch (Exception)
                    {
                        MessageBox.Alert("添加失败!", Page);
                        throw;
                    }
                }
                else if (hfId.Value != "")
                {
                    int id = Convert.ToInt32(hfId.Value);
                    pro.ProId = id;
                    List <Model.Product> list = ProductBll.GetProductbyId(id);
                    if (list.Count > 0)
                    {
                        pro.ProTypeId = list[0].ProTypeId;
                        try
                        {
                            ProductBll.UpdateProduct(pro);
                            MessageBox.AlertAndRedirect("修改成功!", "Product.aspx?typeId=" + pro.ProTypeId, Page);
                        }
                        catch (Exception)
                        {
                            MessageBox.Alert("修改失败!", Page);
                            /*throw;*/
                        }
                    }
                }
            }
        }
예제 #33
0
 partial void DeleteProduct(Product instance);
예제 #34
0
 /// <summary>
 /// The create product element.
 /// </summary>
 /// <param name="product">
 /// The product.
 /// </param>
 /// <returns>
 /// The <see cref="XElement"/>.
 /// </returns>
 private static XElement CreateProductElement(Product product)
 {
     var productElement = new XElement("product");
     productElement.Add(new XAttribute("id", product.Id));
     productElement.Add(new XElement("productName", product.Name));
     productElement.Add(new XElement("productDescription", product.Description));
     foreach (var version in product.Versions)
     {
         var versionEl = new XElement("version");
         versionEl.Add("versionNumber",version.VersionNumber);
         foreach (var feature in version.Features)
         {
             versionEl.Add("featureName",feature.Name);
             versionEl.Add("featureDescription",feature.Description);
         }
        productElement.Add(versionEl);
     }
     return productElement;
 }
예제 #35
0
		private void detach_Products(Product entity)
		{
			this.SendPropertyChanging();
			entity.Category = null;
		}
예제 #36
0
 /// <summary>
 /// 获得单个实体对象
 /// </summary>
 /// <param name="id">关键字</param>
 /// <returns>实体对象</returns>
 public Model.Product SelectModel(int id)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append(@"select [Id],[JK_Product_Name],[JK_Product_Type],[JK_Product_DateTime],[JK_Product_Type_Id],[JK_Product_Price],[JK_Product_Imgsrc],[JK_Product_Bewrite],[JK_Product_parameten_1],[JK_Product_parameten_2],[JK_Product_parameten_3],[JK_Product_parameten_4] from [Product] ");
     strSql.Append(@" where [Id]=@id ");
     SqlParameter[] parameters = {
             new SqlParameter("@id", SqlDbType.Int,4)};
     parameters[0].Value = id;
     Model.Product model = new Model.Product();
     DataTable dt = DAL.SqlDataHelper.GetDataTable(strSql.ToString(), parameters);
     if (dt.Rows.Count > 0)
     {
         LoadEntityData(ref model, dt.Rows[0]);
         return model;
     }
     else
     {
         return null;
     }
 }