Esempio n. 1
0
        /// <summary>
        /// 增加一行基本表信息
        /// </summary>
        /// <param name="Base">基本表信息实体类</param>
        /// <returns>成功返回BaseId 否则返回0</returns>
        public static int AddBase(BaseEntity Base, string TableName)
        {
            int iExecute = 0;
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into BaseInfo(");
                strSql.Append("Fid,Name,IdCard,Home,StreetId,CommunityId,Bz_Master,Bz_DiBao,AppId_DiBao)");
                strSql.Append(" values (");
                strSql.Append("@Fid,@Name,@IdCard,@Home,@StreetId,@CommunityId,@Bz_Master,@Bz_DiBao,@AppId_DiBao)");
                strSql.Append(";select @@IDENTITY");

                SqlParameter[] parameters = {
                    new SqlParameter("@Fid", SqlDbType.Int),
                    new SqlParameter("@Name", SqlDbType.NVarChar,50),
                    new SqlParameter("@IdCard", SqlDbType.NVarChar,50),
                    new SqlParameter("@Home", SqlDbType.NVarChar,50),
                    new SqlParameter("@StreetId", SqlDbType.Int),
                    new SqlParameter("@CommunityId", SqlDbType.Int),
                    new SqlParameter("@Bz_Master", SqlDbType.Int),
                    new SqlParameter("@Bz_DiBao", SqlDbType.Int),
                    new SqlParameter("@AppId_DiBao", SqlDbType.Int)
                                            };
                parameters[0].Value = Base.Fid;
                parameters[1].Value = Base.Name;
                parameters[2].Value = Base.IdCard;
                parameters[3].Value = Base.Home;
                parameters[4].Value = Base.StreetId;
                parameters[5].Value = Base.CommunityId;
                parameters[6].Value = Base.Bz_Master;
                parameters[7].Value = Base.Bz_DiBao;
                parameters[8].Value = Base.AppId_DiBao;

                object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
                if (obj != null)
                {
                    iExecute = Convert.ToInt32(obj);
                }
            }
            catch (Exception e)
            {
                Log4Net.LogWrite("err", "Controler.Ctrl_Approve.AddUser:" + e.Message);
            }
            return iExecute;
        }
Esempio n. 2
0
        /// <summary>
        /// 添加信息至基本表
        /// </summary>
        /// <returns></returns>
        private bool AddBaseInfo()
        {
            bool bz = true;
            BaseEntity Base = new BaseEntity();
            DataTable dt = CopyFormData();
            DataSet ds = new DataSet();
            ds.Merge(dt);

            int MasterId = int.Parse(drpMaster.SelectedValue) - 1;//获取户主所在行Id
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                Base.Fid = int.Parse(hdFid.Value);
                Base.StreetId = int.Parse(drpStreet.SelectedValue);
                Base.CommunityId = int.Parse(drpCommunity.SelectedValue);
                Base.Home = txtHome.Text;
                Base.Bz_DiBao = 1;

                if (i == MasterId)
                    Base.Bz_Master = 1;
                else
                    Base.Bz_Master = 0;
                Base.Name = ds.Tables[0].Rows[i]["Name"].ToString();
                Base.AppId_DiBao =int.Parse(ds.Tables[0].Rows[i]["ID"].ToString());
                Base.IdCard = ds.Tables[0].Rows[i]["IdCard"].ToString();
                Base.AppId_DiBao = int.Parse(ds.Tables[0].Rows[i]["DiBaoId"].ToString());
                if (Ctrl_Base.AddBaseWithReady(Base, "DiBao", 0, true) == 0)
                    bz = false;
            }
            return bz;
        }
