private void commitchange(Data.Com company) { company.CPriceType = cmbCPriceType.SelectedValue.ToGUID(); company.CPersonType = cmbCPersonType.SelectedValue.ToGUID(); company.CType = cmbCType.SelectedValue.ToGUID(); company.CName = txtLastName.Text; company.CNameEn = txtCNameEn.Text; company.CNationalCode = txtNationalCode.Text; company.CPostalCode = txtZipCode.Text.ToString(); company.CAddress = txtAddress.Text; company.CTell = txtPhone.Text; company.CMobile = txtCellPhone.Text; company.CRegisterNo = txtLegalCRegistrationNo.Text.ToNullableInt(); Data.CompanyStructureDefine _companyDefine = Business.GetCompanyStructureDefineBusiness().GetStructure(Constants.CodeTitle.CompanyType, txtLastName.Text, CompanyParentID, CompanyCode); string s = Business.GetCompanyStructureDefineBusiness().GetMaxCode(CompanyCode).Select(r => r.Code).FirstOrDefault(); _companyDefine.Type = Constants.CodeTitle.CompanyType; using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted, Timeout = new TimeSpan(2, 0, 0) })) { Business.GetCompanyStructureDefineBusiness().SaveByID(_companyDefine); company.CompanyStructureDefineId = _companyDefine.ID; Business.GetComBusiness().Save(company); scope.Complete(); } this.Close(); }
private void btnRegister_Click(object sender, RoutedEventArgs e) { var com = new Data.Com(); if (CompanyId != Guid.Empty) { com = Business.GetComBusiness().GetById(CompanyId); } if (FormIsValid() && CompanyCode != null) { commitchange(com); } }