示例#1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (PurchaseRequestItems.Count == 0)
            {
                ShowError(Exception.AddProductInList);
                return;
            }

            if (String.IsNullOrEmpty(Address1.PostalCode))
            {
                ShowError("O local de entrega é obrigatório!");
                return;
            }

            _pRequest = new DataClasses.PurchaseRequest
            {
                EmployeeId        = Employee.EmployeeId,
                CostCenterId      = Convert.ToInt32(cboTreeBoxCostCenter.SelectedValue),
                CompanyId         = Company.CompanyId,
                PostalCode        = Address1.PostalCode,
                AddressComp       = Address1.AddressComp,
                AddressNumber     = Address1.AddressNumber,
                PurchaseRequestId = _purchaseRequestId
            };

            if (ViewState["compositeProductId"] != null)
            {
                _pRequest.ProductId = Convert.ToInt32(ViewState["compositeProductId"]);
                _pRequest.Amount    = ucCurrFieldAmount.IntValue;
            }

            foreach (GridViewRow row in dtlPurchaseRequestItem.Rows)
            {
                CurrencyField textBox1 = row.FindControl <CurrencyField>("TextBox1") ?? new CurrencyField();
                PurchaseRequestItems[row.RowIndex].Amount -= textBox1.IntValue;
            }

            new PurchaseManager(this).SavePurchaseRequest(_pRequest, PurchaseRequestItems);

            Response.Redirect("PurchaseRequests.aspx");
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (PurchaseRequestItems.Count == 0)
            {
                ShowError(Exception.AddProductInList);
                return;
            }

            if (String.IsNullOrEmpty(Address1.PostalCode))
            {
                ShowError("O local de entrega é obrigatório!");
                return;
            }

            _pRequest = new DataClasses.PurchaseRequest
                        {
                            EmployeeId = Employee.EmployeeId,
                            CostCenterId = Convert.ToInt32(cboTreeBoxCostCenter.SelectedValue),
                            CompanyId = Company.CompanyId,
                            PostalCode = Address1.PostalCode,
                            AddressComp = Address1.AddressComp,
                            AddressNumber = Address1.AddressNumber,
                            PurchaseRequestId = _purchaseRequestId
                        };

            if (ViewState["compositeProductId"] != null)
            {
                _pRequest.ProductId = Convert.ToInt32(ViewState["compositeProductId"]);
                _pRequest.Amount = ucCurrFieldAmount.IntValue;
            }

            foreach (GridViewRow row in dtlPurchaseRequestItem.Rows)
            {
                CurrencyField textBox1 = row.FindControl<CurrencyField>("TextBox1") ?? new CurrencyField();
                PurchaseRequestItems[row.RowIndex].Amount -= textBox1.IntValue;
            }

            new PurchaseManager(this).SavePurchaseRequest(_pRequest, PurchaseRequestItems);

            Response.Redirect("PurchaseRequests.aspx");
        }