private void btnRick_Click(object sender, EventArgs e) { dlgSearchCustomer searhCustomer = new dlgSearchCustomer(); searhCustomer.Owner = this.ParentForm; searhCustomer.ShowDialog(); if (searhCustomer.Custno != "") { txtRiskCusId.Text = searhCustomer.CustId; txtPatnerNr.Text = searhCustomer.Custno; txtParnerName.Text = searhCustomer.CustName; txtRishLevel.Value = ContractFrm.objContract.RiskLevel; ContractCustomer RiskCustId = new ContractCustomer(); RiskCustId.Name = searhCustomer.CustName; int id; bool tmp = int.TryParse(searhCustomer.CustId, out id); if (tmp) { RiskCustId.CustId = id; } tmp = int.TryParse(searhCustomer.Custno, out id); if (tmp) { RiskCustId.CustNr = id; } ContractFrm.objContract.RiskCustId = RiskCustId; } }
public async Task ExecuteAsync(ContractCustomer contractCustomer) { var contractCustomerRepo = Uow.GetRepository <ContractCustomer>(); contractCustomerRepo.Update(contractCustomer); await Uow.SaveChangesAsync(); }
public Customer GetCustomer(Customer newCustomer) { Customer customer = new Customer(); string cs = ConfigurationManager.ConnectionStrings["CRCS"].ConnectionString; using (SqlConnection con = new SqlConnection(cs)) { SqlCommand cmd = new SqlCommand("spGetCustomer", con); cmd.CommandType = CommandType.StoredProcedure; SqlParameter parameterId = new SqlParameter(); parameterId.ParameterName = "@Id"; parameterId.Value = newCustomer.Id; cmd.Parameters.Add(parameterId); try { con.Open(); SqlDataReader reader = cmd.ExecuteReader(); bool isExist = false; while (reader.Read()) { isExist = true; if ((CustomerType)reader["CustomerType"] == CustomerType.PayAsGoCustomer) { customer = new PayAsGoCustomer { CustomerType = CustomerType.PayAsGoCustomer }; } else { customer = new ContractCustomer { CustomerType = CustomerType.ContractCustomer, Discount = Convert.ToDecimal(reader["Discount"]) }; } customer.Id = Convert.ToInt32(reader["Id"]); customer.FirstName = reader["FirstName"].ToString(); customer.LastName = reader["LastName"].ToString(); customer.Mobile = reader["Mobile"].ToString(); customer.Email = reader["Email"].ToString(); } if (!isExist) { throw new FaultException("Customer id " + newCustomer.Id.ToString() + " does not exist"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } return(customer); }
public async Task <int> ExecuteAsync(ContractCustomer contractCustomer) { var contractCustomerRepo = Uow.GetRepository <ContractCustomer>(); await contractCustomerRepo.CreateAsync(contractCustomer); await Uow.SaveChangesAsync(); return(contractCustomer.Id); }
public void loadCustomerEmployee() { //loadInVoiceAddress ContractCustomer ccInvoice = new ContractCustomer(); ccInvoice = objContract.InvoiceCustId; if (ccInvoice != null) { this.headerControl1.txtInvoiceCusNr.Text = ccInvoice.CustNr.ToString(); this.headerControl1.txtInvoiceCusName.Text = ccInvoice.Name; this.headerControl1.txtInvoiceCusAdd.Text = ccInvoice.Address; this.headerControl1.txtInvoiceCusEmail.Text = ccInvoice.Email; this.headerControl1.txtInvoiceCusPhone.Text = ccInvoice.Phone; } //load ContractCustomer ContractCustomer cc = new ContractCustomer(); cc = objContract.ContractCustId; if (cc != null) { this.headerControl1.txtContractCusNr.Text = cc.CustNr.ToString(); this.headerControl1.txtContractCusName.Text = cc.Name; this.headerControl1.txtContractCusAdd.Text = cc.Address; this.headerControl1.txtContractCusEmail.Text = cc.Email; this.headerControl1.txtContractCusPhone.Text = cc.Phone; } //load Responsible Employee ContractEmployee ces = new ContractEmployee(); ces = objContract.RespSmanId; if (ces != null) { this.headerControl1.txtEmployeeID1.Text = ces.SmanId.ToString(); this.headerControl1.txtEmployeeName1.Text = ces.Name; this.headerControl1.txtEmployeePhone1.Text = ces.Phone; this.headerControl1.txtEmployeeEmail1.Text = ces.Email; } //load Care taking Employee ContractEmployee cte = new ContractEmployee(); cte = objContract.CareSmanId; if (cte != null) { this.headerControl1.txtEmployeeID2.Text = cte.SmanId.ToString(); this.headerControl1.txtEmployeeName2.Text = cte.Name; this.headerControl1.txtEmployeePhone2.Text = cte.Phone; this.headerControl1.txtEmployeeEmail2.Text = cte.Email; } }
/// <summary> /// Получает идентификатор адресата для переписки по идентификатору договора. /// </summary> /// <param name="contractId">Идентификатор договора.</param> /// <returns>Идентификатор адресата для переписки.</returns> private async Task <int?> GetAddresseeIdByContractId(int contractId) { Contract contract = await Executor .GetQuery <GetContractByIdWithCustomersAndCustomerRolesQuery>() .Process(query => query.ExecuteAsync(contractId)); if (contract is null) { throw new DataNotFoundException(nameof(Contract), DataNotFoundException.OperationType.Read, contractId); } ContractCustomer addressee = contract.ContractCustomers .FirstOrDefault(customer => customer.CustomerRole.Code == DicCustomerRoleCodes.Correspondence); return(addressee?.CustomerId); }
private void btnSearchCustomer2_Click(object sender, EventArgs e) { //Contract customer dlgSearchCustomer searhCustomer = new dlgSearchCustomer(); searhCustomer.Owner = this.ParentForm; searhCustomer.ShowDialog(); ContractCustomer cc = new ContractCustomer(); int id = -1; bool tmp = int.TryParse(searhCustomer.CustId, out id); if (tmp) { cc.CustId = id; } int custno = -1; bool tmp2 = int.TryParse(searhCustomer.Custno, out custno); if (tmp2) { cc.CustNr = custno; } cc.Name = searhCustomer.CustName; cc.Address = searhCustomer.CustAddress; cc.Email = searhCustomer.CustEmail; cc.Phone = searhCustomer.CustPhone; if (!string.IsNullOrEmpty(searhCustomer.Custno)) { this.txtContractCusNr.Text = searhCustomer.Custno; this.txtContractCusName.Text = searhCustomer.CustName; this.txtContractCusAdd.Text = searhCustomer.CustAddress; this.txtContractCusEmail.Text = searhCustomer.CustEmail; this.txtContractCusPhone.Text = searhCustomer.CustPhone; ContractFrm.objContract.ContractCustId = cc; //check contract Variant bool chk = Contract.checkContractVariant(cc.CustId); this.chkContractVariant.Checked = chk; } }
public List <Customer> GetCustomers() { List <Customer> customers = new List <Customer>(); Customer customer = new Customer(); string cs = ConfigurationManager.ConnectionStrings["CRCS"].ConnectionString; using (SqlConnection con = new SqlConnection(cs)) { SqlCommand cmd = new SqlCommand("spGetCustomers", con); cmd.CommandType = CommandType.StoredProcedure; con.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { if ((CustomerType)reader["CustomerType"] == CustomerType.PayAsGoCustomer) { customer = new PayAsGoCustomer { CustomerType = CustomerType.PayAsGoCustomer }; } else { customer = new ContractCustomer { CustomerType = CustomerType.ContractCustomer, Discount = Convert.ToDecimal(reader["Discount"]) }; } customer.Id = Convert.ToInt32(reader["Id"]); customer.FirstName = reader["FirstName"].ToString(); customer.LastName = reader["LastName"].ToString(); customer.Mobile = reader["Mobile"].ToString(); customer.Email = reader["Email"].ToString(); customers.Add(customer); } } return(customers); }
private async Task <ContractCustomer> CreateCustomer(RfCustomerAddressExtention oldCustomer, int contractId) { try { var customerId = GetObjectId <DicCustomer>(oldCustomer.CustomerId); if ((customerId == null || customerId == 0) && oldCustomer.CustomerId.HasValue) { customerId = await GetCustomer(oldCustomer.CustomerId.Value); } if (customerId == null || customerId == 0) { return(null); } var customer = new ContractCustomer { Address = oldCustomer.AddresNameRu, CustomerId = customerId, CustomerRoleId = GetObjectId <DicCustomerRole>(oldCustomer.CType), DateCreate = new DateTimeOffset(oldCustomer.DateCreate.GetValueOrDefault(DateTime.Now)), DateUpdate = new DateTimeOffset(oldCustomer.Stamp.GetValueOrDefault(DateTime.Now)), DateBegin = GetNullableDate(oldCustomer.DateBegin), DateEnd = GetNullableDate(oldCustomer.DateEnd), ExternalId = oldCustomer.Id, ContractId = contractId, Timestamp = BitConverter.GetBytes(DateTime.Now.Ticks), AddressEn = oldCustomer.AddresNameEn, AddressKz = oldCustomer.AddresNameKz }; return(customer); } catch (Exception) { return(null); } }
public async Task <IActionResult> Post([FromBody] ContractDetailDto contractDetailDto) { var contractId = await Executor.GetCommand <CreateContractCommand>().Process(c => c.ExecuteAsync(contractDetailDto)); var contract = await Executor.GetQuery <GetContractByIdQuery>().Process(q => q.ExecuteAsync(contractId)); var addressee = contract.Addressee; if (addressee != null /*&& string.IsNullOrWhiteSpace(contractDetailDto.Apartment) == false*/) { addressee.Apartment = contractDetailDto.Apartment; addressee.Address = contractDetailDto.AddresseeAddress; var сorrespondenceСustomerRoleId = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicCustomerRole), _сorrespondenceCustomerRole); var сorrespondenceCustomer = new ContractCustomer() { CustomerId = contract.AddresseeId, ContractId = contractId, CustomerRoleId = сorrespondenceСustomerRoleId, Address = addressee.Address, AddressEn = addressee.AddressEn, AddressKz = addressee.AddressKz, DateCreate = DateTimeOffset.Now, DateUpdate = DateTimeOffset.Now }; await Executor.GetCommand <CreateContractCustomerCommand>().Process(q => q.ExecuteAsync(сorrespondenceCustomer)); await Executor.GetCommand <UpdateDicCustomerCommand>().Process(c => c.ExecuteAsync(addressee)); } var userId = NiisAmbientContext.Current.User.Identity.UserId; var contractWorkflow = await Executor.GetQuery <GetInitialContractWorkflowQuery>().Process(q => q.ExecuteAsync(contract, userId)); if (contractWorkflow != null) { await Executor.GetHandler <ProcessContractWorkflowHandler>().Process(h => h.Handle(contractWorkflow, userId)); } var contractRequestRelationsDtos = new List <ContractRequestRelationDto>(); var contractProtectionDocRelationDtos = new List <ContractProtectionDocRelationDto>(); foreach (var ownerDto in contractDetailDto.Owners) { contractRequestRelationsDtos.Add(new ContractRequestRelationDto { ContractId = contractId, Request = new RequestItemDto { Id = ownerDto.OwnerId } }); } foreach (var ownerDto in contractDetailDto.ProtectionDocsOwners) { contractProtectionDocRelationDtos.Add(new ContractProtectionDocRelationDto { ContractId = contractId, ProtectionDoc = new ProtectionDocItemDto { Id = ownerDto.OwnerId } }); } // var contractRequestRelationsDtos = contractDetailDto.RequestRelations.ToList(); Executor.CommandChain() .AddCommand <DeleteContractRequestRelationsCommand>(c => c.Execute(contractId, contractRequestRelationsDtos)) .AddCommand <CreateContractRequestRelationsCommand>(c => c.Execute(contractId, contractRequestRelationsDtos)) .AddCommand <UpdateContractRequestRelationsCommand>(c => c.Execute(contractId, contractRequestRelationsDtos)) .AddCommand <DeleteContractProtectionDocRelationsCommand>(c => c.Execute(contractId, contractProtectionDocRelationDtos)) .AddCommand <CreateContractProtectionDocRelationsCommand>(c => c.Execute(contractId, contractProtectionDocRelationDtos)) .AddCommand <UpdateContractProtectionDocRelationsCommand>(c => c.Execute(contractId, contractProtectionDocRelationDtos)) .ExecuteAllWithTransaction(); var createdContract = await Executor.GetQuery <GetContractByIdQuery>().Process(q => q.ExecuteAsync(contractId)); var createdContractDetailDto = Mapper.Map <Contract, ContractDetailDto>(createdContract); return(Ok(createdContractDetailDto)); }
/// <summary> /// Добавление договора /// </summary> /// <param name="request">Входные параметры</param> /// <param name="response">Данные для ответа</param> /// <returns></returns> public ContractResponse AddContract(ContractRequest request, ContractResponse response) { var typeId = _dictionaryHelper.GetDictionaryIdByExternalId(nameof(DicDocumentType), request.DocumentType.Id); DicCustomer customer; customer = Mapper.Map <DicCustomer>( request, el => el.Items[nameof(customer.TypeId)] = _dictionaryHelper.GetDictionaryEntityByExternalId(nameof(DicCustomerType), request.Addressee.CustomerType.Id).Id); customer.CountryId = _dictionaryHelper.GetDictionaryIdByExternalId(nameof(DicCountry), request.Addressee.CountryInfo.Id); var addressee = _integrationDictionaryHelper.GetCustomerIdOrCreateNew(customer); var correspondence = request.CorrespondenceAddress; var protectionDocTypeId = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicProtectionDocType), DicProtectionDocTypeCodes.ProtectionDocTypeContractCode); #region Добавление договора var contract = new Contract { ProtectionDocTypeId = protectionDocTypeId, Description = request.DocumentDescriptionRu, ReceiveTypeId = int.Parse(DicReceiveTypeCodes.ElectronicFeed), DivisionId = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicDivision), DicDivisionCodes.RGP_NIIS), AddresseeId = addressee.Id, AddresseeAddress = addressee.Address, StatusId = 1 }; CreateContract(Mapper.Map(request, contract)); #endregion #region Добавление адресата для переписки if (correspondence != null) { var correspondenceCustomer = _integrationDictionaryHelper.GetCustomerIdOrCreateNew(new DicCustomer { TypeId = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicCustomerType), DicCustomerTypeCodes.Undefined), NameRu = correspondence.CustomerName, Phone = correspondence.Phone, PhoneFax = correspondence.Fax, Email = correspondence.Email }); _niisWebContext.ContractCustomers.Add(new ContractCustomer { CustomerId = correspondenceCustomer.Id, ContractId = contract.Id, DateCreate = DateTimeOffset.Now, CustomerRoleId = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicCustomerRole), DicCustomerRole.Codes.Correspondence) }); _niisWebContext.SaveChanges(); } #endregion #region Добавление контрагентов foreach (var item in request.BlockCustomers) { if (item.CustomerType == null) { continue; } if (item.CustomerType.Id == 0) { item.CustomerType.Id = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicCustomerType), DicCustomerTypeCodes.Undefined); } var dicCustomer = new DicCustomer { TypeId = _dictionaryHelper.GetDictionaryEntityByExternalId(nameof(DicCustomerType), item.CustomerType.Id).Id, NameRu = item.NameRu, NameKz = item.NameKz, NameEn = item.NameEn, Phone = item.Phone, PhoneFax = item.Fax, Email = item.Email, Address = $"{item.Region}, {item.Street}, {item.Index}", CertificateNumber = item.CertificateNumber, CertificateSeries = item.CertificateSeries, Opf = item.Opf, ApplicantsInfo = item.ApplicantsInfo, PowerAttorneyFullNum = item.PowerAttorneyFullNum, ShortDocContent = item.ShortDocContent, Xin = item.Xin, NotaryName = item.NotaryName, DateCreate = DateTimeOffset.Now }; if (item.RegistrationDate != DateTime.MinValue) { dicCustomer.RegDate = new DateTimeOffset(item.RegistrationDate.GetValueOrDefault()); } var contractCustomer = new ContractCustomer { CustomerId = _integrationDictionaryHelper.GetCustomerIdOrCreateNew(dicCustomer).Id, ContractId = contract.Id, DateCreate = DateTimeOffset.Now, CustomerRoleId = _dictionaryHelper.GetDictionaryEntityByExternalId(nameof(DicCustomerRole), item.CustomerRole.Id)?.Id }; _niisWebContext.ContractCustomers.Add(contractCustomer); _niisWebContext.SaveChanges(); } #endregion #region Добавление прикрепленного документа заявления var document = new Document(_dictionaryHelper.GetDocumentType(typeId).type) { TypeId = typeId, DateCreate = DateTimeOffset.Now, AddresseeId = addressee.Id, StatusId = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicDocumentStatus), DicDocumentStatusCodes.InWork), ReceiveTypeId = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicReceiveType), DicReceiveTypeCodes.ElectronicFeed) }; _documentHelper.CreateDocument(document); _attachFileHelper.AttachFile(new AttachedFileModel { PageCount = request.RequisitionFile.PageCount.GetValueOrDefault(), CopyCount = request.RequisitionFile.CopyCount.GetValueOrDefault(), File = request.RequisitionFile.Content, Length = request.RequisitionFile.Content.Length, IsMain = true, Name = request.RequisitionFile.Name }, document); _niisWebContext.Documents.Update(document); _niisWebContext.SaveChanges(); _niisWebContext.ContractsDocuments.Add(new ContractDocument { DocumentId = document.Id, ContractId = contract.Id }); _niisWebContext.SaveChanges(); #endregion #region Добавление документов foreach (var attachedFile in request.AttachmentFiles) { if (attachedFile.File == null) { continue; } var documentType = _dictionaryHelper.GetDocumentType(attachedFile.FileType.Id); var inWorkStatusId = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicDocumentStatus), DicDocumentStatusCodes.InWork); var completedStatusId = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicDocumentStatus), DicDocumentStatusCodes.Completed); var attachmentDocument = new Document(documentType.type) { TypeId = documentType.typeId, DateCreate = DateTimeOffset.Now, StatusId = documentType.type == DocumentType.DocumentRequest ? completedStatusId : inWorkStatusId, AddresseeId = addressee.Id, ReceiveTypeId = _dictionaryHelper.GetDictionaryIdByCode(nameof(DicReceiveType), DicReceiveTypeCodes.ElectronicFeed) }; _documentHelper.CreateDocument(attachmentDocument); var attached = new AttachedFileModel { Length = attachedFile.File.Content.Length, PageCount = attachedFile.File.PageCount.GetValueOrDefault(), File = attachedFile.File?.Content, Name = attachedFile.File.Name, IsMain = true, CopyCount = 1 }; _attachFileHelper.AttachFile(attached, document); _niisWebContext.ContractsDocuments.Add(new ContractDocument { DocumentId = attachmentDocument.Id, ContractId = contract.Id }); _niisWebContext.SaveChanges(); } #endregion #region Добавление связи с ОД foreach (var contractPatent in request.PatentNumbers) { //Получаем типа патента if (!(_dictionaryHelper.GetDictionaryByExternalId(nameof(DicProtectionDocType), contractPatent.PatentType.Id) is DicProtectionDocType type)) { throw new NotSupportedException($"Тип с идентефикатором {contractPatent.PatentType.Id} не найден"); } var patentId = _niisWebContext .ProtectionDocs .Where(d => d.GosNumber == contractPatent.PatentNumber && d.Request.ProtectionDocTypeId == type.Id) .Select(d => d.Id).FirstOrDefault(); _niisWebContext.ContractProtectionDocRelations.Add(new ContractProtectionDocRelation { ProtectionDocId = patentId, ContractId = contract.Id }); _niisWebContext.SaveChanges(); } #endregion #region Добавление этапа обработки var routeId = _integrationDictionaryHelper.GetRouteIdByProtectionDocType(protectionDocTypeId); var stage = _integrationDictionaryHelper.GetRouteStage(routeId); var contractWorkflow = new ContractWorkflow { OwnerId = contract.Id, DateCreate = DateTimeOffset.Now, RouteId = routeId, CurrentStageId = stage.Id, CurrentUserId = _configuration.AuthorAttachmentDocumentId, IsComplete = stage.IsLast, IsSystem = stage.IsSystem, IsMain = stage.IsMain }; _niisWebContext.ContractWorkflows.Add(contractWorkflow); _niisWebContext.SaveChanges(); contract.CurrentWorkflowId = contractWorkflow.Id; _niisWebContext.Contracts.Update(contract); _niisWebContext.SaveChanges(); #endregion _integrationStatusUpdater.Add(contractWorkflow.Id); var onlineStatusId = 0; if (contractWorkflow.CurrentStageId != null) { onlineStatusId = _integrationDictionaryHelper.GetOnlineStatus(contractWorkflow.CurrentStageId.Value); } response.DocumentId = contract.Barcode; response.DocumentNumber = contract.IncomingNumber; response.RequisitionStatus = onlineStatusId; return(response); }
public Contract saveContractData() { //ContractDate contractDate = contract.ContractDateData; //ContractPayment ContractPaymentData = contract.ContractPaymentData; //ContractCapital ContractCapitalData = contract.ContractCapitalData; //ContractCost ContractCostData = contract.ContractCostData; //ContractExtraKm ContractExtraKmData = contract.ContractExtraKmData; ContractDate contractDate = ContractFrm.objContract.ContractDateData; ContractPayment ContractPaymentData = ContractFrm.objContract.ContractPaymentData; ContractCapital ContractCapitalData = ContractFrm.objContract.ContractCapitalData; ContractCost ContractCostData = ContractFrm.objContract.ContractCostData; ContractExtraKm ContractExtraKmData = ContractFrm.objContract.ContractExtraKmData; if (contractDate == null) { contractDate = new ContractDate(); } if (ContractPaymentData == null) { ContractPaymentData = new ContractPayment(); } if (ContractCapitalData == null) { ContractCapitalData = new ContractCapital(); } if (ContractCostData == null) { ContractCostData = new ContractCost(); } if (ContractExtraKmData == null) { ContractExtraKmData = new ContractExtraKm(); } //Start contractDate.ContractStartDate = txtStartDate.Value; contractDate.ContractStartKm = Int32.Parse(txtStartKm.Value.ToString()); contractDate.ContractStartHour = Int32.Parse(txtStartHr.Value.ToString()); contractDate.InvoiceStartDate = txtStartInvoice.Value; contractDate.ContractPeriodMonth = Int32.Parse(txtPeriod.Text); contractDate.ContractPeriodKm = Int32.Parse(txtKm.Value.ToString()); contractDate.ContractPeriodHour = Int32.Parse(txtHr.Value.ToString()); if (rdKmBase.Checked) { ContractFrm.objContract.ContractDateData.ContractPeriodKmHour = 1; } if (rdHrBase.Checked) { ContractFrm.objContract.ContractDateData.ContractPeriodKmHour = 2; } //End contractDate.ContractEndDate = txtEndDate.Value; contractDate.ContractEndKm = Int32.Parse(txtEndKm.Value.ToString()); contractDate.ContractEndHour = Int32.Parse(txtEndHr.Value.ToString()); contractDate.InvoiceEndDate = txtEndInvoice.Value; if (cbTemType.SelectedValue != null) { clsBaseListItem TerminationType = new clsBaseListItem(); TerminationType.strValue1 = cbTemType.SelectedValue.ToString(); TerminationType.strText = cbTemType.SelectedText; ContractFrm.objContract.TerminationType = TerminationType; } //Payment if (cbPayPeriod.SelectedValue != null) { clsBaseListItem PaymentPeriod = new clsBaseListItem(); PaymentPeriod.strValue1 = cbPayPeriod.SelectedValue.ToString(); PaymentPeriod.strText = cbPayPeriod.SelectedText; ContractPaymentData.PaymentPeriod = PaymentPeriod; } ContractFrm.objContract.IsManualInvoice = cbInvoice.Checked; ContractPaymentData.PaymentIsInBlock = cbPayment.Checked; if (cbColType.SelectedValue != null) { ContractPaymentData.PaymentCollectionType = cbColType.SelectedValue.ToString(); } if (cbGrpLevel.SelectedValue != null) { ContractPaymentData.PaymentGroupingLevel = cbGrpLevel.SelectedValue.ToString(); } clsBaseListItem PaymentTerm = new clsBaseListItem(); if (cbPayTerm.SelectedValue != null) { PaymentTerm.strValue1 = cbPayTerm.SelectedValue.ToString(); PaymentTerm.strText = cbPayTerm.SelectedText; } ContractPaymentData.PaymentTerm = PaymentTerm; clsBaseListItem InvoiceSiteId = new clsBaseListItem(); if (cbInvoiceSite.SelectedValue != null) { InvoiceSiteId.strValue1 = cbInvoiceSite.SelectedValue.ToString(); InvoiceSiteId.strText = cbInvoiceSite.SelectedText; } ContractFrm.objContract.InvoiceSiteId = InvoiceSiteId; //captial ContractCapitalData.CapitalStartAmount = txtStartAmount.Value; clsBaseListItem CapitalStartPayer = new clsBaseListItem(); if (txtStartAmountPayer.SelectedValue != null) { CapitalStartPayer.strValue1 = txtStartAmountPayer.SelectedValue.ToString(); CapitalStartPayer.strText = txtStartAmountPayer.SelectedText.ToString(); } ContractCapitalData.CapitalStartPayer = CapitalStartPayer; ContractCapitalData.CapitalMonthAmount = txtMonAmount.Value; clsBaseListItem CapitalMonthPayer = new clsBaseListItem(); if (txtMonAmountPayer.SelectedValue != null) { CapitalMonthPayer.strValue1 = txtMonAmountPayer.SelectedValue.ToString(); CapitalMonthPayer.strText = txtMonAmountPayer.SelectedText.ToString(); } ContractCapitalData.CapitalMonthPayer = CapitalMonthPayer; if (ContractFrm.objContract.ContractCapitalData != null) { txtTotalAmount.Text = (ContractFrm.objContract.ContractCapitalData.CapitalStartAmount + ContractFrm.objContract.ContractCapitalData.CapitalMonthAmount * ContractFrm.objContract.ContractDateData.ContractPeriodMonth).ToString(); } else { txtTotalAmount.Text = ""; } //Cost clsBaseListItem CostBasis = new clsBaseListItem(); if (cbCostBassis.SelectedValue != null) { CostBasis.strValue1 = cbCostBassis.SelectedValue.ToString(); CostBasis.strText = cbCostBassis.SelectedText.ToString(); } ContractCostData.CostBasis = CostBasis; ContractCostData.CostBasedOnService = txtCostBase.Value; ContractCostData.CostMonthBasis = txtMonBassis.Value; ContractCostData.CostKmBasis = txtKmBassis.Value; ContractCostData.CostPerKm = txtErr.Value; txtLastPay.Text = "txtLastPay"; txtLastKm.Text = ""; //Extra clsBaseListItem ExtraKmInvoicePeriod = new clsBaseListItem(); if (cbBiling.SelectedValue != null) { ExtraKmInvoicePeriod.strValue1 = cbBiling.SelectedValue.ToString(); ExtraKmInvoicePeriod.strText = cbBiling.SelectedText.ToString(); } ContractExtraKmData.ExtraKmInvoicePeriod = ExtraKmInvoicePeriod; clsBaseListItem ExtraKmAccounting = new clsBaseListItem(); if (cbAccounting.SelectedValue != null) { ExtraKmAccounting.strValue1 = cbAccounting.SelectedValue.ToString(); ExtraKmAccounting.strText = cbAccounting.SelectedText.ToString(); } ContractExtraKmData.ExtraKmAccounting = ExtraKmAccounting; ContractExtraKmData.ExtraKmMaxDeviation = txtMaxDev.Value; ContractExtraKmData.ExtraKmLowAmount = txtLowKm.Value; ContractExtraKmData.ExtraKmHighAmount = txtHighKm.Value; ContractExtraKmData.ExtraKmInvoicedAmount = txtInvoiceAmount.Value; // clsBaseListItem RollingCode = new clsBaseListItem(); if (cbRoll.SelectedIndex >= 0) { RollingCode.strValue1 = cbRoll.SelectedValue.ToString(); RollingCode.strText = cbRoll.SelectedText.ToString(); } ContractFrm.objContract.RollingCode = RollingCode; ContractFrm.objContract.IsInvoiceDetail = cbInvoiceDetail.Checked; //RiskCustId ContractCustomer RiskCustId = new ContractCustomer(); if (txtRiskCusId.Text != null && txtRiskCusId.Text.Trim().Length > 0) { RiskCustId.CustId = Int32.Parse(txtRiskCusId.Text); } ContractFrm.objContract.RiskCustId = RiskCustId; ContractFrm.objContract.RiskLevel = txtRishLevel.Value; //Save Risk List <ZSC_SubcontractorContractRisk> listRisk = new List <ZSC_SubcontractorContractRisk>(); List <SubContractorContract> SubContracts = ContractFrm.objContract.SubContracts; ZSC_SubcontractorContractRisk objRisk = null; string colName = ""; decimal newInteger; foreach (DataRow row in dataTable.Rows) { foreach (SubContractorContract subContract in SubContracts) { colName = "sub" + subContract.OID; if (row[colName] != null && row[colName].ToString().Trim().Length > 0 && decimal.TryParse(row[colName].ToString().Trim(), out newInteger) && newInteger > 0) { objRisk = new ZSC_SubcontractorContractRisk(); objRisk.SubContractOID = subContract.OID; objRisk.RiskPartnerCustId = Int32.Parse(row["RiskPartnerCustId"].ToString().Trim()); objRisk.RiskLevel = decimal.Parse(row[colName].ToString().Trim()); listRisk.Add(objRisk); } } } ContractFrm.objContract.SubcontractorContractRisks = listRisk; ContractFrm.objContract.ContractDateData = contractDate; ContractFrm.objContract.ContractPaymentData = ContractPaymentData; ContractFrm.objContract.ContractCapitalData = ContractCapitalData; ContractFrm.objContract.ContractCostData = ContractCostData; ContractFrm.objContract.ContractExtraKmData = ContractExtraKmData; ContractFrm.objContract.IndexingDate = dtIndexingDate.Value; ContractFrm.objContract.IndexValue = dfIndexValue.Value; ContractFrm.objContract.ContractPaymentData.InvoiceDate = (Int32)dfInvoicingDay.Value; return(ContractFrm.objContract); }
public void fillData() { initFrm(); if (ContractFrm.objContract != null && ContractFrm.objContract.ContractOID > 0) { //Start txtStartDate.Value = ContractFrm.objContract.ContractDateData.ContractStartDate; txtStartKm.Value = ContractFrm.objContract.ContractDateData.ContractStartKm; txtStartHr.Value = ContractFrm.objContract.ContractDateData.ContractStartHour; txtStartInvoice.Value = ContractFrm.objContract.ContractDateData.InvoiceStartDate; txtPeriod.Value = ContractFrm.objContract.ContractDateData.ContractPeriodMonth; txtKm.Value = ContractFrm.objContract.ContractDateData.ContractPeriodKm; txtHr.Value = ContractFrm.objContract.ContractDateData.ContractPeriodHour; rdKmBase.Checked = (ContractFrm.objContract.ContractDateData != null && ContractFrm.objContract.ContractDateData.ContractPeriodKmHour == 1); rdHrBase.Checked = (ContractFrm.objContract.ContractDateData != null && ContractFrm.objContract.ContractDateData.ContractPeriodKmHour == 2); //End txtEndDate.Value = ContractFrm.objContract.ContractDateData.ContractEndDate; txtEndKm.Value = ContractFrm.objContract.ContractDateData.ContractEndKm; txtEndHr.Value = ContractFrm.objContract.ContractDateData.ContractEndHour; txtEndInvoice.Value = ContractFrm.objContract.ContractDateData.InvoiceEndDate; cbTemType.SelectedValue = ContractFrm.objContract.TerminationType.strValue1; //Payment if (ContractFrm.objContract.ContractPaymentData.PaymentPeriod != null && ContractFrm.objContract.ContractPaymentData.PaymentPeriod.strValue1 != null) { cbPayPeriod.SelectedValue = ContractFrm.objContract.ContractPaymentData.PaymentPeriod.strValue1; } else { cbPayPeriod.SelectedIndex = -1; } cbPayment.Checked = ContractFrm.objContract.ContractPaymentData.PaymentIsInBlock; cbInvoice.Checked = ContractFrm.objContract.IsManualInvoice; if (ContractFrm.objContract.ContractPaymentData != null && ContractFrm.objContract.ContractPaymentData.PaymentNextBlockStart != null) { txtNextBlock.Text = ContractFrm.objContract.ContractPaymentData.PaymentNextBlockStart.ToString("d", System.Globalization.CultureInfo.GetCultureInfo(objGlobal.CultureInfo)); } else { txtNextBlock.Text = ""; } if (ContractFrm.objContract.ContractPaymentData != null && ContractFrm.objContract.ContractPaymentData.PaymentNextBlockEnd != null) { txtNextBlockEnd.Text = ContractFrm.objContract.ContractPaymentData.PaymentNextBlockEnd.ToString("d", System.Globalization.CultureInfo.GetCultureInfo(objGlobal.CultureInfo)); } else { txtNextBlockEnd.Text = ""; } cbColType.SelectedValue = ContractFrm.objContract.ContractPaymentData.PaymentCollectionType; cbGrpLevel.SelectedValue = ContractFrm.objContract.ContractPaymentData.PaymentGroupingLevel; cbPayTerm.SelectedValue = ContractFrm.objContract.ContractPaymentData.PaymentTerm.strValue1; if (ContractFrm.objContract.InvoiceSiteId != null) { cbInvoiceSite.SelectedValue = ContractFrm.objContract.InvoiceSiteId.strValue1; } else { cbInvoiceSite.SelectedValue = -1; } //captial txtStartAmount.Text = ContractFrm.objContract.ContractCapitalData.CapitalStartAmount.ToString(); if (ContractFrm.objContract.ContractCapitalData != null && ContractFrm.objContract.ContractCapitalData.CapitalStartPayer != null && ContractFrm.objContract.ContractCapitalData.CapitalStartPayer.strValue1 != null && ContractFrm.objContract.ContractCapitalData.CapitalStartPayer.strValue1.Length > 0) { txtStartAmountPayer.SelectedValue = ContractFrm.objContract.ContractCapitalData.CapitalStartPayer.strValue1; } else { txtStartAmountPayer.SelectedValue = -1; } txtMonAmount.Text = ContractFrm.objContract.ContractCapitalData.CapitalMonthAmount.ToString(); if (ContractFrm.objContract.ContractCapitalData != null && ContractFrm.objContract.ContractCapitalData.CapitalMonthPayer != null && ContractFrm.objContract.ContractCapitalData.CapitalMonthPayer.strValue1 != null && ContractFrm.objContract.ContractCapitalData.CapitalMonthPayer.strValue1.Length > 0) { txtMonAmountPayer.SelectedValue = ContractFrm.objContract.ContractCapitalData.CapitalMonthPayer.strValue1; } else { txtMonAmountPayer.SelectedValue = -1; } txtTotalAmount.Text = (ContractFrm.objContract.ContractCapitalData.CapitalStartAmount + ContractFrm.objContract.ContractCapitalData.CapitalMonthAmount * ContractFrm.objContract.ContractDateData.ContractPeriodMonth).ToString(); //Cost if (ContractFrm.objContract.ContractCostData.CostBasis != null && ContractFrm.objContract.ContractCostData.CostBasis.strValue1 != null && ContractFrm.objContract.ContractCostData.CostBasis.strValue1.Length > 0) { cbCostBassis.SelectedValue = ContractFrm.objContract.ContractCostData.CostBasis.strValue1; } else { cbCostBassis.SelectedIndex = -1; } txtCostBase.Value = ContractFrm.objContract.ContractCostData.CostBasedOnService; txtCostBase2.Value = ContractFrm.objContract.ContractCostData.CostBasedOnService + ContractFrm.objContract.getPayerOptionPrice(); txtMonBassis.Value = ContractFrm.objContract.ContractCostData.CostMonthBasis; txtKmBassis.Value = ContractFrm.objContract.ContractCostData.CostKmBasis; DateTime? lastPay = ContractOption.GetLastPayDate(ContractFrm.objContract.ContractOID); CultureInfo cu = new CultureInfo(ContractFrm.myCulture); if (lastPay != null) { txtLastPay.Text = lastPay.ToString().ToString(cu); } else { txtLastPay.Text = ""; } txtErr.Text = ContractFrm.objContract.ContractCostData.CostPerKm.ToString(); //LastKm info VehicleMileage vehicleMileage = ContractFrm.objContract.VehiId.lastMileages(); if (vehicleMileage != null) { txtLastKm.Text = vehicleMileage.LastKmInfo(); } else { txtLastKm.Text = ""; } //Extra if (ContractFrm.objContract.ContractExtraKmData.ExtraKmInvoicePeriod != null && ContractFrm.objContract.ContractExtraKmData.ExtraKmInvoicePeriod.strValue1 != null && ContractFrm.objContract.ContractExtraKmData.ExtraKmInvoicePeriod.strValue1 != "") { cbBiling.SelectedValue = ContractFrm.objContract.ContractExtraKmData.ExtraKmInvoicePeriod.strValue1; } else { cbBiling.SelectedIndex = -1; } if (ContractFrm.objContract.ContractExtraKmData.ExtraKmInvoicePeriod != null && ContractFrm.objContract.ContractExtraKmData.ExtraKmAccounting.strValue1 != null && ContractFrm.objContract.ContractExtraKmData.ExtraKmAccounting.strValue1 != "") { cbAccounting.SelectedValue = ContractFrm.objContract.ContractExtraKmData.ExtraKmAccounting.strValue1; } else { cbAccounting.SelectedIndex = -1; } txtMaxDev.Value = ContractFrm.objContract.ContractExtraKmData.ExtraKmMaxDeviation; txtLowKm.Value = ContractFrm.objContract.ContractExtraKmData.ExtraKmLowAmount; txtHighKm.Value = ContractFrm.objContract.ContractExtraKmData.ExtraKmHighAmount; txtInvoiceAmount.Value = ContractFrm.objContract.ContractExtraKmData.ExtraKmInvoicedAmount; //cbRoll if (ContractFrm.objContract.RollingCode != null && ContractFrm.objContract.RollingCode.strValue1 != null && ContractFrm.objContract.RollingCode.strValue1 != "") { cbRoll.SelectedValue = ContractFrm.objContract.RollingCode.strValue1; } else { cbRoll.SelectedIndex = -1; } cbInvoiceDetail.Checked = ContractFrm.objContract.IsInvoiceDetail; //Risk ContractCustomer RiskCustId = ContractFrm.objContract.RiskCustId; if (RiskCustId != null && RiskCustId.CustId > 0) { txtRiskCusId.Text = RiskCustId.CustId.ToString(); txtPatnerNr.Text = RiskCustId.CustNr.ToString(); txtParnerName.Text = RiskCustId.Name; } else { txtRiskCusId.Text = ""; txtPatnerNr.Text = ""; txtParnerName.Text = ""; } txtRishLevel.Text = ContractFrm.objContract.RiskLevel.ToString(); if (ContractFrm.objContract.IndexingDate != DateTime.MinValue) { dtIndexingDate.Value = ContractFrm.objContract.IndexingDate; } dfIndexValue.Value = ContractFrm.objContract.IndexValue; dfInvoicingDay.Value = ContractFrm.objContract.ContractPaymentData.InvoiceDate; //Load data grid fillRisk(); generateColumns(); } else { //Start txtStartDate.Value = DateTime.Now; txtStartKm.Value = 0; txtStartHr.Value = 0; txtStartInvoice.Value = DateTime.Now; txtPeriod.Value = 0; txtKm.Value = 0; txtHr.Value = 0; //End txtEndDate.Value = DateTime.Now; txtEndKm.Value = 0; txtEndHr.Value = 0; txtEndInvoice.Value = DateTime.Now; cbTemType.Text = ""; //Payment cbPayPeriod.SelectedIndex = -1; cbPayment.Checked = false; cbInvoice.Checked = false; txtNextBlock.Text = ""; txtNextBlockEnd.Text = ""; cbColType.SelectedIndex = -1; cbGrpLevel.SelectedIndex = -1; cbPayTerm.SelectedIndex = -1; cbInvoiceSite.SelectedIndex = -1; //captial txtStartAmount.Text = ""; txtStartAmountPayer.Text = ""; txtMonAmount.Text = ""; txtMonAmountPayer.Text = ""; txtTotalAmount.Text = ""; //Cost cbCostBassis.Text = ""; txtCostBase.Value = 0; txtCostBase2.Value = 0; txtMonBassis.Value = 0; txtKmBassis.Value = 0; txtLastPay.Text = ""; txtErr.Text = ""; txtLastKm.Text = ""; //Extra cbBiling.SelectedIndex = -1; cbAccounting.SelectedIndex = -1; txtMaxDev.Value = 0; txtLowKm.Value = 0; txtHighKm.Value = 0; txtInvoiceAmount.Value = 0; cbRoll.SelectedIndex = -1; cbInvoiceDetail.Checked = false; //Risk txtRiskCusId.Text = ""; txtPatnerNr.Text = ""; txtParnerName.Text = ""; txtRishLevel.Value = 0; txtRishLevel.Value = 0; //Grid } gridRisk.DataSource = dataTable; //() formatDecimal(); }