public InsuranceFund GetInsuranceFundByID(int InsuranceFundID)
        {
            using (var connection = new OleDbConnection(ConfigManagement.AccessConStr)) {
                string sqlText = string.Format(@"select
                    InsuranceFundID,
                    PeopleID,
                    InsuranceFundType,
                    Number,
                    PaymentAddress,
                    PaymentStartDate,
                    PaymentEndDate,
                    BasicNum
                    from {0} where InsuranceFundID=@InsuranceFundID", _InsuranceFundTableName);
                var paras = new OleDbParameter[1];
                paras[0] = new OleDbParameter("InsuranceFundID", InsuranceFundID);

                var reader = new OLESqlHelper().GetReader(sqlText, connection, paras);
                if (reader.Read()) {
                    int i = 0;
                    var InsuranceFund = new InsuranceFund();
                    InsuranceFund.InsuranceFundID = reader.GetInt32(i++);
                    InsuranceFund.PeopleID = reader.GetInt32(i++);
                    InsuranceFund.InsuranceFundType = (int)reader.GetInt32(i++);
                    InsuranceFund.Number = reader.GetString(i++);
                    InsuranceFund.PaymentAddress = reader.GetString(i++);
                    InsuranceFund.PaymentStartDate = reader.IsDBNull(i) ? new Nullable<DateTime>() : reader.GetDateTime(i++);
                    InsuranceFund.PaymentEndDate = reader.IsDBNull(i) ? new Nullable<DateTime>() : reader.GetDateTime(i++);
                    InsuranceFund.BasicNum = reader.GetFloat(i++);

                    return InsuranceFund;
                } else {
                    return null;
                }
            }
        }
 public CResult<bool> UpdateInsuranceFund(InsuranceFund InsuranceFund)
 {
     if (InsuranceFund.InsuranceFundID <= 0) {
         return new CResult<bool>(false, ErrorCode.ParameterError);
     }
     var result = new InsuranceFundDAL().UpdateInsuranceFund(InsuranceFund);
     if (result) {
         return new CResult<bool>(true);
     } else {
         return new CResult<bool>(false, ErrorCode.SaveDataFailed);
     }
 }
        public CResult<bool> InsertInsuranceFund(InsuranceFund InsuranceFund)
        {
            if (InsuranceFund.PeopleID <= 0) {
                return new CResult<bool>(false, ErrorCode.ParameterError);
            }

            var result = new InsuranceFundDAL().InsertInsuranceFund(InsuranceFund);
            if (result) {
                return new CResult<bool>(true);
            } else {
                return new CResult<bool>(false, ErrorCode.DataNotExist);
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            var bll = new InsuranceFundBLL();

            var fund = new InsuranceFund();
            fund.InsuranceFundType = (int)InsuranceFundType.住房公积金;
            fund.Number = this.txtHouseNumber.Text;
            fund.PaymentAddress = this.txtHousePaymentAddress.Text;
            fund.PaymentStartDate = this.dtphousePaymentStartDate.Value;
            if (this.dtpHousePaymentEndDate.Checked) {
                fund.PaymentEndDate = this.dtpHousePaymentEndDate.Value;
            }
            if (!string.IsNullOrWhiteSpace(this.txtHouseBasicNum.Text)) {
                fund.BasicNum = float.Parse(this.txtHouseBasicNum.Text);
            }

            var insurance = new InsuranceFund();
            insurance.InsuranceFundType = (int)InsuranceFundType.社保;
            insurance.Number = this.txtSocialNumber.Text;
            insurance.PaymentAddress = this.txtSocialPaymentAddress.Text;
            insurance.PaymentStartDate = this.dtpSocialPaymentStartDate.Value;
            if (this.dtpSocialPaymentEndDate.Checked) {
                insurance.PaymentEndDate = this.dtpSocialPaymentEndDate.Value;
            }
            if (!string.IsNullOrWhiteSpace(this.txtSocialBasicNum.Text)) {
                insurance.BasicNum = float.Parse(this.txtSocialBasicNum.Text);
            }

            var result = true;
            if (isEdit) {
                fund.InsuranceFundID = this._fundID.Value;
                result = result && bll.UpdateInsuranceFund(fund).Data;

                insurance.InsuranceFundID = this._insuranceID.Value;
                result = result && bll.UpdateInsuranceFund(insurance).Data;
            } else {
                fund.PeopleID = this._currentPeopleID;
                result = result && bll.InsertInsuranceFund(fund).Data;

                insurance.PeopleID = this._currentPeopleID;
                result = result && bll.InsertInsuranceFund(insurance).Data;
            }
            if (result) {
                MessageBox.Show("操作成功!");
            } else {
                MessageBox.Show("操作失败!");
            }
        }
        public List<InsuranceFund> GetInsuranceFundList(int peopleID)
        {
            string sqlText = string.Format(@"select
                InsuranceFundID,
                InsuranceFundType,
                Number,
                PaymentAddress,
                PaymentStartDate,
                PaymentEndDate,
                BasicNum
                from {0}
                where PeopleID=@PeopleID"
                , _InsuranceFundTableName);

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

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

            var InsuranceFundList = new List<InsuranceFund>();
            foreach (DataRow row in table.Rows) {
                var peopleFamily = new InsuranceFund() {
                    InsuranceFundID = (int)row["InsuranceFundID"],
                    InsuranceFundType = (int)row["InsuranceFundType"],
                    Number = row["Number"].ToString(),
                    PaymentAddress = row["PaymentAddress"].ToString(),
                    PaymentStartDate = (DateTime?)row["PaymentStartDate"],
                    PaymentEndDate = row.IsNull("PaymentEndDate") ? null : (DateTime?)row["PaymentEndDate"],
                    BasicNum = (float)row["BasicNum"]
                };
                InsuranceFundList.Add(peopleFamily);
            }
            return InsuranceFundList;
        }
        public bool UpdateInsuranceFund(InsuranceFund InsuranceFund)
        {
            string sqlText = string.Format(@"update {0} set
                    InsuranceFundType=@InsuranceFundType,
                    [Number]=@Number,
                    PaymentAddress=@PaymentAddress,
                    PaymentStartDate=@PaymentStartDate,
                    PaymentEndDate=@PaymentEndDate,
                    BasicNum=@BasicNum
                where InsuranceFundID=@InsuranceFundID", _InsuranceFundTableName);
            var paras = new OleDbParameter[7];
            paras[0] = new OleDbParameter("InsuranceFundType", InsuranceFund.InsuranceFundType);
            paras[1] = new OleDbParameter("Number", InsuranceFund.Number);
            paras[2] = new OleDbParameter("PaymentAddress", InsuranceFund.PaymentAddress);
            paras[3] = new OleDbParameter("PaymentStartDate", InsuranceFund.PaymentStartDate);
            paras[4] = new OleDbParameter("PaymentEndDate", InsuranceFund.PaymentEndDate);
            paras[5] = new OleDbParameter("BasicNum", InsuranceFund.BasicNum);
            paras[6] = new OleDbParameter("InsuranceFundID", InsuranceFund.InsuranceFundID);

            var result = new OLESqlHelper().ExecuteNoneQuery(sqlText, paras);
            return result;
        }
        public bool InsertInsuranceFund(InsuranceFund InsuranceFund)
        {
            string sqlText = string.Format(@"insert into {0}(
                PeopleID,
                InsuranceFundType,
                [Number],
                PaymentAddress,
                PaymentStartDate,
                PaymentEndDate,
                BasicNum
                )
                values(
                @PeopleID,
                @InsuranceFundType,
                @Number,
                @PaymentAddress,
                @PaymentStartDate,
                @PaymentEndDate,
                @BasicNum)", _InsuranceFundTableName);
            var paras = new OleDbParameter[7];
            paras[0] = new OleDbParameter("PeopleID", InsuranceFund.PeopleID);
            paras[1] = new OleDbParameter("InsuranceFundType", InsuranceFund.InsuranceFundType);
            paras[2] = new OleDbParameter("Number", InsuranceFund.Number);
            paras[3] = new OleDbParameter("PaymentAddress", InsuranceFund.PaymentAddress);
            paras[4] = new OleDbParameter("PaymentStartDate", InsuranceFund.PaymentStartDate);
            paras[4].OleDbType = OleDbType.DBDate;
            paras[5] = new OleDbParameter("PaymentEndDate", InsuranceFund.PaymentEndDate);
            paras[5].OleDbType = OleDbType.DBDate;
            paras[6] = new OleDbParameter("BasicNum", InsuranceFund.BasicNum);

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