示例#1
0
        /// <summary>
        /// 增加一个优抚人员
        /// </summary>
        /// <param name="YouFu">优抚人员</param>
        /// <returns></returns>
        public static int AddYouFu(YouFu YouFu)
        {
            int iExecute = 0;
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into AnFu_Info (");
                strSql.Append("Name,Military_time,Local_Address,Local_Phone,IsDiBao,NoLocal_Address,NoLocal_Phone,AnFu_Type,AnFu_Rank,IsAtJob,IsAtCountryside");
                strSql.Append(",IsElderPartyMember,Annual_Money,Care_Fee,Dead_Time,IsNewAdd,IsEnterMicro,Remark,Area,IdCard,Birthday");
                strSql.Append(") values(");
                strSql.Append("@Name,@Military_time,@Local_Address,@Local_Phone,@IsDiBao,@NoLocal_Address,@NoLocal_Phone,@AnFu_Type,@AnFu_Rank,@IsAtJob,@IsAtCountryside");
                strSql.Append(",@IsElderPartyMember,@Annual_Money,@Care_Fee,@Dead_Time,@IsNewAdd,@IsEnterMicro,@Remark,@Area,@IdCard,@Birthday");
                strSql.Append(");select @@IDENTITY");
                SqlParameter[] para = new SqlParameter[]
                {
                new SqlParameter("@Name",SqlDbType.NVarChar,50),
                new SqlParameter("@Military_time",SqlDbType.Date),
                new SqlParameter("@Local_Address",SqlDbType.NVarChar),
                new SqlParameter("@Local_Phone",SqlDbType.NVarChar,20),
                new SqlParameter("@IsDiBao",SqlDbType.NChar,10),
                new SqlParameter("@NoLocal_Address",SqlDbType.NVarChar),
                new SqlParameter("@NoLocal_Phone",SqlDbType.NVarChar,20),
                new SqlParameter("@AnFu_Type",SqlDbType.NVarChar,50),
                new SqlParameter("@AnFu_Rank",SqlDbType.NVarChar,50),
                new SqlParameter("@IsAtJob",SqlDbType.NChar,10),
                new SqlParameter("@IsAtCountryside",SqlDbType.NChar,10),
                new SqlParameter("@IsElderPartyMember",SqlDbType.NChar,10),
                new SqlParameter("@Annual_Money",SqlDbType.Decimal),
                new SqlParameter("@Care_Fee",SqlDbType.Decimal),
                new SqlParameter("@Dead_Time",SqlDbType.Date),
                new SqlParameter("@IsNewAdd",SqlDbType.NChar,10),
                new SqlParameter("@IsEnterMicro",SqlDbType.NChar,10),
                new SqlParameter("@Remark",SqlDbType.Text),
                new SqlParameter("@Area",SqlDbType.NVarChar,50),
                new SqlParameter("@IdCard",SqlDbType.NVarChar,20),
                new SqlParameter("@Birthday",SqlDbType.Date)
                };
                para[0].Value = YouFu.Name;
                para[1].Value = YouFu.MilitaryTime;
                para[2].Value = YouFu.LocalAddress;
                para[3].Value = YouFu.LocalPhone;
                para[4].Value = YouFu.IsDiBao;
                para[5].Value = YouFu.NoLocalAddress;
                para[6].Value = YouFu.NolocalPhone;
                para[7].Value = YouFu.YouFuType;
                para[8].Value = YouFu.YouFuRank;
                para[9].Value = YouFu.IsAtJob;
                para[10].Value = YouFu.IsAtContryside;
                para[11].Value = YouFu.IsEdlerPartyMember;
                para[12].Value = YouFu.AnnualMoney;
                para[13].Value = YouFu.CareFee;
                para[14].Value = YouFu.DeadTime;
                para[15].Value = YouFu.IsNewAdd;
                para[16].Value = YouFu.IsEnterMicro;
                para[17].Value = YouFu.Remark;
                para[18].Value = YouFu.Area;
                para[19].Value = YouFu.IDCard;
                para[20].Value = YouFu.Birthday;
                object obj = DbHelperSQL.GetSingle(strSql.ToString(), para);
                if (obj != null)
                {
                    iExecute = Convert.ToInt32(obj);
                }

            }
            catch (Exception e)
            {
                Log4Net.LogWrite("err", "Controler\\AddDiBao" + e.Message);
            }
            return iExecute;
        }
