Example #1
0
        //        /// <summary>
        //        /// ȡ��������Ʒ���е�����
        //        /// </summary>
        //        /// <param name="paramProductSysNo"></param>
        //        /// <returns></returns>
        //        public SortedList GetProductAttributes(int paramProductSysNo)
        //        {
        //            string sql = @"select ca.attributeid,ca.attributename,ca.ordernum,ca.status,ca.attributetype,ca.sysno
        //                          from category_attribute ca
        //                          inner join product p on p.c3sysno = ca.c3sysno
        //                          where ca.status=0 and p.sysno = "+paramProductSysNo
        //                +@"; select *
        //                          from product_attribute
        //                          where productsysno = "+paramProductSysNo;
        //            DataSet ds = SqlHelper.ExecuteDataSet(sql);
        //            DataTable TName = ds.Tables[0];
        //            DataTable TValue = ds.Tables[1];
        //            SortedList st = new SortedList();
        //            if(!Util.HasMoreRow(TName))
        //                return st;
        //
        //            foreach(DataRow dr in TName.Rows)
        //            {
        //                AttributeInfo ai = new AttributeInfo();
        //                ai.SysNo = (int)dr["sysno"];
        //                ai.AttributeId = dr["attributeid"].ToString();
        //                ai.AttributeName = dr["attributename"].ToString();
        //                ai.OrderNum = (int)dr["ordernum"];
        //                ai.Status = (int)dr["status"];
        //                ai.AttributeType = dr["attributetype"].ToString();
        //                if ( Util.HasMoreRow(TValue))
        //                {
        //                    ai.AttributeValue = ds.Tables[1].Rows[0][ai.AttributeId].ToString();
        //                }
        //                st.Add(ai,null);
        //            }
        //            return st;
        //        }
        /// <summary>
        /// ������Ʒ����
        /// </summary>
        /// <param name="oParam"></param>
        public void UpdateAttributeInfo(ProductAttributeInfo oParam)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                ProductAttributeDac pa = new ProductAttributeDac();
                //pa.Update(oParam);
                pa.Update2(oParam);
                scope.Complete();
            }
        }
Example #2
0
        /// <summary>
        /// ������Ʒ����
        /// </summary>
        /// <param name="oParam"></param>
        public void UpdateAttribute2(int paramProductSysNo, Hashtable htText, Hashtable htOption)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {

                Hashtable ht_Old = GetProductAttribute2Value(paramProductSysNo);
                ProductAttributeDac pa = new ProductAttributeDac();

                foreach (string key in htText.Keys)
                {
                    ProductAttribute2Info oParam = new ProductAttribute2Info();
                    oParam.ProductSysNo = paramProductSysNo;
                    oParam.Attribute2SysNo = int.Parse(key);
                    oParam.Attribute2Value = htText[key].ToString();
                    oParam.Attribute2OptionSysNo = 0;  //default value is 0

                    if (ht_Old != null && ht_Old.Count > 0 && ht_Old.ContainsKey(key))
                    {
                        pa.Update(oParam);
                    }
                    else
                    {
                        pa.Insert(oParam);
                    }
                }

                foreach (string key in htOption.Keys)
                {
                    ProductAttribute2Info oParam = new ProductAttribute2Info();
                    oParam.ProductSysNo = paramProductSysNo;
                    oParam.Attribute2SysNo = int.Parse(key);
                    oParam.Attribute2OptionSysNo = int.Parse(htOption[key].ToString());
                    oParam.Attribute2Value = ""; // default value is ""

                    if (ht_Old != null && ht_Old.Count > 0 && ht_Old.ContainsKey(key))
                    {
                        pa.Update(oParam);
                    }
                    else
                    {
                        pa.Insert(oParam);
                    }
                }

                if (ht_Old != null && ht_Old.Count > 0)
                {
                    foreach (string key in ht_Old.Keys)
                    {
                        if (!htText.ContainsKey(key) && !htOption.ContainsKey(key))
                        {
                            pa.DeleteProductAttribute2(paramProductSysNo, Util.TrimIntNull(key));
                        }
                    }
                }

                scope.Complete();
            }
        }