/// <summary>
        /// 取消订单(1待确认,2确认,3待发货,4发货,5收货(交易成功),11退货,12取消)
        /// </summary>
        /// <param name="scode">货号</param>
        /// <param name="localBanlace">本次购买数量</param>
        /// <param name="o">实体连接</param>
        /// <returns></returns>
        public string minusBanlace(string scode, int localBanlace, object o)
        {
            string s = string.Empty;

            try
            {
                model.pbxdatasourceDataContext context = (model.pbxdatasourceDataContext)o;
                model.product MdProduct = (from c in context.product where c.Scode == scode select c).FirstOrDefault();

                if (MdProduct != null && MdProduct.Def3 > 0)
                {
                    MdProduct.Scode = scode;
                    MdProduct.Def3  = MdProduct.Def3 - localBanlace;

                    context.SubmitChanges();
                    s = "减去销售数量成功";
                }
                else
                {
                    s = "减去销售数量失败";
                }
            }
            catch (Exception ex)
            {
                s = "减去销售数量失败" + (ex.Message);
            }
            return(s);
        }
        /// <summary>
        /// 根据货号查询商品
        /// </summary>
        /// <param name="scode"></param>
        /// <returns></returns>
        public model.product getProductScode(string scode)
        {
            model.pbxdatasourceDataContext context = new model.pbxdatasourceDataContext();
            model.product MdProduct = (from c in context.product where c.Scode == scode select c).FirstOrDefault();

            return(MdProduct);
        }