Esempio n. 3
0
        /// <summary>
        /// 增加一行基本表信息并将户主信息写入项目待入库表
        /// </summary>
        /// <param name="Base">基本表信息实体类</param>
        /// <returns>成功返回1 否则返回0</returns>
        public static int AddBaseWithReady(BaseEntity Base, string TableName, int Bz_Cz, bool IsDiBao)
        {
            int iExecute = 0;
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into BaseInfo(");
                strSql.Append("Fid,Name,IdCard,Home,StreetId,CommunityId,Bz_Master,Bz_DiBao,AppId_DiBao,Bz_DiShouRu,AppId_DiShouRu,Bz_TempHelp,AppId_TempHelp)");
                strSql.Append(" values (");
                strSql.Append("@Fid,@Name,@IdCard,@Home,@StreetId,@CommunityId,@Bz_Master,@Bz_DiBao,@AppId_DiBao,@Bz_DiShouRu,@AppId_DiShouRu,@Bz_TempHelp,@AppId_TempHelp)");
                strSql.Append(";select @@IDENTITY");

                SqlParameter[] parameters = {
                    new SqlParameter("@Fid", SqlDbType.Int),
                    new SqlParameter("@Name", SqlDbType.NVarChar,50),
                    new SqlParameter("@IdCard", SqlDbType.NVarChar,50),
                    new SqlParameter("@Home", SqlDbType.NVarChar,50),
                    new SqlParameter("@StreetId", SqlDbType.Int),
                    new SqlParameter("@CommunityId", SqlDbType.Int),
                    new SqlParameter("@Bz_Master", SqlDbType.Int),
                    new SqlParameter("@Bz_DiBao", SqlDbType.Int),
                    new SqlParameter("@AppId_DiBao", SqlDbType.Int),
                    new SqlParameter("@Bz_DiShouRu", SqlDbType.Int),
                    new SqlParameter("@AppId_DiShouRu", SqlDbType.Int),
                    new SqlParameter("@Bz_TempHelp", SqlDbType.Int),
                    new SqlParameter("@AppId_TempHelp", SqlDbType.Int)
                                            };
                parameters[0].Value = Base.Fid;
                parameters[1].Value = Base.Name;
                parameters[2].Value = Base.IdCard;
                parameters[3].Value = Base.Home;
                parameters[4].Value = Base.StreetId;
                parameters[5].Value = Base.CommunityId;
                parameters[6].Value = Base.Bz_Master;
                parameters[7].Value = Base.Bz_DiBao;
                parameters[8].Value = Base.AppId_DiBao;
                parameters[9].Value = Base.Bz_DiShouRu;
                parameters[10].Value = Base.AppId_DiShouRu;
                parameters[11].Value = Base.Bz_TempHelp;
                parameters[12].Value = Base.AppId_TempHelp;

                object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
                if (obj != null)
                {
                    iExecute = Convert.ToInt32(obj);
                }

                if (Base.Bz_Master == 1)//如果录入的是户主
                {
                    string sql = "";
                    if (IsDiBao)
                        sql = "insert into " + TableName + "_Ready (BaseFid,Bz_Cz) values (" + Base.Fid + "," + Bz_Cz + ")";
                    else
                        sql = "insert into " + TableName + "_Ready (BaseFid) values (" + Base.Fid + ")";
                    DbHelperSQL.ExecuteSql(sql);
                }
            }
            catch (Exception e)
            {
                Log4Net.LogWrite("err", "Controler.Ctrl_Approve.AddUser:" + e.Message);
            }
            return iExecute;
        }
