Пример #1
0
 private ProductInfoEntity GetDataEntity()
 {
     /*
      * productInfoEntity = new ProductInfoEntity
      * {
      *  ProductCode = this.ProductCode.Text.Trim(),
      *  ProductName = this.ProductName.Text.Trim(),
      *  ProductCategory = BusinessLogic.ConvertToString(this.ProductCategory.SelectedValue),
      *  ProductModel = this.ProductModel.Text.Trim(),
      *  ProductStandard = this.ProductStandard.Text.Trim(),
      *  ProductUnit = this.ProductUnit.Text.Trim(),
      *  ProductDescription = this.ProductDescription.Text.Trim(),
      *  MiddleRate = BusinessLogic.ConvertToNullableDecimal(this.MiddleRate.Text),
      *  ReferenceCoefficient = BusinessLogic.ConvertToNullableDecimal(this.ReferenceCoefficient.Text),
      *  ProductPrice = BusinessLogic.ConvertToNullableDecimal(this.ProductPrice.Text),
      *  WholesalePrice = BusinessLogic.ConvertToNullableDecimal(this.WholesalePrice.Text),
      *  PromotionPrice = BusinessLogic.ConvertToNullableDecimal(this.PromotionPrice.Text),
      *  InternalPrice = BusinessLogic.ConvertToNullableDecimal(this.InternalPrice.Text),
      *  SpecialPrice = BusinessLogic.ConvertToNullableDecimal(this.SpecialPrice.Text),
      *  Description = this.Description.Text.Trim(),
      *  Enabled = Enabled.Checked ? 1:0
      * };
      */
     //新方法,一句话就搞定了
     productInfoEntity = new ProductInfoEntity();
     FormBinding.BindControlsToObject(productInfoEntity, this);
     return(productInfoEntity);
 }
Пример #2
0
        private void BindEditData()
        {
            currentProductInfoEntity = new ProductInfoManager(dbProvider).GetEntity(this.EntityId);
            if (currentProductInfoEntity == null || string.IsNullOrEmpty(currentProductInfoEntity.ProductName))
            {
                return;
            }
            //新方法,一句话就搞定了
            FormBinding.BindObjectToControls(currentProductInfoEntity, this);

            /*
             * //General Information 常规信息
             * this.ProductCode.Text = currentProductInfoEntity.ProductCode;
             * this.ProductName.Text = currentProductInfoEntity.ProductName;
             * this.ProductCategory.SelectedValue = currentProductInfoEntity.ProductCategory;
             * this.ProductModel.Text = currentProductInfoEntity.ProductModel;
             * this.ProductStandard.Text = currentProductInfoEntity.ProductStandard;
             * this.ProductUnit.Text = currentProductInfoEntity.ProductUnit;
             * this.ProductDescription.Text = currentProductInfoEntity.ProductDescription;
             *
             * //价格信息
             * this.MiddleRate.Text = currentProductInfoEntity.MiddleRate.ToString();
             * this.ReferenceCoefficient.Text = currentProductInfoEntity.ReferenceCoefficient.ToString();
             * this.ProductPrice.Text = currentProductInfoEntity.ProductPrice.ToString();
             * this.WholesalePrice.Text = currentProductInfoEntity.WholesalePrice.ToString();
             * this.PromotionPrice.Text = currentProductInfoEntity.PromotionPrice.ToString();
             * this.InternalPrice.Text = currentProductInfoEntity.InternalPrice.ToString();
             * this.SpecialPrice.Text = currentProductInfoEntity.SpecialPrice.ToString();
             *
             * //功能描述
             * this.Description.Text = currentProductInfoEntity.Description;
             * this.Enabled.Checked = BusinessLogic.ConvertIntToBoolean(currentProductInfoEntity.Enabled);
             */
        }
Пример #3
0
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="productInfoEntity">实体</param>
        public int UpdateEntity(ProductInfoEntity productInfoEntity)
        {
            var sqlBuilder = new SQLBuilder(DBProvider);

            sqlBuilder.BeginUpdate(this.CurrentTableName);
            this.SetEntity(sqlBuilder, productInfoEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(ProductInfoTable.FieldModifiedBy, UserInfo.RealName);
                sqlBuilder.SetValue(ProductInfoTable.FieldModifiedUserId, UserInfo.Id);
            }
            sqlBuilder.SetDBNow(ProductInfoTable.FieldModifiedOn);
            sqlBuilder.SetWhere(ProductInfoTable.FieldId, productInfoEntity.Id);
            return(sqlBuilder.EndUpdate());
        }
