/// <summary>
        /// 获取输入的信息
        /// </summary>
        /// <returns>名片类</returns>
        private BaseBusinessCardEntity GetEntity()
        {
            BaseBusinessCardEntity businessCardEntity = new BaseBusinessCardEntity();

            // 这里提高主键产生速度
            businessCardEntity.Id          = System.Guid.NewGuid().ToString();
            businessCardEntity.FullName    = this.txtFullName.Text;
            businessCardEntity.Title       = this.txtTitle.Text;
            businessCardEntity.Company     = this.ucCompany.SelectedFullName;
            businessCardEntity.Phone       = this.txtPhone.Text;
            businessCardEntity.Postalcode  = this.txtPostalcode.Text;
            businessCardEntity.Mobile      = this.txtMobile.Text;
            businessCardEntity.Address     = this.txtAddress.Text;
            businessCardEntity.Email       = this.txtEmail.Text;
            businessCardEntity.OfficePhone = this.txtOfficePhone.Text;
            businessCardEntity.QQ          = this.txtQQ.Text;
            businessCardEntity.Fax         = this.txtFax.Text;
            businessCardEntity.Web         = this.txtWeb.Text;
            businessCardEntity.BankName    = this.txtBankName.Text;
            businessCardEntity.BankAccount = this.txtBankAccount.Text;
            businessCardEntity.TaxAccount  = this.txtTaxAccount.Text;
            businessCardEntity.Personal    = this.chkPersonal.Checked;
            businessCardEntity.Description = this.txtDescription.Text;
            return(businessCardEntity);
        }
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="businessCardEntity">实体</param>
        public string AddEntity(BaseBusinessCardEntity businessCardEntity)
        {
            string returnValue = string.Empty;

            if (String.IsNullOrEmpty(businessCardEntity.Id) || String.IsNullOrEmpty(businessCardEntity.SortCode))
            {
                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper);
                string sequence = sequenceManager.GetSequence(BaseBusinessCardTable.TableName);
                if (String.IsNullOrEmpty(businessCardEntity.Id))
                {
                    businessCardEntity.Id = sequence;
                }
                if (String.IsNullOrEmpty(businessCardEntity.SortCode))
                {
                    businessCardEntity.SortCode = sequence;
                }
            }
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);

            sqlBuilder.BeginInsert(this.CurrentTableName);
            sqlBuilder.SetValue(BaseBusinessCardTable.FieldId, businessCardEntity.Id);
            this.SetEntity(sqlBuilder, businessCardEntity);
            sqlBuilder.SetValue(BaseBusinessCardTable.FieldCreateBy, UserInfo.RealName);
            sqlBuilder.SetValue(BaseBusinessCardTable.FieldCreateUserId, UserInfo.Id);
            sqlBuilder.SetDBNow(BaseBusinessCardTable.FieldCreateOn);
            return(sqlBuilder.EndInsert() > 0 ? businessCardEntity.Id : string.Empty);
        }
        /// <summary>
        /// 检查批量删除的输入的有效性
        /// </summary>
        /// <returns>允许批量删除</returns>
        private bool CheckInputBatchDelete()
        {
            bool returnValue   = false;
            int  selectedCount = 0;
            BaseBusinessCardEntity businessCardEntity = new BaseBusinessCardEntity();

            foreach (DataRowView DataRowView in this.DTBusinessCard.DefaultView)
            {
                DataRow dataRow = DataRowView.Row;
                if (dataRow.RowState != DataRowState.Deleted)
                {
                    if (dataRow[BaseBusinessLogic.SelectedColumn].ToString() == true.ToString())
                    {
                        businessCardEntity = new BaseBusinessCardEntity(dataRow);
                        // 有权限删除
                        if (this.permissionEditPublic || businessCardEntity.CreateUserId.Equals(UserInfo.Id))
                        {
                            selectedCount++;
                        }
                        else
                        {
                            // MessageBox.Show(AppMessage.MSG0024, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return(returnValue);
                        }
                    }
                }
            }
            // 有记录被选中了
            returnValue = selectedCount > 0;
            if (!returnValue)
            {
                MessageBox.Show(AppMessage.MSG0024, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(returnValue);
        }
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>数据表</returns>
        public BaseBusinessCardEntity GetEntity(BaseUserInfo userInfo, string id)
        {
            DataTable dataTable = this.Get(userInfo, id);
            BaseBusinessCardEntity businessCardEntity = new BaseBusinessCardEntity(dataTable);

            return(businessCardEntity);
        }
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="id">主键</param>
        public BaseBusinessCardEntity GetEntity(string id)
        {
            DataTable dataTable = this.GetDataTableById(id);
            BaseBusinessCardEntity businessCardEntity = new BaseBusinessCardEntity(dataTable);

            return(businessCardEntity);
        }
Example #6
0
        private void btnLikeAdd_Click(object sender, EventArgs e)
        {
            BaseBusinessCardEntity entity = GetEntity();

            entity.Id = null;
            FrmBusinessCardAdd frmBusinessCardAdd = new FrmBusinessCardAdd(entity);

            frmBusinessCardAdd.ShowDialog();
        }
Example #7
0
        /// <summary>
        /// 加载窗体
        /// </summary>
        public override void FormOnLoad()
        {
            BusinessCardService businessCardService = new BusinessCardService();

            this.BusinessCardEntity = businessCardService.GetEntity(UserInfo, this.EntityId);
            // 显示内容
            this.ShowEntity(this.BusinessCardEntity);
            // 设置焦点
            this.ActiveControl = this.txtFullName;
            this.txtFullName.Focus();
        }
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="businessCardEntity">实体</param>
        public int UpdateEntity(BaseBusinessCardEntity businessCardEntity)
        {
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);

            sqlBuilder.BeginUpdate(this.CurrentTableName);
            this.SetEntity(sqlBuilder, businessCardEntity);
            sqlBuilder.SetValue(BaseBusinessCardTable.FieldModifiedBy, UserInfo.RealName);
            sqlBuilder.SetValue(BaseBusinessCardTable.FieldModifiedUserId, UserInfo.Id);
            sqlBuilder.SetDBNow(BaseBusinessCardTable.FieldModifiedOn);
            sqlBuilder.SetWhere(BaseBusinessCardTable.FieldId, businessCardEntity.Id);
            return(sqlBuilder.EndUpdate());
        }
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="businessCardEntity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <param name="statusMessage">返回状态信息</param>
        /// <returns>影响行数</returns>
        public int UpdateEntity(BaseUserInfo userInfo, BaseBusinessCardEntity businessCardEntity, out string statusCode, out string statusMessage)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif
            statusCode    = string.Empty;
            statusMessage = string.Empty;

            int returnValue = 0;

            // 使用工厂模式 传入 数据库类型
            IDbHelper dbHelper = null;
            if (DbHelper.DbType == CurrentDbType.Access)
            {
                dbHelper = DbHelperFactory.GetHelper(DbHelper.DbType);
            }
            else
            {
                dbHelper = DbHelperFactory.GetHelper();
            }

            // IDbHelper dbHelper = DbHelperFactory.GetHelper();
            try
            {
                dbHelper.Open(UserCenterDbConnection);
                BaseBusinessCardManager businessCardManager = new BaseBusinessCardManager(dbHelper, userInfo);
                // 编辑数据
                returnValue = businessCardManager.Update(businessCardEntity);
                // returnValue = businessCardManager.Update(businessCardEntity, out statusCode);

                statusMessage = businessCardManager.GetStateMessage(statusCode);
                BaseLogManager.Instance.Add(dbHelper, userInfo, MethodBase.GetCurrentMethod());
            }
            catch (Exception ex)
            {
                BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                throw ex;
            }
            finally
            {
                dbHelper.Close();
            }

            // 写入调试信息
            #if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif
            return(returnValue);
        }
        /// <summary>
        /// 批量保存
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="dataTable">数据表</param>
        /// <returns>影响行数</returns>
        public int BatchSave(BaseUserInfo userInfo, DataTable dataTable)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            int returnValue = 0;

            // 使用工厂模式 传入 数据库类型
            IDbHelper dbHelper = null;
            if (DbHelper.DbType == CurrentDbType.Access)
            {
                dbHelper = DbHelperFactory.GetHelper(DbHelper.DbType);
            }
            else
            {
                dbHelper = DbHelperFactory.GetHelper();
            }

            // IDbHelper dbHelper = DbHelperFactory.GetHelper();
            try
            {
                dbHelper.Open(UserCenterDbConnection);
                BaseBusinessCardManager businessCardManager = new BaseBusinessCardManager(dbHelper, userInfo);
                BaseBusinessCardEntity  businessCardEntity  = null;
                foreach (DataRow dataRow in dataTable.Rows)
                {
                    businessCardEntity = new BaseBusinessCardEntity(dataRow);
                    returnValue       += businessCardManager.Update(businessCardEntity);
                }
                BaseLogManager.Instance.Add(dbHelper, userInfo, MethodBase.GetCurrentMethod());
            }
            catch (Exception ex)
            {
                BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                throw ex;
            }
            finally
            {
                dbHelper.Close();
            }

            // 写入调试信息
            #if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif
            return(returnValue);
        }