Esempio n. 4
0
        /// <summary>
        /// 获取家庭基本信息
        /// </summary>
        /// <param name="Fid">家庭Id</param>
        /// <returns></returns>
        public static BaseEntity GetBaseFamilyInfo(int Fid)
        {
            BaseEntity BaseInfo = new BaseEntity();
            DataSet ds = new DataSet();
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("select Id,Fid,Bz_DiBao");
                strSql.Append(" from BaseInfo");
                strSql.Append(" where Bz_Master=1 and Fid=" + Fid);

                ds = DbHelperSQL.Query(strSql.ToString());
                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (ds.Tables[0].Rows[0]["Id"] != null && ds.Tables[0].Rows[0]["Id"].ToString() != "")
                    {
                        BaseInfo.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                    }
                    if (ds.Tables[0].Rows[0]["Fid"] != null && ds.Tables[0].Rows[0]["Fid"].ToString() != "")
                    {
                        BaseInfo.Fid = int.Parse(ds.Tables[0].Rows[0]["Fid"].ToString());
                    }
                    //if (ds.Tables[0].Rows[0]["Reason_Community"] != null && ds.Tables[0].Rows[0]["Reason_Community"].ToString() != "")
                    //{
                    //    BaseInfo.Reason_Community = ds.Tables[0].Rows[0]["Reason_Community"].ToString();
                    //}
                    //if (ds.Tables[0].Rows[0]["Reason_Office"] != null && ds.Tables[0].Rows[0]["Reason_Office"].ToString() != "")
                    //{
                    //    BaseInfo.Reason_Office = ds.Tables[0].Rows[0]["Reason_Office"].ToString();
                    //}
                    //if (ds.Tables[0].Rows[0]["Reason_Civil"] != null && ds.Tables[0].Rows[0]["Reason_Civil"].ToString() != "")
                    //{
                    //    BaseInfo.Reason_Civil = ds.Tables[0].Rows[0]["Reason_Civil"].ToString();
                    //}
                    //if (ds.Tables[0].Rows[0]["Bz_Result_Community"] != null && ds.Tables[0].Rows[0]["Bz_Result_Community"].ToString() != "")
                    //{
                    //    BaseInfo.Bz_Result_Community = int.Parse(ds.Tables[0].Rows[0]["Bz_Result_Community"].ToString());
                    //}
                    //if (ds.Tables[0].Rows[0]["Bz_Result_Office"] != null && ds.Tables[0].Rows[0]["Bz_Result_Office"].ToString() != "")
                    //{
                    //    BaseInfo.Bz_Result_Office = int.Parse(ds.Tables[0].Rows[0]["Bz_Result_Office"].ToString());
                    //}
                    //if (ds.Tables[0].Rows[0]["Bz_Result_Civil"] != null && ds.Tables[0].Rows[0]["Bz_Result_Civil"].ToString() != "")
                    //{
                    //    BaseInfo.Bz_Result_Civil = int.Parse(ds.Tables[0].Rows[0]["Bz_Result_Civil"].ToString());
                    //}
                    if (ds.Tables[0].Rows[0]["Bz_DiBao"] != null && ds.Tables[0].Rows[0]["Bz_DiBao"].ToString() != "")
                    {
                        BaseInfo.Bz_DiBao = int.Parse(ds.Tables[0].Rows[0]["Bz_DiBao"].ToString());
                    }
                }
            }
            catch (Exception e)
            {
                Log4Net.LogWrite("err", "SysAccessData.SysManage.UserManage\\DacUserInfo\\GetPageUserInfoList" + e.Message);
            }
            return BaseInfo;
        }