Пример #4
0
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="productInfoEntity">实体</param>
 private void SetEntity(SQLBuilder sqlBuilder, ProductInfoEntity productInfoEntity)
 {
     sqlBuilder.SetValue(ProductInfoTable.FieldProductCode, productInfoEntity.ProductCode);
     sqlBuilder.SetValue(ProductInfoTable.FieldProductName, productInfoEntity.ProductName);
     sqlBuilder.SetValue(ProductInfoTable.FieldProductModel, productInfoEntity.ProductModel);
     sqlBuilder.SetValue(ProductInfoTable.FieldProductStandard, productInfoEntity.ProductStandard);
     sqlBuilder.SetValue(ProductInfoTable.FieldProductCategory, productInfoEntity.ProductCategory);
     sqlBuilder.SetValue(ProductInfoTable.FieldProductUnit, productInfoEntity.ProductUnit);
     sqlBuilder.SetValue(ProductInfoTable.FieldProductDescription, productInfoEntity.ProductDescription);
     sqlBuilder.SetValue(ProductInfoTable.FieldMiddleRate, productInfoEntity.MiddleRate);
     sqlBuilder.SetValue(ProductInfoTable.FieldReferenceCoefficient, productInfoEntity.ReferenceCoefficient);
     sqlBuilder.SetValue(ProductInfoTable.FieldProductPrice, productInfoEntity.ProductPrice);
     sqlBuilder.SetValue(ProductInfoTable.FieldWholesalePrice, productInfoEntity.WholesalePrice);
     sqlBuilder.SetValue(ProductInfoTable.FieldPromotionPrice, productInfoEntity.PromotionPrice);
     sqlBuilder.SetValue(ProductInfoTable.FieldInternalPrice, productInfoEntity.InternalPrice);
     sqlBuilder.SetValue(ProductInfoTable.FieldSpecialPrice, productInfoEntity.SpecialPrice);
     sqlBuilder.SetValue(ProductInfoTable.FieldEnabled, productInfoEntity.Enabled);
     sqlBuilder.SetValue(ProductInfoTable.FieldDescription, productInfoEntity.Description);
     sqlBuilder.SetValue(ProductInfoTable.FieldDeleteMark, productInfoEntity.DeleteMark);
 }
Пример #5
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="productInfoEntity">实体</param>
        /// <param name="statusMessage">状态消息</param>
        public int Update(ProductInfoEntity productInfoEntity, out string statusMessage)
        {
            var returnValue = 0;
            var parameters  = new List <KeyValuePair <string, object> >
            {
                new KeyValuePair <string, object>(ProductInfoTable.FieldProductName, productInfoEntity.ProductName),
                new KeyValuePair <string, object>(ProductInfoTable.FieldProductCode, productInfoEntity.ProductCode),
                new KeyValuePair <string, object>(ProductInfoTable.FieldDeleteMark, 0)
            };

            // 检查用户名是否重复
            if (this.Exists(parameters, productInfoEntity.Id))
            {
                // 名称或编号已重复
                statusMessage = "名称或编号重复!";
            }
            else
            {
                returnValue   = this.UpdateEntity(productInfoEntity);
                statusMessage = returnValue == 0 ? "更新失败!" : "更新成功!";
            }

            return(returnValue);
        }
Пример #6
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="productInfoEntity">实体</param>
 /// <returns>主键</returns>
 public string Add(ProductInfoEntity productInfoEntity)
 {
     return(this.AddEntity(productInfoEntity));
 }
Пример #7
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="productInfoEntity">实体</param>
        public string AddEntity(ProductInfoEntity productInfoEntity)
        {
            var sequence = string.Empty;

            this.Identity = false;
            if (productInfoEntity.Id != null)
            {
                sequence = productInfoEntity.Id;
            }

            var sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, ProductInfoTable.FieldId);
            if (!this.Identity)
            {
                if (string.IsNullOrEmpty(productInfoEntity.Id))
                {
                    sequence             = BusinessLogic.NewGuid();
                    productInfoEntity.Id = sequence;
                }

                sqlBuilder.SetValue(ProductInfoTable.FieldId, productInfoEntity.Id);
            }
            else
            {
                if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(ProductInfoTable.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DBProvider.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(ProductInfoTable.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (string.IsNullOrEmpty(productInfoEntity.Id))
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                var sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            productInfoEntity.Id = sequence;
                        }
                        sqlBuilder.SetValue(ProductInfoTable.FieldId, productInfoEntity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, productInfoEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(ProductInfoTable.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(ProductInfoTable.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(ProductInfoTable.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(ProductInfoTable.FieldModifiedBy, UserInfo.RealName);
                sqlBuilder.SetValue(ProductInfoTable.FieldModifiedUserId, UserInfo.Id);
            }
            sqlBuilder.SetDBNow(ProductInfoTable.FieldModifiedOn);
            if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString(CultureInfo.InvariantCulture);
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
Пример #8
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="productInfoEntity">实体</param>
 /// <param name="identity">自增量方式</param>
 /// <param name="returnId">返回主键</param>
 /// <returns>主键</returns>
 public string Add(ProductInfoEntity productInfoEntity, bool identity, bool returnId)
 {
     this.Identity = identity;
     this.ReturnId = returnId;
     return(this.AddEntity(productInfoEntity));
 }