Exemple #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);
 }
Exemple #2
0
        /// <summary>
        /// 保存修改的数据
        /// </summary>
        /// <returns></returns>
        private bool SaveEditData()
        {
            // 设置鼠标繁忙状态,并保留原先的状态
            Cursor holdCursor = this.Cursor;

            this.Cursor = Cursors.WaitCursor;
            bool returnValue = false;

            //新方法,一句话就搞定了
            FormBinding.BindControlsToObject(currentProductInfoEntity, this);

            /*
             * currentProductInfoEntity.ProductCode = this.ProductCode.Text.Trim();
             * currentProductInfoEntity.ProductName = this.ProductName.Text.Trim();
             * currentProductInfoEntity.ProductCategory = BusinessLogic.ConvertToString(this.ProductCategory.SelectedValue);
             * currentProductInfoEntity.ProductModel = this.ProductModel.Text.Trim();
             * currentProductInfoEntity.ProductStandard = this.ProductStandard.Text.Trim();
             * currentProductInfoEntity.ProductUnit = this.ProductUnit.Text.Trim();
             * currentProductInfoEntity.ProductDescription = this.ProductDescription.Text.Trim();
             * currentProductInfoEntity.MiddleRate = BusinessLogic.ConvertToNullableDecimal(this.MiddleRate.Text);
             * currentProductInfoEntity.ReferenceCoefficient = BusinessLogic.ConvertToNullableDecimal(this.ReferenceCoefficient.Text);
             * currentProductInfoEntity.ProductPrice = BusinessLogic.ConvertToNullableDecimal(this.ProductPrice.Text);
             * currentProductInfoEntity.WholesalePrice = BusinessLogic.ConvertToNullableDecimal(this.WholesalePrice.Text);
             * currentProductInfoEntity.PromotionPrice = BusinessLogic.ConvertToNullableDecimal(this.PromotionPrice.Text);
             * currentProductInfoEntity.InternalPrice = BusinessLogic.ConvertToNullableDecimal(this.InternalPrice.Text);
             * currentProductInfoEntity.SpecialPrice = BusinessLogic.ConvertToNullableDecimal(this.SpecialPrice.Text);
             * currentProductInfoEntity.Description = this.Description.Text.Trim();
             * currentProductInfoEntity.Enabled = Enabled.Checked ? 1: 0;
             */
            string statusMessage = string.Empty;

            returnValue = new ProductInfoManager(dbProvider, this.UserInfo).Update(currentProductInfoEntity, out statusMessage) > 0;
            if (returnValue)
            {
                this.Changed = true;
                MessageBoxHelper.ShowSuccessMsg(statusMessage);
            }
            else
            {
                MessageBoxHelper.ShowWarningMsg(statusMessage);
            }


            // 设置鼠标默认状态,原来的光标状态
            this.Cursor = holdCursor;
            return(returnValue);
        }
 private void btnControlToEntity_Click(object sender, EventArgs e)
 {
     FormBinding.BindControlsToObject(TestEntity, this);
     this.richTextBox1.Text = TestEntity.ToString();
 }