Esempio n. 5
0
        /// <summary>
        /// 保存按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            TempHelp_Info tempHelpInfo = new TempHelp_Info();
            tempHelpInfo.Name = txtName.Text;
            tempHelpInfo.IdCard = txtIdCard.Text;
            tempHelpInfo.Bz_Approver = cbApprover.Checked ? 1 : 0;
            tempHelpInfo.Bz_BaoZhang = cbBaoZhang.Checked ? 1 : 0;
            // tempHelpInfo.Bz_Cz = cbCz.Checked ? 1 : 0;
            tempHelpInfo.Bz_Master = cbMaster.Checked ? 1 : 0;
            tempHelpInfo.StreetId = int.Parse(drpStreet.SelectedValue);
            tempHelpInfo.CommunityId = int.Parse(drpCommunity.SelectedValue);
            tempHelpInfo.Address = txtAddress.Text;
            tempHelpInfo.Home = txtHome.Text;
            tempHelpInfo.Tel1 = txtTel1.Text;
            tempHelpInfo.Tel2 = txtTel2.Text;
            tempHelpInfo.House = txtHouse.Text;
            tempHelpInfo.Square = txtSquare.Text;
            tempHelpInfo.Sex = drpSex.SelectedItem.Text;
            tempHelpInfo.Birth = DateTime.Parse(txtBirth.Text);
            tempHelpInfo.ClassId = int.Parse(drpClass.SelectedValue);
            tempHelpInfo.JobId = int.Parse(drpJob.SelectedValue);
            tempHelpInfo.Health = txtHealth.Text;
            tempHelpInfo.Car = txtCar.Text;
            tempHelpInfo.Bz_Retire = cbRetire.Checked ? 1 : 0;
            tempHelpInfo.AppReason = txtAppReason.Value.ToString();
            int MyId;
            if (!int.TryParse(txtFamNum.Text.ToString(), out MyId))
            {
                MessageBox.Show(this, "手动户编号不能为空");
                return;
            }
            else
            {
                tempHelpInfo.MyFid = MyId;
            }
            if (cbRetire.Checked)
            {
                if (txtRetire.Text == "")
                {
                    MessageBox.Show(this, "已退休人员的退休日期不能为空!");
                    return;
                }
                tempHelpInfo.RetireTime = DateTime.Parse(txtRetire.Text);
            }
            else
            {
                tempHelpInfo.RetireTime = null;
            }
            tempHelpInfo.Bz_Dead = cbDead.Checked ? 1 : 0;
            if (cbDead.Checked)
            {
                if (txtDead.Text == "")
                {
                    MessageBox.Show(this, "已死亡人员的死亡日期不能为空!");
                    return;
                }
                tempHelpInfo.DeadTime = DateTime.Parse(txtDead.Text);
            }
            else
            {
                tempHelpInfo.DeadTime = null;
            }
            tempHelpInfo.Wage = txtWage.Text;
            DateTime oneTime = new DateTime();
            if (DateTime.TryParse(txtOneTime.Text, out oneTime))
            {
                tempHelpInfo.OneTime = oneTime;
            }
            else
            {
                tempHelpInfo.OneTime = DateTime.Now;
            }
            if (txtMoney.Text == "")
            {
                tempHelpInfo.Money = 0;
            }
            else
            {
                tempHelpInfo.Money = decimal.Parse(txtMoney.Text);
            }
            tempHelpInfo.State = cbState.Checked ? 0 : 1;
            if (hdId.Value == "0")//添加
            {
                if (hdDiBaoId.Value != "0")//如果是待入库表添加
                {
                    tempHelpInfo.BaseId = int.Parse(hdBaseId.Value);
                    tempHelpInfo.Fid = int.Parse(hdFid.Value);
                    if (Ctrl_Ass_TempHelp.AddTempHelpInfo(tempHelpInfo) > 0)
                    {
                        Ctrl_Base.UpdateBaseInfoWithTableName(tempHelpInfo.BaseId, "TempHelp", 2);
                        MessageBox.ShowAndRedirect(this, "添加成功!", ViewState["BackUrl"].ToString());
                    }
                    else
                        MessageBox.Show(this, "添加失败!");
                }
                else//直接添加
                {
                    if (hdFid.Value == "0")//添加一户
                    {
                        //写入基本表
                        BaseEntity BaseInfo = new BaseEntity();
                        BaseInfo.AppId_TempHelp = 0;//非审批途径进入基本表
                        BaseInfo.Bz_TempHelp = 2;//更改低保标记为在发
                        BaseInfo.Bz_Master = cbMaster.Checked ? 1 : 0;
                        BaseInfo.CommunityId = int.Parse(drpCommunity.SelectedValue);
                        BaseInfo.Home = txtHome.Text;
                        BaseInfo.IdCard = txtIdCard.Text;
                        BaseInfo.Name = txtName.Text;
                        BaseInfo.StreetId = int.Parse(drpStreet.SelectedValue);
                        BaseInfo.Fid = Ctrl_Counter.GetCounter_Fid();//获取Fid
                        tempHelpInfo.Fid = BaseInfo.Fid;
                        tempHelpInfo.AddTime = DateTime.Now.ToString("yyyy-MM-dd");
                        tempHelpInfo.BaseId = CommonHelp.AddBase(BaseInfo, "TempHelp");//信息写入基本表并返回基本表Id
                        if (Ctrl_Ass_TempHelp.AddTempHelpInfo(tempHelpInfo) > 0)
                        {
                            Ctrl_Base.UpdateBaseInfoWithTableName(tempHelpInfo.BaseId, "TempHelp", 2);
                            //MessageBox.ShowAndRedirect(this, "添加成功!是否继续添加家庭成员?", ViewState["BackUrl"].ToString());
                            //if (tempHelpInfo.Fid > 0)
                            //{
                            //    Page.ClientScript.RegisterStartupScript(this.GetType(), "js", "fnAddFamConfirm(" + tempHelpInfo.Fid + ",'" + ViewState["BackUrl"].ToString() + "');", true);
                            //}
                            MessageBox.ShowAndRedirect(this, "添加成功", "TempHelp_Fam.aspx?Fid=" + tempHelpInfo.Fid);
                        }
                        else
                            MessageBox.Show(this, "添加失败!");
                    }
                    else
                    {
                        //写入基本表
                        BaseEntity BaseInfo = new BaseEntity();
                        BaseInfo.AppId_TempHelp = 0;//非审批途径进入基本表
                        BaseInfo.Bz_DiBao = 2;//更改低保标记为在发
                        BaseInfo.Bz_Master = cbMaster.Checked ? 1 : 0;
                        BaseInfo.CommunityId = int.Parse(drpCommunity.SelectedValue);
                        BaseInfo.Home = txtHome.Text;
                        BaseInfo.IdCard = txtIdCard.Text;
                        BaseInfo.Name = txtName.Text;
                        BaseInfo.StreetId = int.Parse(drpStreet.SelectedValue);
                        BaseInfo.Fid = int.Parse(hdFid.Value);

                        tempHelpInfo.BaseId = Ctrl_Base.AddBase(BaseInfo, "TempHelpInfo");//信息写入基本表并返回基本表Id
                        tempHelpInfo.Fid = int.Parse(hdFid.Value);
                        if (Ctrl_Ass_TempHelp.AddTempHelpInfo(tempHelpInfo) > 0)
                        {
                            Ctrl_Base.UpdateBaseInfoWithTableName(tempHelpInfo.BaseId, "TempHelp", 2);
                            MessageBox.ShowAndRedirect(this, "添加成功!", ViewState["BackUrl"].ToString());

                            // Response.Write("<Script Language='JavaScript'>if ( window.confirm('添加成功,继续添加')) {  window.location.href='" + ViewState["BackUrl"].ToString() +"' } else {window.location.href='" + ViewState["BackUrl"].ToString() + "' };</script>");  //如果成功则继续添加,不成功则返回页面主页(相应户为单位)
                        }
                        else
                            MessageBox.Show(this, "添加失败!");
                    }
                }

            }
            else//修改
            {
                tempHelpInfo.Id = int.Parse(hdId.Value);
                tempHelpInfo.BaseId = int.Parse(hdBaseId.Value);
                tempHelpInfo.Fid = int.Parse(hdFid.Value);
                if (cbState.Checked && txtStopReason.Enabled)//如果停发
                {
                    if (string.IsNullOrEmpty(txtStopReason.Text))
                    {
                        MessageBox.Show(this, "停发原因不能为空!");
                        return;
                    }
                    Ctrl_Ass_TempHelp.AddStopReason(tempHelpInfo.Id, txtStopReason.Text);
                }
                if (Ctrl_Ass_TempHelp.UpdateTempHelp(tempHelpInfo))
                    MessageBox.ShowAndRedirect(this, "修改成功!", ViewState["BackUrl"].ToString());
                else
                    MessageBox.Show(this, "修改失败!");
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 保存按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            DiBao_Info DiBaoInfo = new DiBao_Info();
            DiBaoInfo.Name = txtName.Text;
            DiBaoInfo.IdCard = txtIdCard.Text;
            DiBaoInfo.Bz_Approver = cbApprover.Checked ? 1 : 0;
            DiBaoInfo.Bz_BaoZhang = cbBaoZhang.Checked ? 1 : 0;
            DiBaoInfo.Bz_Cz = cbCz.Checked ? 1 : 0;
            DiBaoInfo.Bz_Master = cbMaster.Checked ? 1 : 0;
            DiBaoInfo.StreetId = int.Parse(drpStreet.SelectedValue);
            DiBaoInfo.CommunityId = int.Parse(drpCommunity.SelectedValue);
            DiBaoInfo.Address = txtAddress.Text;
            DiBaoInfo.Home = txtHome.Text;
            DiBaoInfo.Tel1 = txtTel1.Text;
            DiBaoInfo.Tel2 = txtTel2.Text;
            DiBaoInfo.House = txtHouse.Text;
            DiBaoInfo.Square = txtSquare.Text;
            DiBaoInfo.Sex = drpSex.SelectedItem.Text;
            DiBaoInfo.Birth = DateTime.Parse(txtBirth.Text);
            DiBaoInfo.TypeId = int.Parse(drpType.SelectedValue);
            DiBaoInfo.ClassId = int.Parse(drpClass.SelectedValue);
            DiBaoInfo.JobId = int.Parse(drpJob.SelectedValue);
            DiBaoInfo.Health = txtHealth.Text;
            DiBaoInfo.Car = txtCar.Text;
            DiBaoInfo.Bank = txtBank.Text;
            DiBaoInfo.Bz_Retire = cbRetire.Checked ? 1 : 0;
            DiBaoInfo.AppReason = txtAppReason.Value;
            DiBaoInfo.MyFid = int.Parse(txtFamNum.Text);
            if (cbRetire.Checked)
            {
                if (txtRetire.Text == "")
                {
                    MessageBox.Show(this, "已退休人员的退休日期不能为空!");
                    return;
                }
                DiBaoInfo.RetireTime = DateTime.Parse(txtRetire.Text);
            }
            else
            {
                DiBaoInfo.RetireTime = null;
            }
            DiBaoInfo.Bz_Dead = cbDead.Checked ? 1 : 0;
            if (cbDead.Checked)
            {
                if (txtDead.Text == "")
                {
                    MessageBox.Show(this, "已死亡人员的死亡日期不能为空!");
                    return;
                }
                DiBaoInfo.DeadTime = DateTime.Parse(txtDead.Text);
            }
            else
            {
                DiBaoInfo.DeadTime = null;
            }

            #region 判断时间输入是否合乎要求(在日历控件不好使的情况下判断)
            DateTime lTime;
            DateTime nTime;
            if (DateTime.TryParse(txtCheckTime.Text, out lTime))
            {
                DiBaoInfo.CheckTime = lTime;
            }
            else
            {
                MessageBox.Show(this, "上次检查时间不正确");
                return;
            }
            if (DateTime.TryParse(txtNextTime.Text, out nTime))
            {
                DiBaoInfo.NextTime = nTime;
            }
            else
            {
                MessageBox.Show(this, "下次检查时间不正确");
                return;
            }
            #endregion

            DiBaoInfo.Wage = txtWage.Text;
            DiBaoInfo.Wage1 = txtWage1.Text;
            DiBaoInfo.Wage2 = txtWage2.Text;
            DiBaoInfo.Wage3 = txtWage3.Text;
            DiBaoInfo.Wage4 = txtWage4.Text;
            DiBaoInfo.Wage5 = txtWage5.Text;
            DiBaoInfo.Wage6 = txtWage6.Text;
            DiBaoInfo.OneMoney = txtOneMoney.Text;
            DiBaoInfo.OneMonth = txtOneMonth.Text;
            DiBaoInfo.OneTime = null;//农村低保不含此项,赋null值
            if (txtMoney.Text == "")
            {
                DiBaoInfo.Money = 0;
            }
            else
            {
                DiBaoInfo.Money = decimal.Parse(txtMoney.Text);
            }
            DiBaoInfo.State = cbState.Checked ? 0 : 1;
            if (hdId.Value == "0")//添加
            {
                if (hdDiBaoId.Value != "0")//如果是待入库表添加
                {
                    DiBaoInfo.BaseId = int.Parse(hdBaseId.Value);
                    DiBaoInfo.Fid = int.Parse(hdFid.Value);
                    if (Ctrl_Ass_DiBao.AddDiBao(DiBaoInfo) > 0)
                    {
                        Ctrl_Base.UpdateBaseInfoWithTableName(DiBaoInfo.BaseId, "DiBao", 2);
                        MessageBox.ShowAndRedirect(this, "添加成功!", ViewState["BackUrl"].ToString());
                    }
                    else
                        MessageBox.Show(this, "添加失败!");
                }
                else//直接添加
                {
                    if (hdFid.Value == "0")//添加一户
                    {
                        //写入基本表
                        BaseEntity BaseInfo = new BaseEntity();
                        BaseInfo.AppId_DiShouRu = 0;//非审批途径进入基本表
                        BaseInfo.Bz_DiBao = 2;//更改低保标记为在发
                        BaseInfo.Bz_Master = cbMaster.Checked ? 1 : 0;
                        BaseInfo.CommunityId = int.Parse(drpCommunity.SelectedValue);
                        BaseInfo.Home = txtHome.Text;
                        BaseInfo.IdCard = txtIdCard.Text;
                        BaseInfo.Name = txtName.Text;
                        BaseInfo.StreetId = int.Parse(drpStreet.SelectedValue);
                        BaseInfo.Fid = Ctrl_Counter.GetCounter_Fid();//获取Fid

                        DiBaoInfo.Fid = BaseInfo.Fid;
                        DiBaoInfo.BaseId = Ctrl_Base.AddBase(BaseInfo, "DiBao");//信息写入基本表并返回基本表Id

                        if (Ctrl_Ass_DiBao.AddDiBao(DiBaoInfo) > 0)
                        {
                            Ctrl_Base.UpdateBaseInfoWithTableName(DiBaoInfo.BaseId, "DiBao", 2);
                            MessageBox.ShowAndRedirect(this, "添加成功!", "DiBao_Fam_Nc.aspx?Fid=" + DiBaoInfo.Fid);
                        }
                        else
                            MessageBox.Show(this, "添加失败!");
                    }
                    else
                    {
                        //写入基本表
                        BaseEntity BaseInfo = new BaseEntity();
                        BaseInfo.AppId_DiShouRu = 0;//非审批途径进入基本表
                        BaseInfo.Bz_DiBao = 2;//更改低保标记为在发
                        BaseInfo.Bz_Master = cbMaster.Checked ? 1 : 0;
                        BaseInfo.CommunityId = int.Parse(drpCommunity.SelectedValue);
                        BaseInfo.Home = txtHome.Text;
                        BaseInfo.IdCard = txtIdCard.Text;
                        BaseInfo.Name = txtName.Text;
                        BaseInfo.StreetId = int.Parse(drpStreet.SelectedValue);
                        BaseInfo.Fid = int.Parse(hdFid.Value);

                        DiBaoInfo.BaseId = Ctrl_Base.AddBase(BaseInfo, "DiBao");//信息写入基本表并返回基本表Id
                        DiBaoInfo.Fid = int.Parse(hdFid.Value);
                        if (Ctrl_Ass_DiBao.AddDiBao(DiBaoInfo) > 0)
                        {
                            Ctrl_Base.UpdateBaseInfoWithTableName(DiBaoInfo.BaseId, "DiBao", 2);
                            //MessageBox.ShowAndRedirect(this, "添加成功!", ViewState["BackUrl"].ToString());
                            if (DiBaoInfo.Fid > 0)
                            {
                                //Page.ClientScript.RegisterStartupScript(this.GetType(), "js", "fnAddFamConfirm(" + DiBaoInfo.Fid + ",'" + ViewState["BackUrl"].ToString() + "');", true);
                                MessageBox.ShowAndRedirect(this, "添加成功!", ViewState["BackUrl"].ToString());
                                // Response.Write("<Script Language='JavaScript'>if ( window.confirm('添加成功,继续添加')) {  window.location.href='" + ViewState["BackUrl"].ToString() +"' } else {window.location.href='" + ViewState["BackUrl"].ToString() + "' };</script>");//如果成功则继续添加,不成功则返回页面主页(相应户为单位)
                            }
                        }
                        else
                            MessageBox.Show(this, "添加失败!");
                    }
                }

            }
            else//修改
            {
                DiBaoInfo.Id = int.Parse(hdId.Value);
                DiBaoInfo.BaseId = int.Parse(hdBaseId.Value);
                DiBaoInfo.Fid = int.Parse(hdFid.Value);
                if (cbState.Checked && txtStopReason.Enabled)//如果停发
                {
                    Ctrl_Ass_DiBao.AddStopReason(DiBaoInfo.Id, txtStopReason.Text);
                }
                if (Ctrl_Ass_DiBao.UpdateDiBao(DiBaoInfo))
                    MessageBox.ShowAndRedirect(this, "修改成功!", ViewState["BackUrl"].ToString());
                else
                    MessageBox.Show(this, "修改失败!");
            }
        }