/// <summary> /// 添加一行临时救助人员申请信息 /// </summary> /// <param name="appTempHelp">临时救助人员信息实体</param> /// <returns>添加成功返回非0值,否则返回0</returns> public static int AddTempHelp(ApproveTempHelp appTempHelp) { int iExecute = 0; try { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Approve_TempHelp("); strSql.Append("Uid,Fid,Bz_Approver,Bz_Master,Bz_BaoZhang,Name,IdCard,Address,Home,StreetId,CommunityId,"); strSql.Append("Tel1,Tel2,House,Square,Wage,Bz_Cz,Add_Time,ApproveReason)"); 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,@Bz_Cz,@AddTime,@ApproveReason)"); 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("@Bz_Cz", SqlDbType.Int), new SqlParameter("@AddTime", SqlDbType.NVarChar, 50), new SqlParameter("@ApproveReason", SqlDbType.NVarChar, 500), }; parameters[0].Value = appTempHelp.Uid; parameters[1].Value = appTempHelp.Fid; parameters[2].Value = appTempHelp.Bz_Approver; parameters[3].Value = appTempHelp.Bz_Master; parameters[4].Value = appTempHelp.Bz_BaoZhang; parameters[5].Value = appTempHelp.Name; parameters[6].Value = appTempHelp.IdCard; parameters[7].Value = appTempHelp.Address; parameters[8].Value = appTempHelp.Home; parameters[9].Value = appTempHelp.StreetId; parameters[10].Value = appTempHelp.CommunityId; parameters[11].Value = appTempHelp.Tel1; parameters[12].Value = appTempHelp.Tel2; parameters[13].Value = appTempHelp.House; parameters[14].Value = appTempHelp.Square; parameters[15].Value = appTempHelp.Wage; parameters[16].Value = appTempHelp.Bz_Cz; parameters[17].Value = appTempHelp.Add_Time; parameters[18].Value = appTempHelp.ApproveReason; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj != null) { iExecute = Convert.ToInt32(obj); } } catch (Exception e) { Log4Net.LogWrite("err", "Controler.Ctrl_Approve.AddTempHelp:" + e.Message); } return iExecute; }
/// <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 存入家庭成员信息 int recordId = 0; Approve_Record AppRecord = new Approve_Record(); 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++) { ApproveTempHelp appTempHelp = new ApproveTempHelp(); appTempHelp.Fid = Fid; if (MasterId == i)//户主信息录入 { appTempHelp.Bz_Master = 1;//如果为户主行 则户主标记为1 appTempHelp.Address = txtAddress.Text; appTempHelp.Home = txtHome.Text; appTempHelp.Tel1 = txtTel1.Text; appTempHelp.Tel2 = txtTel2.Text; appTempHelp.House = txtHouse.Text; appTempHelp.Square = txtSquare.Text; appTempHelp.StreetId = int.Parse(drpStreet.SelectedValue); appTempHelp.CommunityId = int.Parse(drpCommunity.SelectedValue); AppUser.StreetId = int.Parse(drpStreet.SelectedValue); AppUser.CommunityId = int.Parse(drpCommunity.SelectedValue); //新增 家庭财产和申请理由 if (txtApproveReason.Value.Length > 500) { MessageBox.Show(this, "申请理由不能超过250个字!"); return; } appTempHelp.ApproveReason = txtApproveReason.Value; } else appTempHelp.Bz_Master = 0; appTempHelp.Bz_Cz = 1;//城镇低保标记 appTempHelp.Name = ds.Tables[0].Rows[i]["Name"].ToString(); appTempHelp.IdCard = ds.Tables[0].Rows[i]["IdCard"].ToString(); try { if (ds.Tables[0].Rows[i]["Wage"].ToString() == "") appTempHelp.Wage = "0"; else appTempHelp.Wage = double.Parse(ds.Tables[0].Rows[i]["Wage"].ToString()).ToString(); } catch { MessageBox.Show(this, "有项目填写不正确,请仔细检查!"); return; } if (ApproverId == i) { appTempHelp.Bz_Approver = 1;//如果为申请人行 则申请人标记为1 appTempHelp.Uid = AppUser.Id; AppRecord.UserId = AppUser.Id; AppRecord.TypeId = TypeId; AppRecord.StepId = 0; } else appTempHelp.Bz_Approver = 0; if (Ctrl_Approve.AddTempHelp(appTempHelp) == 0) { MessageBox.Show(this, "申请失败,请您再试一次!"); return; } if (i == ds.Tables[0].Rows.Count - 1)//最后一行保存完毕 再添加申请人信息及申请记录 避免街道数据无法获取 { recordId = Ctrl_Approve.AddRecord(AppRecord); if ((recordId == 0) || !Ctrl_Approve.UpdateUser(AppUser))//将申请人信息写入申请工作流程表 { MessageBox.Show(this, "申请失败,请您再试一次!"); return; } else { Confirm confirm = new Confirm(); confirm.Fid = Fid; confirm.RecordId = recordId; confirm.TypeId = 9; confirm.IdCard = AppUser.IdCard; confirm.ConfirmCode = Med_Ass.GenerateRandomNumber(6); if (CommonHelp.AddConfirm(confirm) == 0) { MessageBox.Show(this, "插入验证码发生错误,联系管理员"); } else { MessageBox.ShowAndRedirect(this, "申请成功,请及时查询回馈信息,牢记下一页面的查询码,供查询使用:", "../Confirm.aspx?confirmCode=" + confirm.ConfirmCode); } } } } #endregion }
/// <summary> /// 根据Id获取临时救助申请数据 /// </summary> /// <param name="Id">临时救助表主键Id</param> /// <returns>临时救助对象</returns> public static ApproveTempHelp GetTempHelpById(int Id) { ApproveTempHelp appTempHelp = new ApproveTempHelp(); 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.Bz_Cz"); strSql.Append(" from Approve_TempHelp as A"); strSql.Append(" inner join (select * from Approve_TempHelp 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() != "") { appTempHelp.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() != "") { appTempHelp.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() != "") { appTempHelp.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() != "") { appTempHelp.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() != "") { appTempHelp.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() != "") { appTempHelp.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() != "") { appTempHelp.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() != "") { appTempHelp.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() != "") { appTempHelp.Name = ds.Tables[0].Rows[0]["Name"].ToString(); } if (ds.Tables[0].Rows[0]["IdCard"] != null && ds.Tables[0].Rows[0]["IdCard"].ToString() != "") { appTempHelp.IdCard = ds.Tables[0].Rows[0]["IdCard"].ToString(); } if (ds.Tables[0].Rows[0]["Address"] != null && ds.Tables[0].Rows[0]["Address"].ToString() != "") { appTempHelp.Address = ds.Tables[0].Rows[0]["Address"].ToString(); } if (ds.Tables[0].Rows[0]["Home"] != null && ds.Tables[0].Rows[0]["Home"].ToString() != "") { appTempHelp.Home = ds.Tables[0].Rows[0]["Home"].ToString(); } if (ds.Tables[0].Rows[0]["Tel1"] != null && ds.Tables[0].Rows[0]["Tel1"].ToString() != "") { appTempHelp.Tel1 = ds.Tables[0].Rows[0]["Tel1"].ToString(); } if (ds.Tables[0].Rows[0]["Tel2"] != null && ds.Tables[0].Rows[0]["Tel2"].ToString() != "") { appTempHelp.Tel2 = ds.Tables[0].Rows[0]["Tel2"].ToString(); } if (ds.Tables[0].Rows[0]["House"] != null && ds.Tables[0].Rows[0]["House"].ToString() != "") { appTempHelp.House = ds.Tables[0].Rows[0]["House"].ToString(); } if (ds.Tables[0].Rows[0]["Square"] != null && ds.Tables[0].Rows[0]["Square"].ToString() != "") { appTempHelp.Square = ds.Tables[0].Rows[0]["Square"].ToString(); } if (ds.Tables[0].Rows[0]["Wage"] != null && ds.Tables[0].Rows[0]["Wage"].ToString() != "") { appTempHelp.Wage = ds.Tables[0].Rows[0]["Wage"].ToString(); } if (ds.Tables[0].Rows[0]["Bz_Cz"] != null && ds.Tables[0].Rows[0]["Bz_Cz"].ToString() != "") { appTempHelp.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 appTempHelp; }