Exemple #1
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);
        }
Exemple #2
0
        private void SaveData(bool close)
        {
            // 设置鼠标繁忙状态,并保留原先的状态
            Cursor holdCursor = this.Cursor;

            this.Cursor = Cursors.WaitCursor;
            //读取产品实体数据
            this.GetDataEntity();

            if (new ProductInfoManager(dbProvider, this.UserInfo).Exists(new[] { ProductInfoTable.FieldProductCode, ProductInfoTable.FieldProductName, ProductInfoTable.FieldDeleteMark }
                                                                         , new object[] { productInfoEntity.ProductCode, productInfoEntity.ProductName, "0" }))
            {
                MessageBoxHelper.ShowWarningMsg("库中已经存在相同数据,请重新检查输入!");
                ProductName.Focus();
            }
            else
            {
                string returnValue = new ProductInfoManager(dbProvider, this.UserInfo).AddEntity(productInfoEntity);
                if (returnValue.Trim().Length > 0)
                {
                    this.Changed = true;
                    MessageBoxHelper.ShowSuccessMsg("新增成功!");
                }
                else
                {
                    MessageBoxHelper.ShowWarningMsg("新增数据失败!");
                }
            }

            // 设置鼠标默认状态,原来的光标状态
            this.Cursor = holdCursor;

            if (this.Changed && close)
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
                if (OnFormClosedRefreash != null)
                {
                    OnFormClosedRefreash();
                }
            }
        }