Example #11
0
 /// <summary>
 /// 显示内容
 /// </summary>
 private void ShowEntity(BaseBusinessCardEntity businessCardEntity)
 {
     this.txtFullName.Text           = businessCardEntity.FullName;
     this.txtTitle.Text              = businessCardEntity.Title;
     this.ucCompany.SelectedFullName = businessCardEntity.Company;
     this.txtPhone.Text              = businessCardEntity.Phone;
     this.txtPostalcode.Text         = businessCardEntity.Postalcode;
     this.txtMobile.Text             = businessCardEntity.Mobile;
     this.txtAddress.Text            = businessCardEntity.Address;
     this.txtEmail.Text              = businessCardEntity.Email;
     this.txtOfficePhone.Text        = businessCardEntity.OfficePhone;
     this.txtQQ.Text          = businessCardEntity.QQ;
     this.txtFax.Text         = businessCardEntity.Fax;
     this.txtWeb.Text         = businessCardEntity.Web;
     this.txtBankName.Text    = businessCardEntity.BankName;
     this.txtBankAccount.Text = businessCardEntity.BankAccount;
     this.txtTaxAccount.Text  = businessCardEntity.TaxAccount;
     this.chkPersonal.Checked = businessCardEntity.Personal;
     this.txtDescription.Text = businessCardEntity.Description;
 }
        /// <summary>
        /// 编辑
        /// </summary>
        public void Edit()
        {
            DataRow dataRow = BaseInterfaceLogic.GetDataGridViewEntity(this.grdBusinessCard);
            BaseBusinessCardEntity businessCardEntity = new BaseBusinessCardEntity(dataRow);

            // 有权限编辑
            if (this.permissionEditPublic || businessCardEntity.CreateUserId.Equals(UserInfo.Id))
            {
                string id = BaseInterfaceLogic.GetDataGridViewEntityId(this.grdBusinessCard, BaseItemDetailsEntity.FieldId);
                FrmBusinessCardEdit frmBusinessCardEdit = new FrmBusinessCardEdit(id);
                if (frmBusinessCardEdit.ShowDialog() == DialogResult.OK)
                {
                    // 获取列表
                    this.Search();
                }
            }
            else
            {
                // 没有权限编辑公开的名片
            }
        }
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="businessCardEntity">实体</param>
 private void SetEntity(SQLBuilder sqlBuilder, BaseBusinessCardEntity businessCardEntity)
 {
     sqlBuilder.SetValue(BaseBusinessCardTable.FieldFullName, businessCardEntity.FullName);
     sqlBuilder.SetValue(BaseBusinessCardTable.FieldTitle, businessCardEntity.Title);
     sqlBuilder.SetValue(BaseBusinessCardTable.FieldCompany, businessCardEntity.Company);
     sqlBuilder.SetValue(BaseBusinessCardTable.FieldPhone, businessCardEntity.Phone);
     sqlBuilder.SetValue(BaseBusinessCardTable.FieldPostalcode, businessCardEntity.Postalcode);
     sqlBuilder.SetValue(BaseBusinessCardTable.FieldMobile, businessCardEntity.Mobile);
     sqlBuilder.SetValue(BaseBusinessCardTable.FieldAddress, businessCardEntity.Address);
     sqlBuilder.SetValue(BaseBusinessCardTable.FieldEmail, businessCardEntity.Email);
     sqlBuilder.SetValue(BaseBusinessCardTable.FieldOfficePhone, businessCardEntity.OfficePhone);
     sqlBuilder.SetValue(BaseBusinessCardTable.FieldQQ, businessCardEntity.QQ);
     sqlBuilder.SetValue(BaseBusinessCardTable.FieldFax, businessCardEntity.Fax);
     sqlBuilder.SetValue(BaseBusinessCardTable.FieldWeb, businessCardEntity.Web);
     sqlBuilder.SetValue(BaseBusinessCardTable.FieldBankName, businessCardEntity.BankName);
     sqlBuilder.SetValue(BaseBusinessCardTable.FieldBankAccount, businessCardEntity.BankAccount);
     sqlBuilder.SetValue(BaseBusinessCardTable.FieldTaxAccount, businessCardEntity.TaxAccount);
     sqlBuilder.SetValue(BaseBusinessCardTable.FieldPersonal, businessCardEntity.Personal ? 1:0);
     sqlBuilder.SetValue(BaseBusinessCardTable.FieldSortCode, businessCardEntity.SortCode);
     sqlBuilder.SetValue(BaseBusinessCardTable.FieldDescription, businessCardEntity.Description);
 }
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="dataTable">数据表</param>
        /// <param name="statusCode">返回状态码</param>
        /// <param name="statusMessage">返回状态信息</param>
        /// <returns>影响行数</returns>
        public int Update(BaseUserInfo userInfo, DataTable dataTable, out string statusCode, out string statusMessage)
        {
            BaseBusinessCardEntity businessCardEntity = new BaseBusinessCardEntity(dataTable);

            return(this.UpdateEntity(userInfo, businessCardEntity, out statusCode, out statusMessage));
        }
 public FrmBusinessCardAdd(BaseBusinessCardEntity entity)
     : this()
 {
     this.businessCardEntity = entity;
 }
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="businessCardEntity">实体</param>
 public int Update(BaseBusinessCardEntity businessCardEntity)
 {
     return(this.UpdateEntity(businessCardEntity));
 }
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="businessCardEntity">实体</param>
 public string Add(BaseBusinessCardEntity businessCardEntity)
 {
     return(this.AddEntity(businessCardEntity));
 }