protected void btnAdd_Click(object sender, EventArgs e) { ContractAssociated contractAssociated = new ContractAssociated(); contractAssociated.CompanyId = Company.CompanyId; if (ucDtPaidDate.DateTime.HasValue) { contractAssociated.PaidDate = ucDtPaidDate.DateTime.Value; } if (ucDtDueDate.DateTime.HasValue) { contractAssociated.DueDate = ucDtDueDate.DateTime.Value.Date; } if (ucCUrrFieldContractValue.CurrencyValue.HasValue) { contractAssociated.Amount = ucCUrrFieldContractValue.CurrencyValue.Value; } if (!String.IsNullOrEmpty(cboCustomerContracts.SelectedValue)) { contractAssociated.ContractId = Convert.ToInt32(cboCustomerContracts.SelectedValue); cboCustomerContracts.Items.Remove(cboCustomerContracts.SelectedItem); } ContractsAssociated.Add(contractAssociated); BindContractsAssociated(); }
/// <summary> /// this functions show a contract /// </summary> private void ShowContract() { contractManager = new ContractManager(this); contract = contractManager.GetContract(Company.CompanyId, Convert.ToInt32(Page.ViewState["ContractId"])); Parcel parcel; ParcelsManager parcelsManager = new ParcelsManager(this); cboContractTemplate.Attributes["onchange"] = "location='ContractTemplateBuilder.aspx?ContractId=" + contract.ContractId + "&ContractTemplateId='+this.value"; // // if exists invoice then show gridview else show parcel fields // if (contract.InvoiceId.HasValue && contract.Invoice.Parcels.Any()) { parcel = contract.Invoice.Parcels.FirstOrDefault(); if (parcel != null) { lnkParcelValue.Text = "Valor da parcelas: " + parcel.Amount.ToString(); lnkParcelValue.NavigateUrl = "Invoice.aspx?InvoiceId=" + parcel.InvoiceId; } } contractId = contract.ContractId; SelCustomer.ShowCustomer(contract.Customer); ucdtIntervalContract.DateInterval = new DateTimeInterval(contract.BeginDate, contract.ExpiresDate); txtObservation.Text = contract.Observation; ucHH.CurrencyValue = contract.HH; if (contract.InterestDeferredPayment.HasValue) txtInterestDeferredPayment.Text = contract.InterestDeferredPayment.ToString(); ucContractValue.CurrencyValue = contract.ContractValue; ucContractAdditionalValue1.CurrencyValue = contract.AdditionalValue1; ucContractAdditionalValue2.CurrencyValue = contract.AdditionalValue2; ucContractAdditionalValue3.CurrencyValue = contract.AdditionalValue3; ucContractAdditionalValue4.CurrencyValue = contract.AdditionalValue4; ucContractAdditionalValue5.CurrencyValue = contract.AdditionalValue5; ucMonthlyFee.CurrencyValue = contract.MonthlyFee; ucInsurance.CurrencyValue = contract.Insurance; ucMoneyReserves.CurrencyValue = contract.MoneyReserves; ShowAdditionalValues(); ucPenalty.CurrencyValue = contract.Penalty; if (contract.EmployeeId.HasValue) cboVendors.SelectedValue = contract.EmployeeId.ToString(); if (contract.RepresentantId.HasValue) cboRepresentants.SelectedValue = contract.RepresentantId.ToString(); txtContractNumber.Text = contract.ContractNumber; cboContractType.DataBind(); cboContractType.SelectedValue = contract.ContractTypeId.ToString(); cboContractStatus.DataBind(); cboContractStatus.SelectedValue = contract.ContractStatusId.ToString(); if (contract.FinancierOperationId.HasValue) { cboPaymentMethods.DataBind(); cboPaymentMethods.SelectedValue = contract.FinancierOperationId.ToString(); } if (contract.Parcels.HasValue) { cboParcels.DataBind(); ListItem item = cboParcels.Items.FindByText(contract.Parcels.ToString()); if (item != null) cboParcels.Items.FindByValue(item.Value).Selected = true; } ucParcelDueDate.DateTime = contract.FirstParcelDueDate; ContractAssociated newContractAssociated; foreach (ContractAssociated item in contract.ContractAssociateds) { newContractAssociated = new ContractAssociated(); newContractAssociated.CopyPropertiesFrom(item); ContractsAssociated.Add(newContractAssociated); } BindContractsAssociated(); ShowParcelValue(); }
protected void btnAdd_Click(object sender, EventArgs e) { ContractAssociated contractAssociated = new ContractAssociated(); contractAssociated.CompanyId = Company.CompanyId; if (ucDtPaidDate.DateTime.HasValue) contractAssociated.PaidDate = ucDtPaidDate.DateTime.Value; if (ucDtDueDate.DateTime.HasValue) contractAssociated.DueDate = ucDtDueDate.DateTime.Value.Date; if (ucCUrrFieldContractValue.CurrencyValue.HasValue) contractAssociated.Amount = ucCUrrFieldContractValue.CurrencyValue.Value; if (!String.IsNullOrEmpty(cboCustomerContracts.SelectedValue)) { contractAssociated.ContractId = Convert.ToInt32(cboCustomerContracts.SelectedValue); cboCustomerContracts.Items.Remove(cboCustomerContracts.SelectedItem); } ContractsAssociated.Add(contractAssociated); BindContractsAssociated(); }
/// <summary> /// this method inserts an AssociatedContract /// </summary> /// <param name="entity"></param> public void InsertAssociatedContract(ContractAssociated entity) { DbContext.ContractAssociateds.InsertOnSubmit(entity); DbContext.SubmitChanges(); }
/// <summary> /// this method deletes ContractAssociated /// </summary> /// <param name="entity"></param> public void DeleteAssociatedContract(ContractAssociated entity) { DbContext.ContractAssociateds.Attach(entity); DbContext.ContractAssociateds.DeleteOnSubmit(entity); DbContext.SubmitChanges(); }
/// <summary> /// this functions show a contract /// </summary> private void ShowContract() { contractManager = new ContractManager(this); contract = contractManager.GetContract(Company.CompanyId, Convert.ToInt32(Page.ViewState["ContractId"])); Parcel parcel; ParcelsManager parcelsManager = new ParcelsManager(this); cboContractTemplate.Attributes["onchange"] = "location='ContractTemplateBuilder.aspx?ContractId=" + contract.ContractId + "&ContractTemplateId='+this.value"; // // if exists invoice then show gridview else show parcel fields // if (contract.InvoiceId.HasValue && contract.Invoice.Parcels.Any()) { parcel = contract.Invoice.Parcels.FirstOrDefault(); if (parcel != null) { lnkParcelValue.Text = "Valor da parcelas: " + parcel.Amount.ToString(); lnkParcelValue.NavigateUrl = "Invoice.aspx?InvoiceId=" + parcel.InvoiceId; } } contractId = contract.ContractId; SelCustomer.ShowCustomer(contract.Customer); ucdtIntervalContract.DateInterval = new DateTimeInterval(contract.BeginDate, contract.ExpiresDate); txtObservation.Text = contract.Observation; ucHH.CurrencyValue = contract.HH; if (contract.InterestDeferredPayment.HasValue) { txtInterestDeferredPayment.Text = contract.InterestDeferredPayment.ToString(); } ucContractValue.CurrencyValue = contract.ContractValue; ucContractAdditionalValue1.CurrencyValue = contract.AdditionalValue1; ucContractAdditionalValue2.CurrencyValue = contract.AdditionalValue2; ucContractAdditionalValue3.CurrencyValue = contract.AdditionalValue3; ucContractAdditionalValue4.CurrencyValue = contract.AdditionalValue4; ucContractAdditionalValue5.CurrencyValue = contract.AdditionalValue5; ucMonthlyFee.CurrencyValue = contract.MonthlyFee; ucInsurance.CurrencyValue = contract.Insurance; ucMoneyReserves.CurrencyValue = contract.MoneyReserves; ShowAdditionalValues(); ucPenalty.CurrencyValue = contract.Penalty; if (contract.EmployeeId.HasValue) { cboVendors.SelectedValue = contract.EmployeeId.ToString(); } if (contract.RepresentantId.HasValue) { cboRepresentants.SelectedValue = contract.RepresentantId.ToString(); } txtContractNumber.Text = contract.ContractNumber; cboContractType.DataBind(); cboContractType.SelectedValue = contract.ContractTypeId.ToString(); cboContractStatus.DataBind(); cboContractStatus.SelectedValue = contract.ContractStatusId.ToString(); if (contract.FinancierOperationId.HasValue) { cboPaymentMethods.DataBind(); cboPaymentMethods.SelectedValue = contract.FinancierOperationId.ToString(); } if (contract.Parcels.HasValue) { cboParcels.DataBind(); ListItem item = cboParcels.Items.FindByText(contract.Parcels.ToString()); if (item != null) { cboParcels.Items.FindByValue(item.Value).Selected = true; } } ucParcelDueDate.DateTime = contract.FirstParcelDueDate; ContractAssociated newContractAssociated; foreach (ContractAssociated item in contract.ContractAssociateds) { newContractAssociated = new ContractAssociated(); newContractAssociated.CopyPropertiesFrom(item); ContractsAssociated.Add(newContractAssociated); } BindContractsAssociated(); ShowParcelValue(); }