示例#2
0
        /// <summary>
        /// 修改优抚信息
        /// </summary>
        /// <param name="YouFu">优抚对象</param>
        /// <returns></returns>
        public static int UpdateYouFu(YouFu YouFu)
        {
            int iExecute = 0;
            try
            {
                string sqlStr = "";
                sqlStr += "UPDATE  AnFu_Info SET  ";

                sqlStr += "Name=@Name,Military_time=@Military_time,Local_Address=@Local_Address,Local_Phone=@Local_Phone,IsDiBao=@IsDiBao,NoLocal_Address=@NoLocal_Address,NoLocal_Phone=@NoLocal_Phone,AnFu_Type=@AnFu_Type,AnFu_Rank=@AnFu_Rank,IsAtJob=@IsAtJob,IsAtCountryside=@IsAtCountryside";
                sqlStr += ",IsElderPartyMember=@IsElderPartyMember,Annual_Money=@Annual_Money,Care_Fee=@Care_Fee,Dead_Time=@Dead_Time,IsNewAdd=@IsNewAdd,IsEnterMicro=@IsEnterMicro,Remark=@Remark,Area=@Area,IdCard=@IdCard,Birthday=@Birthday";
                sqlStr += " where Id=@Id";
                SqlParameter[] para = new SqlParameter[]
                {
                new SqlParameter("@Name",SqlDbType.NVarChar,50),
                new SqlParameter("@Military_time",SqlDbType.Date),
                new SqlParameter("@Local_Address",SqlDbType.NVarChar),
                new SqlParameter("@Local_Phone",SqlDbType.NVarChar,20),
                new SqlParameter("@IsDiBao",SqlDbType.NChar,10),
                new SqlParameter("@NoLocal_Address",SqlDbType.NVarChar),
                new SqlParameter("@NoLocal_Phone",SqlDbType.NVarChar,20),
                new SqlParameter("@AnFu_Type",SqlDbType.NVarChar,50),
                new SqlParameter("@AnFu_Rank",SqlDbType.NVarChar,50),
                new SqlParameter("@IsAtJob",SqlDbType.NChar,10),
                new SqlParameter("@IsAtCountryside",SqlDbType.NChar,10),
                new SqlParameter("@IsElderPartyMember",SqlDbType.NChar,10),
                new SqlParameter("@Annual_Money",SqlDbType.Decimal),
                new SqlParameter("@Care_Fee",SqlDbType.Decimal),
                new SqlParameter("@Dead_Time",SqlDbType.Date),
                new SqlParameter("@IsNewAdd",SqlDbType.NChar,10),
                new SqlParameter("@IsEnterMicro",SqlDbType.NChar,10),
                new SqlParameter("@Remark",SqlDbType.Text),
                new SqlParameter("@Area",SqlDbType.NVarChar,50),
                new SqlParameter("@Id",SqlDbType.Int),
                 new SqlParameter("@IdCard",SqlDbType.NVarChar,20),
                new SqlParameter("@Birthday",SqlDbType.Date)
                };
                para[0].Value = YouFu.Name;
                para[1].Value = YouFu.MilitaryTime;
                para[2].Value = YouFu.LocalAddress;
                para[3].Value = YouFu.LocalPhone;
                para[4].Value = YouFu.IsDiBao;
                para[5].Value = YouFu.NoLocalAddress;
                para[6].Value = YouFu.NolocalPhone;
                para[7].Value = YouFu.YouFuType;
                para[8].Value = YouFu.YouFuRank;
                para[9].Value = YouFu.IsAtJob;
                para[10].Value = YouFu.IsAtContryside;
                para[11].Value = YouFu.IsEdlerPartyMember;
                para[12].Value = YouFu.AnnualMoney;
                para[13].Value = YouFu.CareFee;
                para[14].Value = YouFu.DeadTime;
                para[15].Value = YouFu.IsNewAdd;
                para[16].Value = YouFu.IsEnterMicro;
                para[17].Value = YouFu.Remark;
                para[18].Value = YouFu.Area;
                para[19].Value = YouFu.Id;
                para[20].Value = YouFu.IDCard;
                para[21].Value = YouFu.Birthday;
                object obj = DbHelperSQL.ExecuteSql(sqlStr, para);
                if (obj != null)
                {
                    iExecute = Convert.ToInt32(obj);
                }

                // "UPDATE  AnFu_Info SET  Name=@Name,Military_time=@Military_time,Local_Address=@Local_Address,Local_Phone=@Local_Phone,IsDiBao=@IsDiBao,NoLocal_Address=@NoLocal_Address,NoLocal_Phone=@NoLocal_Phone,AnFu_Type=@AnFu_Type,AnFu_Rank=@AnFu_Rank,IsAtJob=@IsAtJob,IsAtCountryside=@IsAtCountryside,IsElderPartyMember=@IsElderPartyMember,Annual_Money=@Annual_Money,Care_Fee=@Care_Fee,Dead_Time=@Dead_Time,IsNewAdd=@IsNewAdd,IsEnterMicro=@IsEnterMicro,Remark=@Remark,Area=@Area where Id=@Id"
            }
            catch (Exception e)
            {
                Log4Net.LogWrite("err", "Controler\\AddDiBao" + e.Message);
            }
            return iExecute;
        }
