/// <summary> /// 根据Id获取低保申请数据 /// </summary> /// <param name="Id">Id</param> /// <returns>该人低保数据</returns> public static Approve_DiShouRu GetDiShouRuById(int Id) { Approve_DiShouRu appDiShouRu = new Approve_DiShouRu(); Approve_DiBao AppDiBao = new Approve_DiBao(); try { StringBuilder strSql = new StringBuilder(); strSql.Append("select A.Id,A.Uid,A.Fid,A.Bz_Approver,A.Bz_Master,A.Bz_BaoZhang,A.Name,A.IdCard,"); strSql.Append("B.Address,B.Home,B.Tel1,B.Tel2,B.House,B.Square,A.StreetId,A.CommunityId,"); strSql.Append("A.Wage,A.Wage1,A.Wage2,A.Wage3,A.Wage4,A.Wage5,A.Wage6,A.Bz_Cz"); strSql.Append(" from Approve_DiShouRu as A"); strSql.Append(" inner join (select * from Approve_DiShouRu where Bz_Master=1) as B on A.Fid=B.Fid"); strSql.Append(" where A.Id=" + Id); DataSet ds = new DataSet(); 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() != "") { appDiShouRu.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } if (ds.Tables[0].Rows[0]["Uid"] != null && ds.Tables[0].Rows[0]["Uid"].ToString() != "") { appDiShouRu.Uid = int.Parse(ds.Tables[0].Rows[0]["Uid"].ToString()); } if (ds.Tables[0].Rows[0]["Fid"] != null && ds.Tables[0].Rows[0]["Fid"].ToString() != "") { appDiShouRu.Fid = int.Parse(ds.Tables[0].Rows[0]["Fid"].ToString()); } if (ds.Tables[0].Rows[0]["Bz_Approver"] != null && ds.Tables[0].Rows[0]["Bz_Approver"].ToString() != "") { appDiShouRu.Bz_Approver = int.Parse(ds.Tables[0].Rows[0]["Bz_Approver"].ToString()); } if (ds.Tables[0].Rows[0]["Bz_Master"] != null && ds.Tables[0].Rows[0]["Bz_Master"].ToString() != "") { appDiShouRu.Bz_Master = int.Parse(ds.Tables[0].Rows[0]["Bz_Master"].ToString()); } if (ds.Tables[0].Rows[0]["Bz_BaoZhang"] != null && ds.Tables[0].Rows[0]["Bz_BaoZhang"].ToString() != "") { appDiShouRu.Bz_BaoZhang = int.Parse(ds.Tables[0].Rows[0]["Bz_BaoZhang"].ToString()); } if (ds.Tables[0].Rows[0]["StreetId"] != null && ds.Tables[0].Rows[0]["StreetId"].ToString() != "") { appDiShouRu.StreetId = int.Parse(ds.Tables[0].Rows[0]["StreetId"].ToString()); } if (ds.Tables[0].Rows[0]["CommunityId"] != null && ds.Tables[0].Rows[0]["CommunityId"].ToString() != "") { appDiShouRu.CommunityId = int.Parse(ds.Tables[0].Rows[0]["CommunityId"].ToString()); } if (ds.Tables[0].Rows[0]["Name"] != null && ds.Tables[0].Rows[0]["Name"].ToString() != "") { appDiShouRu.Name = ds.Tables[0].Rows[0]["Name"].ToString(); } if (ds.Tables[0].Rows[0]["IdCard"] != null && ds.Tables[0].Rows[0]["IdCard"].ToString() != "") { appDiShouRu.IdCard = ds.Tables[0].Rows[0]["IdCard"].ToString(); } if (ds.Tables[0].Rows[0]["Address"] != null && ds.Tables[0].Rows[0]["Address"].ToString() != "") { appDiShouRu.Address = ds.Tables[0].Rows[0]["Address"].ToString(); } if (ds.Tables[0].Rows[0]["Home"] != null && ds.Tables[0].Rows[0]["Home"].ToString() != "") { appDiShouRu.Home = ds.Tables[0].Rows[0]["Home"].ToString(); } if (ds.Tables[0].Rows[0]["Tel1"] != null && ds.Tables[0].Rows[0]["Tel1"].ToString() != "") { appDiShouRu.Tel1 = ds.Tables[0].Rows[0]["Tel1"].ToString(); } if (ds.Tables[0].Rows[0]["Tel2"] != null && ds.Tables[0].Rows[0]["Tel2"].ToString() != "") { appDiShouRu.Tel2 = ds.Tables[0].Rows[0]["Tel2"].ToString(); } if (ds.Tables[0].Rows[0]["House"] != null && ds.Tables[0].Rows[0]["House"].ToString() != "") { appDiShouRu.House = ds.Tables[0].Rows[0]["House"].ToString(); } if (ds.Tables[0].Rows[0]["Square"] != null && ds.Tables[0].Rows[0]["Square"].ToString() != "") { appDiShouRu.Square = ds.Tables[0].Rows[0]["Square"].ToString(); } if (ds.Tables[0].Rows[0]["Wage"] != null && ds.Tables[0].Rows[0]["Wage"].ToString() != "") { appDiShouRu.Wage = ds.Tables[0].Rows[0]["Wage"].ToString(); } if (ds.Tables[0].Rows[0]["Wage1"] != null && ds.Tables[0].Rows[0]["Wage1"].ToString() != "") { appDiShouRu.Wage1 = ds.Tables[0].Rows[0]["Wage1"].ToString(); } if (ds.Tables[0].Rows[0]["Wage2"] != null && ds.Tables[0].Rows[0]["Wage2"].ToString() != "") { appDiShouRu.Wage2 = ds.Tables[0].Rows[0]["Wage2"].ToString(); } if (ds.Tables[0].Rows[0]["Wage3"] != null && ds.Tables[0].Rows[0]["Wage3"].ToString() != "") { appDiShouRu.Wage3 = ds.Tables[0].Rows[0]["Wage3"].ToString(); } if (ds.Tables[0].Rows[0]["Wage4"] != null && ds.Tables[0].Rows[0]["Wage4"].ToString() != "") { appDiShouRu.Wage4 = ds.Tables[0].Rows[0]["Wage4"].ToString(); } if (ds.Tables[0].Rows[0]["Wage5"] != null && ds.Tables[0].Rows[0]["Wage5"].ToString() != "") { appDiShouRu.Wage5 = ds.Tables[0].Rows[0]["Wage5"].ToString(); } if (ds.Tables[0].Rows[0]["Wage6"] != null && ds.Tables[0].Rows[0]["Wage6"].ToString() != "") { appDiShouRu.Wage6 = ds.Tables[0].Rows[0]["Wage6"].ToString(); } if (ds.Tables[0].Rows[0]["Bz_Cz"] != null && ds.Tables[0].Rows[0]["Bz_Cz"].ToString() != "") { appDiShouRu.Bz_Cz = int.Parse(ds.Tables[0].Rows[0]["Bz_Cz"].ToString()); } ds.Dispose(); } } catch (Exception e) { Log4Net.LogWrite("err", "Controler.Ctrl_Approve.GetDiBaoById:" + e.Message); } return appDiShouRu; }
/// <summary> /// 保存按钮事件 /// </summary> /// <param name="sender">系统参数</param> /// <param name="e">系统参数</param> protected void btnSave_Click(object sender, EventArgs e) { if (FunLogicAddData()) return;//判断是否有未填项 #region 获取家庭成员信息表数据 ds DataTable dt = CopyFormData(); DataSet ds = new DataSet(); ds.Merge(dt); #endregion #region 存入家庭成员信息 Approve_Record AppRecord = new Approve_Record(); BaseInfo baseInfo = new BaseInfo(); int Fid = Ctrl_Counter.GetCounter_Fid();//获取家庭Id 家庭Id不是户主的Id int ApproverId = 0;//申请人所在行Id 恒为0 int MasterId = int.Parse(drpMaster.SelectedValue) - 1;//获取户主所在行Id for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { Approve_DiBao AppDiBao = new Approve_DiBao(); AppDiBao.Fid = Fid; baseInfo.Fid = Fid; if (MasterId == i)//户主信息录入 { AppDiBao.Bz_Master = 1;//如果为户主行 则户主标记为1 baseInfo.Bz_Master = 1; AppDiBao.Address = txtAddress.Text; AppDiBao.Home = txtHome.Text; AppDiBao.Tel1 = txtTel1.Text; AppDiBao.Tel2 = txtTel2.Text; AppDiBao.House = txtHouse.Text; AppDiBao.Square = txtSquare.Text; AppDiBao.StreetId = int.Parse(drpStreet.SelectedValue); AppDiBao.CommunityId = int.Parse(drpCommunity.SelectedValue); AppUser.StreetId = int.Parse(drpStreet.SelectedValue); AppUser.CommunityId = int.Parse(drpCommunity.SelectedValue); baseInfo.StreetId = AppUser.StreetId; baseInfo.CommunityId = AppUser.CommunityId; //新增 家庭财产和申请理由 if (txtApproveReason.Value.Length > 500) { MessageBox.Show(this, "申请理由不能超过250个字!"); return; } if (txtFamilyMoney.Value.Length > 500) { MessageBox.Show(this, "家庭财产说明不能超过50个字!"); return; } AppDiBao.ApproveReason = txtApproveReason.Value; AppDiBao.FamilyMeans = txtFamilyMoney.Value; } else AppDiBao.Bz_Master = 0; baseInfo.Bz_Master = 0; AppDiBao.Bz_Cz = 1;//城镇低保标记 AppDiBao.Name = ds.Tables[0].Rows[i]["Name"].ToString(); AppDiBao.IdCard = ds.Tables[0].Rows[i]["IdCard"].ToString(); baseInfo.Name = AppDiBao.Name; baseInfo.IdCard = AppDiBao.IdCard; try { if (ds.Tables[0].Rows[i]["Wage"].ToString() == "") AppDiBao.Wage = "0"; else AppDiBao.Wage = double.Parse(ds.Tables[0].Rows[i]["Wage"].ToString()).ToString(); if (ds.Tables[0].Rows[i]["Wage1"].ToString() == "") AppDiBao.Wage1 = "0"; else AppDiBao.Wage1 = double.Parse(ds.Tables[0].Rows[i]["Wage1"].ToString()).ToString(); if (ds.Tables[0].Rows[i]["Wage2"].ToString() == "") AppDiBao.Wage2 = "0"; else AppDiBao.Wage2 = double.Parse(ds.Tables[0].Rows[i]["Wage2"].ToString()).ToString(); if (ds.Tables[0].Rows[i]["Wage3"].ToString() == "") AppDiBao.Wage3 = "0"; else AppDiBao.Wage3 = double.Parse(ds.Tables[0].Rows[i]["Wage3"].ToString()).ToString(); if (ds.Tables[0].Rows[i]["Wage4"].ToString() == "") AppDiBao.Wage4 = "0"; else AppDiBao.Wage4 = double.Parse(ds.Tables[0].Rows[i]["Wage4"].ToString()).ToString(); if (ds.Tables[0].Rows[i]["Wage5"].ToString() == "") AppDiBao.Wage5 = "0"; else AppDiBao.Wage5 = double.Parse(ds.Tables[0].Rows[i]["Wage5"].ToString()).ToString(); if (ds.Tables[0].Rows[i]["Wage6"].ToString() == "") AppDiBao.Wage6 = "0"; else AppDiBao.Wage6 = double.Parse(ds.Tables[0].Rows[i]["Wage6"].ToString()).ToString(); } catch { MessageBox.Show(this, "有项目填写不正确,请仔细检查!"); return; } if (ApproverId == i) { AppDiBao.Bz_Approver = 1;//如果为申请人行 则申请人标记为1 AppDiBao.Uid = AppUser.Id; AppRecord.UserId = AppUser.Id; AppRecord.TypeId = TypeId; AppRecord.StepId = 0; } else AppDiBao.Bz_Approver = 0; if (Ctrl_Approve.AddDiBao(AppDiBao) == 0) { MessageBox.Show(this, "申请失败,请您再试一次!"); return; } if (i == ds.Tables[0].Rows.Count - 1)//最后一行保存完毕 再添加申请人信息及申请记录 避免街道数据无法获取 { if ((Ctrl_Approve.AddRecord(AppRecord) == 0) || !Ctrl_Approve.UpdateUser(AppUser))//将申请人信息写入申请工作流程表 { MessageBox.Show(this, "申请失败,请您再试一次!"); return; } } } MessageBox.ShowAndRedirect(this, "申请成功!", "../../First.aspx"); #endregion }
/// <summary> /// 添加一行低保人员申请信息 /// </summary> /// <param name="AppDiBao">低保人员信息实体</param> /// <returns>添加成功返回非0值,否则返回0</returns> public static int AddDiBao(Approve_DiBao AppDiBao) { int iExecute = 0; try { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Approve_DiBao("); strSql.Append("Uid,Fid,Bz_Approver,Bz_Master,Bz_BaoZhang,Name,IdCard,Address,Home,StreetId,CommunityId,"); strSql.Append("Tel1,Tel2,House,Square,Wage,Wage1,Wage2,Wage3,Wage4,Wage5,Wage6,Bz_Cz,ApproveReason,FamilyMeans)"); strSql.Append(" values ("); strSql.Append( "@Uid,@Fid,@Bz_Approver,@Bz_Master,@Bz_BaoZhang,@Name,@IdCard,@Address,@Home,@StreetId,@CommunityId,"); strSql.Append("@Tel1,@Tel2,@House,@Square,@Wage,@Wage1,@Wage2,@Wage3,@Wage4,@Wage5,@Wage6,@Bz_Cz,@ApproveReason,@FamilyMeans)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Uid", SqlDbType.Int), new SqlParameter("@Fid", SqlDbType.Int), new SqlParameter("@Bz_Approver", SqlDbType.Int), new SqlParameter("@Bz_Master", SqlDbType.Int), new SqlParameter("@Bz_BaoZhang", SqlDbType.Int), new SqlParameter("@Name", SqlDbType.NVarChar, 30), new SqlParameter("@IdCard", SqlDbType.NVarChar, 30), new SqlParameter("@Address", SqlDbType.NVarChar, 100), new SqlParameter("@Home", SqlDbType.NVarChar, 100), new SqlParameter("@StreetId", SqlDbType.Int), new SqlParameter("@CommunityId", SqlDbType.Int), new SqlParameter("@Tel1", SqlDbType.NVarChar, 30), new SqlParameter("@Tel2", SqlDbType.NVarChar, 30), new SqlParameter("@House", SqlDbType.NVarChar, 30), new SqlParameter("@Square", SqlDbType.NVarChar, 30), new SqlParameter("@Wage", SqlDbType.NVarChar, 10), new SqlParameter("@Wage1", SqlDbType.NVarChar, 10), new SqlParameter("@Wage2", SqlDbType.NVarChar, 10), new SqlParameter("@Wage3", SqlDbType.NVarChar, 10), new SqlParameter("@Wage4", SqlDbType.NVarChar, 10), new SqlParameter("@Wage5", SqlDbType.NVarChar, 10), new SqlParameter("@Wage6", SqlDbType.NVarChar, 10), new SqlParameter("@Bz_Cz", SqlDbType.Int), new SqlParameter("@ApproveReason", SqlDbType.NVarChar, 500), new SqlParameter("@FamilyMeans", SqlDbType.NVarChar, 100) }; parameters[0].Value = AppDiBao.Uid; parameters[1].Value = AppDiBao.Fid; parameters[2].Value = AppDiBao.Bz_Approver; parameters[3].Value = AppDiBao.Bz_Master; parameters[4].Value = AppDiBao.Bz_BaoZhang; parameters[5].Value = AppDiBao.Name; parameters[6].Value = AppDiBao.IdCard; parameters[7].Value = AppDiBao.Address; parameters[8].Value = AppDiBao.Home; parameters[9].Value = AppDiBao.StreetId; parameters[10].Value = AppDiBao.CommunityId; parameters[11].Value = AppDiBao.Tel1; parameters[12].Value = AppDiBao.Tel2; parameters[13].Value = AppDiBao.House; parameters[14].Value = AppDiBao.Square; parameters[15].Value = AppDiBao.Wage; parameters[16].Value = AppDiBao.Wage1; parameters[17].Value = AppDiBao.Wage2; parameters[18].Value = AppDiBao.Wage3; parameters[19].Value = AppDiBao.Wage4; parameters[20].Value = AppDiBao.Wage5; parameters[21].Value = AppDiBao.Wage6; parameters[22].Value = AppDiBao.Bz_Cz; parameters[23].Value = AppDiBao.ApproveReason; parameters[24].Value = AppDiBao.FamilyMeans; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj != null) { iExecute = Convert.ToInt32(obj); } } catch (Exception e) { Log4Net.LogWrite("err", "Controler.Ctrl_Approve.AddDiBao:" + e.Message); } return iExecute; }