public CResult<bool> UpdateTitleWageChangeRecord(TitleWageChangeRecord TitleWageChangeRecord)
 {
     if (TitleWageChangeRecord.TitleWageChangeRecordID <= 0) {
         return new CResult<bool>(false, ErrorCode.ParameterError);
     }
     var result = new TitleWageChangeRecordDAL().UpdateTitleWageChangeRecord(TitleWageChangeRecord);
     if (result) {
         return new CResult<bool>(true);
     } else {
         return new CResult<bool>(false, ErrorCode.SaveDataFailed);
     }
 }
        public CResult<bool> InsertTitleWageChangeRecord(TitleWageChangeRecord TitleWageChangeRecord)
        {
            if (TitleWageChangeRecord.PeopleID <= 0) {
                return new CResult<bool>(false, ErrorCode.ParameterError);
            }

            var result = new TitleWageChangeRecordDAL().InsertTitleWageChangeRecord(TitleWageChangeRecord);
            if (result) {
                return new CResult<bool>(true);
            } else {
                return new CResult<bool>(false, ErrorCode.DataNotExist);
            }
        }
        public TitleWageChangeRecord GetTitleWageChangeRecordByID(int TitleWageChangeRecordID)
        {
            using (var connection = new OleDbConnection(ConfigManagement.AccessConStr)) {
                string sqlText = string.Format(@"select
                    TitleWageChangeRecordID,
                    PeopleID,
                    ChangeDate,
                    ChangeType,
                    ContractNum,
                    BeforeChangeTitle,
                    BeforeChangeBasicWage,
                    BeforeChangeAllowance,
                    BeforeChangeYearAward,
                    AfterChangeTitle,
                    AfterChangeBasicWage,
                    AfterChangeAllowance,
                    AfterChangeYearAward
                    from {0} where TitleWageChangeRecordID=@TitleWageChangeRecordID", _TitleWageChangeRecordTableName);
                var paras = new OleDbParameter[1];
                paras[0] = new OleDbParameter("TitleWageChangeRecordID", TitleWageChangeRecordID);

                var reader = new OLESqlHelper().GetReader(sqlText, connection, paras);
                if (reader.Read()) {
                    int i = 0;
                    var TitleWageChangeRecord = new TitleWageChangeRecord();
                    TitleWageChangeRecord.TitleWageChangeRecordID = reader.GetInt32(i++);
                    TitleWageChangeRecord.PeopleID = reader.GetInt32(i++);
                    TitleWageChangeRecord.ChangeDate = reader.IsDBNull(i) ? new Nullable<DateTime>() : reader.GetDateTime(i++);
                    TitleWageChangeRecord.ChangeType = reader.GetInt32(i++);
                    TitleWageChangeRecord.ContractNum = reader.GetString(i++);
                    TitleWageChangeRecord.BeforeChangeTitle = reader.GetString(i++);
                    TitleWageChangeRecord.BeforeChangeBasicWage = reader.GetFloat(i++);
                    TitleWageChangeRecord.BeforeChangeAllowance = reader.GetFloat(i++);
                    TitleWageChangeRecord.BeforeChangeYearAward = reader.GetFloat(i++);
                    TitleWageChangeRecord.AfterChangeTitle = reader.GetString(i++);
                    TitleWageChangeRecord.AfterChangeBasicWage = reader.GetFloat(i++);
                    TitleWageChangeRecord.AfterChangeAllowance = reader.GetFloat(i++);
                    TitleWageChangeRecord.AfterChangeYearAward = reader.GetFloat(i++);
                    return TitleWageChangeRecord;
                } else {
                    return null;
                }
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            var record = new TitleWageChangeRecord();

            record.ChangeType = (int)(TitleChangeType)(Enum.Parse(typeof(TitleChangeType), this.cbxChangeType.SelectedItem.ToString()));
            record.AfterChangeTitle = this.txtAfterChangeTitle.Text;
            if (!string.IsNullOrWhiteSpace(this.txtAfterChangeAllowance.Text)) {
                record.AfterChangeAllowance = float.Parse(this.txtAfterChangeAllowance.Text);
            }
            if (!string.IsNullOrWhiteSpace(this.txtAfterChangeBasicWage.Text)) {
                record.AfterChangeBasicWage = float.Parse(this.txtAfterChangeBasicWage.Text);
            }
            if (!string.IsNullOrWhiteSpace(this.txtAfterChangeYearAward.Text)) {
                record.AfterChangeYearAward = float.Parse(this.txtAfterChangeYearAward.Text);
            }

            record.BeforeChangeTitle = this.txtBeforeChangeTitle.Text;
            if (!string.IsNullOrWhiteSpace(this.txtBeforeChangeallowance.Text)) {
                record.BeforeChangeAllowance = float.Parse(this.txtBeforeChangeallowance.Text);
            }
            if (!string.IsNullOrWhiteSpace(this.txtBeforeChangeBasicWage.Text)) {
                record.BeforeChangeBasicWage = float.Parse(this.txtBeforeChangeBasicWage.Text);
            }
            if (!string.IsNullOrWhiteSpace(this.txtBeforeChangeYearAward.Text)) {
                record.BeforeChangeYearAward = float.Parse(this.txtBeforeChangeYearAward.Text);
            }
            record.ChangeDate = this.dtpChangeDate.Value;
            record.ContractNum = this.txtContractNum.Text;

            CResult<bool> result = new CResult<bool>(false);
            if (_isEdit) {
                record.TitleWageChangeRecordID = this._titleWageChangeRecordID.Value;
                result = new TitleWageChangeRecordBLL().UpdateTitleWageChangeRecord(record);
            } else {
                record.PeopleID = this._peopleID.Value;
                result = new TitleWageChangeRecordBLL().InsertTitleWageChangeRecord(record);
            }
            MessageHelper.ShowSaveDbResultMessage(result);
            if (result.Code == 0) {
                this.Dispose();
                if (callbackEvent != null) {
                    callbackEvent.Invoke();
                }
            }
        }
        public List<TitleWageChangeRecord> GetTitleWageChangeRecordList(int peopleID)
        {
            string sqlText = string.Format(@"select
                TitleWageChangeRecordID,
                ChangeDate,
                ChangeType,
                ContractNum,
                BeforeChangeTitle,
                BeforeChangeBasicWage,
                BeforeChangeAllowance,
                BeforeChangeYearAward,
                AfterChangeTitle,
                AfterChangeBasicWage,
                AfterChangeAllowance,
                AfterChangeYearAward
                from {0}
                where PeopleID=@PeopleID"
                , _TitleWageChangeRecordTableName);

            var paras = new OleDbParameter[1];
            paras[0] = new OleDbParameter("PeopleID", peopleID);

            var table = new OLESqlHelper().GetTable(sqlText, paras);

            var TitleWageChangeRecordList = new List<TitleWageChangeRecord>();
            foreach (DataRow row in table.Rows) {
                var TitleWageChangeRecord = new TitleWageChangeRecord() {
                    TitleWageChangeRecordID = (int)row["TitleWageChangeRecordID"],
                    ChangeDate = (DateTime?)row["ChangeDate"],
                    ChangeType = (int)row["ChangeType"],
                    ContractNum = row["ContractNum"].ToString(),
                    BeforeChangeTitle = row["BeforeChangeTitle"].ToString(),
                    BeforeChangeBasicWage = (float)row["BeforeChangeBasicWage"],
                    BeforeChangeAllowance = (float)row["BeforeChangeAllowance"],
                    BeforeChangeYearAward = (float)row["BeforeChangeYearAward"],
                    AfterChangeTitle = row["AfterChangeTitle"].ToString(),
                    AfterChangeBasicWage = (float)row["AfterChangeBasicWage"],
                    AfterChangeAllowance = (float)row["AfterChangeAllowance"],
                    AfterChangeYearAward = (float)row["AfterChangeYearAward"]
                };
                TitleWageChangeRecordList.Add(TitleWageChangeRecord);
            }
            return TitleWageChangeRecordList;
        }
        public bool UpdateTitleWageChangeRecord(TitleWageChangeRecord TitleWageChangeRecord)
        {
            string sqlText = string.Format(@"update {0} set
                ChangeDate=@ChangeDate,
                ChangeType=@ChangeType,
                ContractNum=@ContractNum,
                BeforeChangeTitle=@BeforeChangeTitle,
                BeforeChangeBasicWage=@BeforeChangeBasicWage,
                BeforeChangeallowance=@BeforeChangeAllowance,
                BeforeChangeYearAward=@BeforeChangeYearAward,
                AfterChangeTitle=@AfterChangeTitle,
                AfterChangeBasicWage=@AfterChangeBasicWage,
                AfterChangeAllowance=@AfterChangeAllowance,
                AfterChangeYearAward=@AfterChangeYearAward
                where TitleWageChangeRecordID=@TitleWageChangeRecordID", _TitleWageChangeRecordTableName);
            var paras = new OleDbParameter[12];
            paras[0] = new OleDbParameter("ChangeDate", TitleWageChangeRecord.ChangeDate);
            paras[0].OleDbType = OleDbType.DBDate;
            paras[1] = new OleDbParameter("ChangeType", TitleWageChangeRecord.ChangeType);
            paras[2] = new OleDbParameter("ContractNum", TitleWageChangeRecord.ContractNum);
            paras[3] = new OleDbParameter("BeforeChangeTitle", TitleWageChangeRecord.BeforeChangeTitle);
            paras[4] = new OleDbParameter("BeforeChangeBasicWage", TitleWageChangeRecord.BeforeChangeBasicWage);
            paras[5] = new OleDbParameter("BeforeChangeAllowance", TitleWageChangeRecord.BeforeChangeAllowance);
            paras[6] = new OleDbParameter("BeforeChangeYearAward", TitleWageChangeRecord.BeforeChangeYearAward);
            paras[7] = new OleDbParameter("AfterChangeTitle", TitleWageChangeRecord.AfterChangeTitle);
            paras[8] = new OleDbParameter("AfterChangeBasicWage", TitleWageChangeRecord.AfterChangeBasicWage);
            paras[9] = new OleDbParameter("AfterChangeAllowance", TitleWageChangeRecord.AfterChangeAllowance);
            paras[10] = new OleDbParameter("AfterChangeYearAward", TitleWageChangeRecord.AfterChangeYearAward);
            paras[11] = new OleDbParameter("TitleWageChangeRecordID", TitleWageChangeRecord.TitleWageChangeRecordID);

            var result = new OLESqlHelper().ExecuteNoneQuery(sqlText, paras);
            return result;
        }
        public bool InsertTitleWageChangeRecord(TitleWageChangeRecord TitleWageChangeRecord)
        {
            string sqlText = string.Format(@"insert into {0}(
                    PeopleID,
                    ChangeDate,
                    ChangeType,
                    ContractNum,
                    BeforeChangeTitle,
                    BeforeChangeBasicWage,
                    BeforeChangeAllowance,
                    BeforeChangeYearAward,
                    AfterChangeTitle,
                    AfterChangeBasicWage,
                    AfterChangeAllowance,
                    AfterChangeYearAward
                )
                values(
                    @PeopleID,
                    @ChangeDate,
                    @ChangeType,
                    @ContractNum,
                    @BeforeChangeTitle,
                    @BeforeChangeBasicWage,
                    @BeforeChangeAllowance,
                    @BeforeChangeYearAward,
                    @AfterChangeTitle,
                    @AfterChangeBasicWage,
                    @AfterChangeAllowance,
                    @AfterChangeYearAward)", _TitleWageChangeRecordTableName);
            var paras = new OleDbParameter[12];
            paras[0] = new OleDbParameter("PeopleID", TitleWageChangeRecord.PeopleID);
            paras[1] = new OleDbParameter("ChangeDate", TitleWageChangeRecord.ChangeDate);
            paras[1].OleDbType = OleDbType.Date;
            paras[2] = new OleDbParameter("ChangeType", TitleWageChangeRecord.ChangeType);
            paras[3] = new OleDbParameter("ContractNum", TitleWageChangeRecord.ContractNum);
            paras[4] = new OleDbParameter("BeforeChangeTitle", TitleWageChangeRecord.BeforeChangeTitle);
            paras[5] = new OleDbParameter("BeforeChangeBasicWage", TitleWageChangeRecord.BeforeChangeBasicWage);
            paras[6] = new OleDbParameter("BeforeChangeAllowance", TitleWageChangeRecord.BeforeChangeAllowance);
            paras[7] = new OleDbParameter("BeforeChangeYearAward", TitleWageChangeRecord.BeforeChangeYearAward);
            paras[8] = new OleDbParameter("AfterChangeTitle", TitleWageChangeRecord.AfterChangeTitle);
            paras[9] = new OleDbParameter("AfterChangeBasicWage", TitleWageChangeRecord.AfterChangeBasicWage);
            paras[10] = new OleDbParameter("AfterChangeAllowance", TitleWageChangeRecord.AfterChangeAllowance);
            paras[11] = new OleDbParameter("AfterChangeYearAward", TitleWageChangeRecord.AfterChangeYearAward);

            var result = new OLESqlHelper().ExecuteNoneQuery(sqlText, paras);
            return result;
        }