Ejemplo n.º 1
0
        /// <summary>
        /// 保存
        /// </summary>
        private void btnSave_Click_1(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                if (_currentCustomerTable == null)
                {
                    _currentCustomerTable = new BaseCustomerTable();
                }
                _currentCustomerTable.CODE             = txtCode.Text.Trim();
                _currentCustomerTable.NAME             = txtName.Text.Trim();
                _currentCustomerTable.NAME_SHORT       = txtNameShort.Text.Trim();
                _currentCustomerTable.NAME_ENGLISH     = txtEnglishName.Text.Trim();
                _currentCustomerTable.ZIP_CODE         = txtZipCode.Text.Trim();
                _currentCustomerTable.ADDRESS_FIRST    = txtAddressFirst.Text.Trim();
                _currentCustomerTable.ADDRESS_MIDDLE   = txtAddressMiddle.Text.Trim();
                _currentCustomerTable.ADDRESS_LAST     = txtAddressLast.Text.Trim();
                _currentCustomerTable.PHONE_NUMBER     = txtPhone.Text.Trim();
                _currentCustomerTable.FAX_NUMBER       = txtFax.Text.Trim();
                _currentCustomerTable.MOBIL_NUMBER     = txtMobilNumber.Text.Trim();
                _currentCustomerTable.CONTACT_NAME     = txtContactName.Text.Trim();
                _currentCustomerTable.EMAIL            = txtEmail.Text.Trim();
                _currentCustomerTable.URL              = txtURL.Text.Trim();
                _currentCustomerTable.MEMO             = txtMemo.Text.Trim();
                _currentCustomerTable.CURRENCE_CODE    = CConstant.EXCHANGE_CHIAN;
                _currentCustomerTable.LAST_UPDATE_USER = _userInfo.CODE;
                _currentCustomerTable.CODE1            = txtCode1.Text.Trim();
                _currentCustomerTable.COUNTRY          = txtCountry.Text.Trim();
                _currentCustomerTable.PARENT_NAME      = txtName1.Text.Trim();

                try
                {
                    if (bCustomer.Exists(txtCode.Text.Trim()))
                    {
                        bCustomer.Update(_currentCustomerTable);
                    }
                    else
                    {
                        _currentCustomerTable.CREATE_USER = _userInfo.CODE;
                        bCustomer.Add(_currentCustomerTable);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                result = DialogResult.OK;
                this.Close();
            }
        }
Ejemplo n.º 2
0
        public override string[] doUpdateDB()
        {
            BaseCustomerTable CustomerTable = null;
            BCustomer         bCustomer     = new BCustomer();
            StringBuilder     strError      = new StringBuilder();
            int    successData    = 0;
            int    failureData    = 0;
            string errorFilePath  = "";
            string backupFilePath = "";

            //数据导入处理
            foreach (DataRow dr in _csvDataTable.Rows)
            {
                StringBuilder str = new StringBuilder();
                //编号
                if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "CODE"))))
                {
                    str.Append(CheckString(GetValue(dr, "CODE"), 20, "编号"));
                }
                else
                {
                    str.Append("编号不能为空!");
                }
                str.Append(CheckLenght(GetValue(dr, "NAME"), 100, "名称"));
                //简称
                str.Append(CheckLenght(GetValue(dr, "NAME_SHORT"), 50, "简称"));
                //英文名称
                str.Append(CheckLenght(GetValue(dr, "NAME_ENGLISH"), 100, "英文名称"));
                //邮编
                str.Append(CheckLenght(GetValue(dr, "ZIP_CODE"), 8, "邮编"));
                //地址1
                str.Append(CheckLenght(GetValue(dr, "ADDRESS_FIRST"), 100, "地址1"));
                //地址2
                str.Append(CheckLenght(GetValue(dr, "ADDRESS_MIDDLE"), 100, "地址2"));
                //地址3
                str.Append(CheckLenght(GetValue(dr, "ADDRESS_LAST"), 100, "地址3"));
                //电话
                str.Append(CheckLenght(GetValue(dr, "PHONE_NUMBER"), 20, "电话"));
                //传真
                str.Append(CheckLenght(GetValue(dr, "FAX_NUMBER"), 20, "传真"));
                //联系人名称
                str.Append(CheckLenght(GetValue(dr, "CONTACT_NAME"), 50, "联系人名称"));
                //联系人电话
                str.Append(CheckLenght(GetValue(dr, "MOBIL_NUMBER"), 20, "联系人电话"));
                //邮箱
                str.Append(CheckLenght(GetValue(dr, "EMIAL"), 50, "邮箱"));
                //网址
                str.Append(CheckLenght(GetValue(dr, "URL"), 50, "网址"));
                //备注
                str.Append(CheckLenght(GetValue(dr, "MEMO"), 255, "备注"));
                //类型
                if (CConvert.ToInt32(GetValue(dr, "TYPE", 1)) != 1 && CConvert.ToInt32(GetValue(dr, "TYPE", 1)) != 2 && CConvert.ToString(GetValue(dr, "TYPE", 1)) != "")
                {
                    str.Append("类型只能为1或2!");
                }
                else
                {
                    str.Append(CheckInt(GetValue(dr, "TYPE", 1), 2, "类型"));
                }
                //是否请款公司
                if (CConvert.ToInt32(GetValue(dr, "CLAIM_FLAG", 1)) != 1 && CConvert.ToInt32(GetValue(dr, "CLAIM_FLAG", 1)) != 2 && CConvert.ToString(GetValue(dr, "CLAIM_FLAG", 1)) != "")
                {
                    str.Append("是否请款公司只能为1或2!");
                }
                else
                {
                    str.Append(CheckInt(GetValue(dr, "CLAIM_FLAG", 1), 2, "是否请款公司"));
                }
                //请款公司编号
                str.Append(CheckLenght(GetValue(dr, "CLAIM_CODE"), 20, "请款公司编号"));
                //货币
                if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "CURRENCE_CODE"))))
                {
                    str.Append(CheckCurrency(CConvert.ToString(GetValue(dr, "CURRENCE_CODE")), "货币"));
                }
                //状态
                str.Append(CheckInt(GetValue(dr, "STATUS_FLAG", 1), 9, "状态"));
                //备考2
                str.Append(CheckLenght(GetValue(dr, "MEMO2"), 100, "备考2"));
                //日文名称
                str.Append(CheckLenght(GetValue(dr, "NAME_JP"), 100, "日文名称"));

                if (str.ToString().Trim().Length > 0)
                {
                    strError.Append(GetStringBuilder(dr, str.ToString().Trim()));
                    failureData++;
                    continue;
                }
                try
                {
                    CustomerTable                  = new BaseCustomerTable();
                    CustomerTable.CODE             = CConvert.ToString(GetValue(dr, "CODE"));
                    CustomerTable.NAME             = CConvert.ToString(GetValue(dr, "NAME"));
                    CustomerTable.NAME_SHORT       = CConvert.ToString(GetValue(dr, "NAME_SHORT"));
                    CustomerTable.NAME_ENGLISH     = CConvert.ToString(GetValue(dr, "NAME_ENGLISH"));
                    CustomerTable.ZIP_CODE         = CConvert.ToString(GetValue(dr, "ZIP_CODE"));
                    CustomerTable.ADDRESS_FIRST    = CConvert.ToString(GetValue(dr, "ADDRESS_FIRST"));
                    CustomerTable.ADDRESS_MIDDLE   = CConvert.ToString(GetValue(dr, "ADDRESS_MIDDLE"));
                    CustomerTable.ADDRESS_LAST     = CConvert.ToString(GetValue(dr, "ADDRESS_LAST"));
                    CustomerTable.PHONE_NUMBER     = CConvert.ToString(GetValue(dr, "PHONE_NUMBER"));
                    CustomerTable.FAX_NUMBER       = CConvert.ToString(GetValue(dr, "FAX_NUMBER"));
                    CustomerTable.CONTACT_NAME     = CConvert.ToString(GetValue(dr, "CONTACT_NAME"));
                    CustomerTable.MOBIL_NUMBER     = CConvert.ToString(GetValue(dr, "MOBIL_NUMBER"));
                    CustomerTable.EMAIL            = CConvert.ToString(GetValue(dr, "EMIAL"));
                    CustomerTable.URL              = CConvert.ToString(GetValue(dr, "URL"));
                    CustomerTable.MEMO             = CConvert.ToString(GetValue(dr, "MEMO"));
                    CustomerTable.TYPE             = CConvert.ToInt32(GetValue(dr, "TYPE", 1));
                    CustomerTable.CLAIM_FLAG       = CConvert.ToInt32(GetValue(dr, "CLAIM_FLAG", 1));
                    CustomerTable.CLAIM_CODE       = CConvert.ToString(GetValue(dr, "CLAIM_CODE"));
                    CustomerTable.CURRENCE_CODE    = CConvert.ToString(GetValue(dr, "CURRENCE_CODE"));
                    CustomerTable.STATUS_FLAG      = CConvert.ToInt32(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL));
                    CustomerTable.MEMO2            = CConvert.ToString(GetValue(dr, "MEMO2"));
                    CustomerTable.NAME_JP          = CConvert.ToString(GetValue(dr, "NAME_JP"));
                    CustomerTable.CREATE_USER      = _userInfo.CODE;
                    CustomerTable.LAST_UPDATE_USER = _userInfo.CODE;

                    if (!bCustomer.Exists(CustomerTable.CODE))
                    {
                        bCustomer.Add(CustomerTable);
                    }
                    else
                    {
                        bCustomer.Update(CustomerTable);
                    }
                    successData++;
                }
                catch
                {
                    strError.Append(GetStringBuilder(dr, " 数据导入失败,请与系统管理员联系!").ToString());
                    failureData++;
                }
            }
            //错误记录处理
            if (strError.Length > 0)
            {
                errorFilePath = WriteFile(strError.ToString());
            }
            //备份处理
            backupFilePath = BackupFile();

            return(new string[] { successData.ToString(), failureData.ToString(), errorFilePath, backupFilePath });
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 保存
        /// </summary>
        private void btnSave_Click_1(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                if (_currentCustomerTable == null)
                {
                    _currentCustomerTable = new BaseCustomerTable();
                }
                _currentCustomerTable.CODE             = txtCode.Text;
                _currentCustomerTable.NAME             = txtName.Text;
                _currentCustomerTable.NAME_SHORT       = txtNameShort.Text;
                _currentCustomerTable.NAME_ENGLISH     = txtEnglishName.Text;
                _currentCustomerTable.ZIP_CODE         = txtZipCode.Text;
                _currentCustomerTable.ADDRESS_FIRST    = txtAddressFirst.Text;
                _currentCustomerTable.ADDRESS_MIDDLE   = txtAddressMiddle.Text;
                _currentCustomerTable.ADDRESS_LAST     = txtAddressLast.Text;
                _currentCustomerTable.PHONE_NUMBER     = txtPhone.Text;
                _currentCustomerTable.FAX_NUMBER       = txtFax.Text;
                _currentCustomerTable.MOBIL_NUMBER     = txtMobilNumber.Text;
                _currentCustomerTable.CONTACT_NAME     = txtContactName.Text;
                _currentCustomerTable.EMAIL            = txtEmail.Text;
                _currentCustomerTable.URL              = txtURL.Text;
                _currentCustomerTable.MEMO             = txtMemo.Text;
                _currentCustomerTable.MEMO2            = txtMemo2.Text;
                _currentCustomerTable.CLAIM_CODE       = txtClaimCode.Text;
                _currentCustomerTable.CURRENCE_CODE    = txtCurrencyCode.Text;
                _currentCustomerTable.LAST_UPDATE_USER = _userInfo.CODE;
                _currentCustomerTable.NAME_JP          = txtName_Japan.Text.Trim();
                if (rType1.Checked)
                {
                    _currentCustomerTable.TYPE = 1;
                }
                else
                {
                    _currentCustomerTable.TYPE = 2;
                }

                if (rClaim1.Checked)
                {
                    _currentCustomerTable.CLAIM_FLAG = 1;
                    btnClaim.Enabled     = false;
                    txtClaimCode.Enabled = false;
                    txtClaimName.Enabled = false;
                }
                else
                {
                    _currentCustomerTable.CLAIM_FLAG = 2;
                    btnClaim.Enabled     = true;
                    txtClaimCode.Enabled = false;
                }

                try
                {
                    if (bCustomer.Exists(txtCode.Text.Trim()))
                    {
                        bCustomer.Update(_currentCustomerTable);
                    }
                    else
                    {
                        _currentCustomerTable.CREATE_USER = _userInfo.CODE;
                        bCustomer.Add(_currentCustomerTable);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                result = DialogResult.OK;
                this.Close();
            }
        }