Exemple #1
0
        /// <summary>
        /// 保存
        /// </summary>
        private void btnSave_Click_1(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                if (_currentWarehouseTable == null)
                {
                    _currentWarehouseTable = new BaseWarehouseTable();
                }

                _currentWarehouseTable.CODE             = txtCode.Text.Trim();
                _currentWarehouseTable.NAME             = txtName.Text.Trim();
                _currentWarehouseTable.NAME_SHORT       = txtNameShort.Text.Trim();
                _currentWarehouseTable.ZIP_CODE         = txtZipCode.Text.Trim();
                _currentWarehouseTable.ADDRESS_FIRST    = txtAddressFirst.Text.Trim();
                _currentWarehouseTable.ADDRESS_MIDDLE   = txtAddressMiddle.Text.Trim();
                _currentWarehouseTable.ADDRESS_LAST     = txtAddressLast.Text.Trim();
                _currentWarehouseTable.PHONE_NUMBER     = txtPhone.Text.Trim();
                _currentWarehouseTable.FAX_NUMBER       = txtFax.Text.Trim();
                _currentWarehouseTable.MOBIL_NUMBER     = txtMobil.Text.Trim();
                _currentWarehouseTable.CONTACT_NAME     = txtContactName.Text.Trim();
                _currentWarehouseTable.EMAIL            = txtEmail.Text.Trim();
                _currentWarehouseTable.MEMO             = txtMemo.Text.Trim();
                _currentWarehouseTable.LAST_UPDATE_USER = _userInfo.CODE;

                try
                {
                    if (bWarehouse.Exists(txtCode.Text.Trim()))
                    {
                        bWarehouse.Update(_currentWarehouseTable);
                    }
                    else
                    {
                        _currentWarehouseTable.CREATE_USER = _userInfo.CODE;
                        bWarehouse.Add(_currentWarehouseTable);
                    }
                }
                catch (Exception ex)
                {
                    //log.error
                    MessageBox.Show("");
                    return;
                }
                result = DialogResult.OK;
                this.Close();
                CCacheData.WAREHOUSE = null;
            }
        }
Exemple #2
0
        public override string[] doUpdateDB()
        {
            BaseWarehouseTable WarehouseTable = null;
            BWarehouse         bWarehouse     = new BWarehouse();
            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, "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, "MEMO"), 255, "备注"));
                //状态
                str.Append(CheckInt(GetValue(dr, "STATUS_FLAG", 1), 9, "状态"));

                if (str.ToString().Trim().Length > 0)
                {
                    strError.Append(GetStringBuilder(dr, str.ToString().Trim()));
                    failureData++;
                    continue;
                }
                try
                {
                    WarehouseTable                  = new BaseWarehouseTable();
                    WarehouseTable.CODE             = CConvert.ToString(GetValue(dr, "CODE"));
                    WarehouseTable.NAME             = CConvert.ToString(GetValue(dr, "NAME"));
                    WarehouseTable.NAME_SHORT       = CConvert.ToString(GetValue(dr, "NAME_SHORT"));
                    WarehouseTable.ZIP_CODE         = CConvert.ToString(GetValue(dr, "ZIP_CODE"));
                    WarehouseTable.ADDRESS_FIRST    = CConvert.ToString(GetValue(dr, "ADDRESS_FIRST"));
                    WarehouseTable.ADDRESS_MIDDLE   = CConvert.ToString(GetValue(dr, "ADDRESS_MIDDLE"));
                    WarehouseTable.ADDRESS_LAST     = CConvert.ToString(GetValue(dr, "ADDRESS_LAST"));
                    WarehouseTable.PHONE_NUMBER     = CConvert.ToString(GetValue(dr, "PHONE_NUMBER"));
                    WarehouseTable.FAX_NUMBER       = CConvert.ToString(GetValue(dr, "FAX_NUMBER"));
                    WarehouseTable.CONTACT_NAME     = CConvert.ToString(GetValue(dr, "CONTACT_NAME"));
                    WarehouseTable.MOBIL_NUMBER     = CConvert.ToString(GetValue(dr, "MOBIL_NUMBER"));
                    WarehouseTable.EMAIL            = CConvert.ToString(GetValue(dr, "EMIAL"));
                    WarehouseTable.MEMO             = CConvert.ToString(GetValue(dr, "MEMO"));
                    WarehouseTable.STATUS_FLAG      = CConvert.ToInt32(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS));
                    WarehouseTable.CREATE_USER      = _userInfo.CODE;
                    WarehouseTable.LAST_UPDATE_USER = _userInfo.CODE;

                    if (!bWarehouse.Exists(WarehouseTable.CODE))
                    {
                        WarehouseTable.CREATE_DATE_TIME = DateTime.Now;
                        WarehouseTable.LAST_UPDATE_TIME = DateTime.Now;
                        bWarehouse.Add(WarehouseTable);
                    }
                    else
                    {
                        WarehouseTable.LAST_UPDATE_TIME = DateTime.Now;
                        bWarehouse.Update(WarehouseTable);
                    }
                    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 });
        }