public void Update() { short routes = 0; BAudit bAudit = new BAudit(); EAudit eAudit = null; BCompany bCompany = new BCompany(); ECompany eCompany = new ECompany(); ECompany updatedCompany = new ECompany(); BCorporation bCorporation = new BCorporation(); ECorporation eCorporation = new ECorporation(); TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew); eCorporation.CodeCorporation = Aleatory.GetString(2); eCorporation.Name = Aleatory.GetString(8); eCorporation.State = Aleatory.GetShort(); eCorporation.Audit.UserRegister = Aleatory.GetString(8); bCorporation.Insert(eCorporation); eCompany.CodeCompany = Aleatory.GetString(2); eCompany.Ruc = Aleatory.GetString(11); eCompany.CodeCorporation = eCorporation.CodeCorporation; eCompany.LongName = Aleatory.GetString(8); eCompany.State = Aleatory.GetShort(); eCompany.Audit.UserRegister = Aleatory.GetString(8); bCompany.Insert(eCompany); eCompany.LongName = Aleatory.GetString(8); eCompany.State = Aleatory.GetShort(); eCompany.Audit.UserRegister = Aleatory.GetString(8); bCompany.Update(eCompany); updatedCompany = bCompany.Select(eCompany); if (updatedCompany != null && updatedCompany.CodeCompany == eCompany.CodeCompany && updatedCompany.CodeCorporation == eCompany.CodeCorporation && updatedCompany.LongName != eCompany.LongName && updatedCompany.State == eCompany.State) { routes++; } eAudit = bAudit.Select(eCompany.Audit). Where(x => x.UserRegister == eCompany.Audit.UserRegister && x.Code == eCompany.Audit.Code && x.TypeEvent == "Update").FirstOrDefault(); if (eAudit != null) { routes++; } ts.Dispose(); }
/// <summary> /// 保存 /// </summary> private void btnSave_Click_1(object sender, EventArgs e) { if (CheckInput()) { if (_currentCompanyTable == null) { _currentCompanyTable = new BaseCompanyTable(); } _currentCompanyTable.CODE = txtCode.Text.Trim().PadLeft(2, '0'); _currentCompanyTable.NAME = txtName.Text; _currentCompanyTable.NAME_SHORT = txtNameShort.Text; _currentCompanyTable.NAME_ENGLISH = txtEnglishName.Text; _currentCompanyTable.ZIP_CODE = txtZipCode.Text; _currentCompanyTable.ADDRESS_FIRST = txtAddressFirst.Text; _currentCompanyTable.ADDRESS_MIDDLE = txtAddressMiddle.Text; _currentCompanyTable.ADDRESS_LAST = txtAddressLast.Text; _currentCompanyTable.PHONE_NUMBER = txtPhone.Text; _currentCompanyTable.FAX_NUMBER = txtFax.Text; _currentCompanyTable.EMAIL = txtEmail.Text; _currentCompanyTable.URL = txtURL.Text; _currentCompanyTable.MEMO = txtMemo.Text; _currentCompanyTable.LAST_UPDATE_USER = _userInfo.CODE; try { if (bCompany.Exists(txtCode.Text.Trim())) { bCompany.Update(_currentCompanyTable); } else { _currentCompanyTable.CREATE_USER = _userInfo.CODE; bCompany.Add(_currentCompanyTable); } } catch (Exception ex) { //log.error MessageBox.Show(""); return; } result = DialogResult.OK; this.Close(); CCacheData.Company = null; } }
/// <summary> /// 保存 /// </summary> private void btnSave_Click_1(object sender, EventArgs e) { if (CheckInput()) { if (_currentCompanyTable == null) { _currentCompanyTable = new BaseCompanyTable(); } _currentCompanyTable.CODE = txtCode.Text.Trim().PadLeft(2, '0'); _currentCompanyTable.NAME = txtName.Text.Trim(); _currentCompanyTable.NAME_SHORT = txtNameShort.Text.Trim(); _currentCompanyTable.NAME_ENGLISH = txtEnglishName.Text.Trim(); _currentCompanyTable.ZIP_CODE = txtZipCode.Text.Trim(); _currentCompanyTable.ADDRESS_FIRST = txtAddressFirst.Text.Trim(); _currentCompanyTable.ADDRESS_MIDDLE = txtAddressMiddle.Text.Trim(); _currentCompanyTable.ADDRESS_LAST = txtAddressLast.Text.Trim(); _currentCompanyTable.PHONE_NUMBER = txtPhone.Text.Trim(); _currentCompanyTable.FAX_NUMBER = txtFax.Text.Trim(); _currentCompanyTable.EMAIL = txtEmail.Text.Trim(); _currentCompanyTable.URL = txtURL.Text.Trim(); _currentCompanyTable.MEMO = txtMemo.Text.Trim(); _currentCompanyTable.LAST_UPDATE_USER = _userInfo.CODE; if (txtLogo.Text.ToString() != "") { string[] sArray = Regex.Split(txtLogo.Text.Trim(), @"\\", RegexOptions.IgnoreCase); System.IO.FileStream fs = new System.IO.FileStream(txtLogo.Text.Trim(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite); byte[] imgByte = new byte[fs.Length]; fs.Read(imgByte, 0, (int)fs.Length); _currentCompanyTable.LOGO = imgByte; } if (txtCompanyPicture.Text.ToString() != "") { string[] sArray = Regex.Split(txtCompanyPicture.Text.Trim(), @"\\", RegexOptions.IgnoreCase); System.IO.FileStream fs = new System.IO.FileStream(txtCompanyPicture.Text.Trim(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite); byte[] imgByte = new byte[fs.Length]; fs.Read(imgByte, 0, (int)fs.Length); _currentCompanyTable.COMPANY_PICTURE = imgByte; } try { if (bCompany.Exists(txtCode.Text.Trim())) { bCompany.Update(_currentCompanyTable); } else { _currentCompanyTable.CREATE_USER = _userInfo.CODE; bCompany.Add(_currentCompanyTable); } } catch (Exception ex) { //log.error MessageBox.Show(""); return; } result = DialogResult.OK; this.Close(); CCacheData.Company = null; } }