/// <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; } }