示例#3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            YouFu YouFu = new YouFu();
            if (string.IsNullOrEmpty(this.txtRwTime.Text.Trim()))
            {
                MessageBox.Show(this, "入伍时间不能为空。");
                return;
            }
            if (string.IsNullOrEmpty(this.txtIDCard.Text.Trim()))
            {
                MessageBox.Show(this, "身份证不能为空。");
                return;
            }
            if (!string.IsNullOrEmpty(txtAnnualMoney.Text.Trim()))
            {
                try
                {
                    YouFu.AnnualMoney = Convert.ToDecimal(txtAnnualMoney.Text.Trim());
                }
                catch
                {
                    MessageBox.Show(this, "年费填写错误,请重新填写。");
                    return;
                }
            }
            else
            {
                YouFu.AnnualMoney = null;
            }

            if (!string.IsNullOrEmpty(txtCareFee.Text.Trim()))
            {
                try
                {
                    YouFu.CareFee = Convert.ToDecimal(txtCareFee.Text.Trim());
                }
                catch
                {
                    MessageBox.Show(this, "护理费填写错误,请重新填写。");
                    return;
                }
            }
            else
            {
                YouFu.CareFee = null;
            }

            YouFu.Name = txtName.Text.Trim();
            try
            {
                YouFu.MilitaryTime = Convert.ToDateTime(txtRwTime.Text.Trim());
            }
            catch
            {
                MessageBox.Show(this, "入伍日期填写错误!");
            }

            YouFu.LocalAddress = txtLocalAddress.Text.Trim();

            try
            {
                YouFu.Birthday = DateTime.Parse(txtBirthday.Text.Trim());
            }
            catch (Exception)
            {
                MessageBox.Show(this, "生日填写错误!");
            }
            YouFu.IDCard = txtIDCard.Text.Trim();
            YouFu.LocalPhone = txtLocalPhone.Text.Trim();
            YouFu.YouFuType = ddlCareType.SelectedValue.Trim();
            YouFu.YouFuRank = ddlCareRank.SelectedValue.Trim();

            if (ddlArea.SelectedIndex == 0)
            {
                YouFu.Area = null;
            }
            else
            {
                YouFu.Area = ddlArea.SelectedValue.Trim();
            }

            if (ddlIsAtJob.SelectedIndex == 0)
            {
                YouFu.IsAtJob = null;
            }
            else
            {
                YouFu.IsAtJob = ddlIsAtJob.SelectedValue.Trim();
            }

            if (ddlIsAtCountryside.SelectedIndex == 0)
            {
                YouFu.IsAtContryside = null;
            }
            else
            {
                YouFu.IsAtContryside = ddlIsAtCountryside.SelectedValue.Trim();
            }

            if (ddlEdlerPartyMember.SelectedIndex == 0)
            {
                YouFu.IsEdlerPartyMember = null;
            }
            else
            {
                YouFu.IsEdlerPartyMember = ddlEdlerPartyMember.SelectedValue.Trim();
            }

            try
            {
                YouFu.DeadTime = Convert.ToDateTime(txtDeadTime.Text.Trim());
            }
            catch
            {
                YouFu.DeadTime = null;
            }

            if (ddlIsNewAdd.SelectedIndex == 0)
            {
                YouFu.IsNewAdd = null;
            }
            else
            {
                YouFu.IsNewAdd = ddlIsNewAdd.SelectedValue.Trim();
            }

            if (ddlIsEnterMicro.SelectedIndex == 0)
            {
                YouFu.IsEnterMicro = null;
            }
            else
            {
                YouFu.IsEnterMicro = ddlIsEnterMicro.SelectedValue.Trim();
            }
            YouFu.Remark = txtRemark.Text.Trim();

            if (!string.IsNullOrEmpty(YouFu.Name))
            {
                if (Ctrl_YouFu.AddYouFu(YouFu) > 0)
                {
                    MessageBox.ShowAndRedirect(this, "添加成功!", ViewState["BackUrl"].ToString());
                }
                else
                    MessageBox.Show(this, "添加失败!");
            }
            else
                MessageBox.Show(this, "姓名没有填写!请填写姓名");
        }