Exemple #3
0
        /// <summary>
        /// 根据货号返回已售库存(库存查product表)
        /// </summary>
        /// <param name="scode"></param>
        /// <returns></returns>
        public int getScodeBalanceSales(string scode)
        {
            pbxdatasourceDataContext context = new pbxdatasourceDataContext();

            model.product p = (from c in context.product where c.Scode == scode select c).SingleOrDefault();
            int           i = p == null ? 0 : int.Parse(p.Def3.ToString());

            return(i);
        }
 /// <summary>
 /// 更新商品信息
 /// </summary>
 /// <returns></returns>
 public bool UpdateProduct(model.product mm, string a, string b, string PropertyId, int UserId)
 {
     return(dal.UpdateProduct(mm, a, b, PropertyId, UserId));
 }
        /// <summary>
        /// 将打datatable转换为list集合
        /// </summary>
        /// <param name="dataRow">datatable rows</param>
        /// <returns></returns>
        private List <model.product> DataTableToList(DataRowCollection dataRow)
        {
            List <model.product> list = new List <model.product>();

            foreach (DataRow row in dataRow)
            {
                model.product pro = new model.product();
                if (row["Id"] != null)
                {
                    pro.Id = int.Parse(row["Id"].ToString());
                }
                if (row["Scode"] != null)
                {
                    pro.Scode = row["Scode"].ToString();
                }
                if (row["Bcode"] != null)
                {
                    pro.Bcode = row["Bcode"].ToString();
                }
                if (row["Bcode2"] != null)
                {
                    pro.Bcode2 = row["Bcode2"].ToString();
                }
                if (row["Descript"] != null)
                {
                    pro.Descript = row["Descript"].ToString();
                }
                if (row["Cdescript"] != null)
                {
                    pro.Cdescript = row["Cdescript"].ToString();
                }
                if (row["Unit"] != null)
                {
                    pro.Unit = row["Unit"].ToString();
                }
                if (row["Currency"] != null)
                {
                    pro.Currency = row["Currency"].ToString();
                }
                if (row["Cat"] != null)
                {
                    pro.Cat = row["Cat"].ToString();
                }
                if (row["Cat1"] != null)
                {
                    pro.Cat1 = row["Cat1"].ToString();
                }
                if (row["Cat2"] != null)
                {
                    pro.Cat2 = row["Cat2"].ToString();
                }
                if (row["Clolor"] != null)
                {
                    pro.Clolor = row["Clolor"].ToString();
                }
                if (row["Size"] != null)
                {
                    pro.Size = row["Size"].ToString();
                }
                if (row["Style"] != null)
                {
                    pro.Style = row["Style"].ToString();
                }
                if (row["Pricea"] != null)
                {
                    pro.Pricea = decimal.Parse(row["Pricea"].ToString());
                }
                if (row["Priceb"] != null)
                {
                    pro.Priceb = decimal.Parse(row["Priceb"].ToString());
                }
                if (row["Pricec"] != null)
                {
                    pro.Pricec = decimal.Parse(row["Pricec"].ToString());
                }
                if (row["Priced"] != null)
                {
                    pro.Priced = decimal.Parse(row["Priced"].ToString());
                }
                if (row["Pricee"] != null)
                {
                    pro.Pricee = decimal.Parse(row["Pricee"].ToString());
                }
                if (row["Disca"] != null)
                {
                    pro.Disca = decimal.Parse(row["Disca"].ToString());
                }
                if (row["Discb"] != null)
                {
                    pro.Discb = decimal.Parse(row["Discb"].ToString());
                }
                if (row["Discc"] != null)
                {
                    pro.Discc = decimal.Parse(row["Discc"].ToString());
                }
                if (row["Discd"] != null)
                {
                    pro.Discd = decimal.Parse(row["Discd"].ToString());
                }
                if (row["Disce"] != null)
                {
                    pro.Disce = decimal.Parse(row["Disce"].ToString());
                }
                if (row["Vencode"] != null)
                {
                    pro.Vencode = row["Vencode"].ToString();
                }
                if (row["Model"] != null)
                {
                    pro.Model = row["Model"].ToString();
                }
                if (row["Rolevel"] != null)
                {
                    pro.Rolevel = int.Parse(row["Rolevel"].ToString());
                }
                if (row["Roamt"] != null)
                {
                    pro.Roamt = int.Parse(row["Roamt"].ToString());
                }
                if (row["Stopsales"] != null)
                {
                    pro.Stopsales = int.Parse(row["Stopsales"].ToString());
                }
                if (row["Loc"] != null)
                {
                    pro.Loc = row["Loc"].ToString();
                }
                if (row["Balance"] != null)
                {
                    pro.Balance = int.Parse(row["Balance"].ToString());
                }
                if (row["Lastgrnd"] != null)
                {
                    string datae = row["Lastgrnd"].ToString();
                    //pro.Lastgrnd = DateTime.Parse(row["Lastgrnd"].ToString());
                    pro.Lastgrnd = GetDateTimeParms(datae);
                }
                //if (row["Imagefile"] != null && typeof(System.DBNull) != row["Imagefile"].GetType())
                //{
                //    pro.Imagefile = (byte[])row["Imagefile"];
                //}
                if (row["Imagefile"] != null)
                {
                    pro.Imagefile = "";
                }
                if (row["Def1"] != null)
                {
                    pro.Def1 = row["Def1"].ToString();
                }
                if (row["Def2"] != null)
                {
                    pro.Def2 = row["Def2"].ToString();
                }
                if (row["Def3"] != null)
                {
                    pro.Def3 = int.Parse(row["Def3"].ToString());
                }
                if (row["ciqProductId"] != null)
                {
                    pro.ciqProductId = row["ciqProductId"].ToString();
                }
                if (row["ciqSpec"] != null)
                {
                    pro.ciqSpec = row["ciqSpec"].ToString();
                }
                if (row["ciqHSNo"] != null)
                {
                    pro.ciqHSNo = row["ciqHSNo"].ToString();
                }
                if (row["ciqAssemCountry"] != null)
                {
                    pro.ciqAssemCountry = row["ciqAssemCountry"].ToString();
                }
                if (row["ciqProductNo"] != null)
                {
                    pro.ciqProductNo = Convert.ToInt32(row["ciqProductNo"].ToString());
                }
                if (row["Def9"] != null)
                {
                    pro.Def9 = row["Def9"].ToString();
                }
                if (row["Def10"] != null)
                {
                    pro.Def10 = row["Def10"].ToString();
                }
                if (row["Def11"] != null)
                {
                    pro.Def11 = row["Def11"].ToString();
                }
                list.Add(pro);
            }
            return(list);
        }
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="Id">商品id</param>
        /// <returns></returns>
        public bool UpdateProduct(model.product mm, string AttrId, string ComAttrvalues, string PropertyId, int UserId)
        {
            try
            {
                IDataParameter[] pro = new IDataParameter[] {
                    new SqlParameter("Cdescript", mm.Cdescript),
                    new SqlParameter("Cat1", mm.Cat1),
                    new SqlParameter("Cat2", mm.Cat2),
                    new SqlParameter("Rolevel", mm.Rolevel),
                    new SqlParameter("Scode", mm.Scode),
                    new SqlParameter("ciqProductId", mm.ciqProductId),
                    new SqlParameter("ciqSpec", mm.ciqSpec),
                    new SqlParameter("ciqHSNo", mm.ciqHSNo),
                    new SqlParameter("ciqAssemCountry", mm.ciqAssemCountry),
                    new SqlParameter("Def9", mm.Def9),
                    new SqlParameter("Def10", mm.Def10),
                    new SqlParameter("sql", ""),
                    new SqlParameter("Imagefile", mm.Imagefile),
                    new SqlParameter("QtyUnit", mm.QtyUnit),
                    new SqlParameter("Def15", mm.Def15),
                    new SqlParameter("Def16", mm.Def16),
                };
                string n = Update(pro, "UpdateProductinfo");//根据货号更新product表的信息

                Dictionary <string, string> dic = new Dictionary <string, string>();
                if (AttrId != "")
                {
                    string[] ArryComAttrvalues, ArryAttrId, ArryPropertyId;
                    ArryAttrId        = AttrId.Split(',');
                    ArryComAttrvalues = ComAttrvalues.Split(',');
                    ArryPropertyId    = PropertyId.Split(',');
                    for (int i = 0; i < ArryAttrId.Length; i++)
                    {
                        string check = @"select * from productPorpertyValue where Id='" + ArryAttrId[i] + "' "; //判断该属性是否存在

                        if (DbHelperSQL.Query(check).Tables[0].Rows.Count == 0)                                 //不存在则根据货号以及类别添加属性以及属性值 存在则跟新属性值
                        {
                            IDataParameter[] pro1 = new IDataParameter[] {
                                new SqlParameter("Cat2", mm.Cat2),
                                new SqlParameter("PropertyId ", ArryPropertyId[i]),
                                new SqlParameter("Scode", mm.Scode),
                                new SqlParameter("PropertyValue", ArryComAttrvalues[i]),
                                new SqlParameter("PropertyIndex", "1"),
                                new SqlParameter("UserId", UserId),
                            };
                            string m = Add(pro1, "InsertPropertyValue");
                        }
                        else
                        {
                            IDataParameter[] pro1 = new IDataParameter[] {
                                new SqlParameter("PropertyValue", ArryComAttrvalues[i]),
                                new SqlParameter("Id", ArryAttrId[i]),
                                new SqlParameter("sql", ""),
                            };
                            string m = Update(pro1, "UpdatePropertyValue");
                        }
                    }
                }
                dal.InsertErrorlog(new model.errorlog()
                {
                    errorSrc        = "pbxdata.dal->AttributeDal->UpdateProduct()",
                    ErrorMsg        = "修改",
                    errorTime       = DateTime.Now,
                    operation       = 2,
                    errorMsgDetails = "通过货号修改商品信息->" + mm.Scode,
                    UserId          = UserId,
                });
                return(true);
            }
            catch (Exception ex)
            {
                dal.InsertErrorlog(new model.errorlog()
                {
                    errorSrc        = "pbxdata.dal->AttributeDal->UpdateProduct()",
                    ErrorMsg        = "修改",
                    errorTime       = DateTime.Now,
                    operation       = 1,
                    errorMsgDetails = ex.Message,
                    UserId          = UserId,
                });
                return(false);
            }
        }