protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["admin"] != null) { string str = Request.QueryString["record_id"]; try { int id = Convert.ToInt32(str); payback = new PayBackApplyDAO().getPayBackApply(id); payback.Image = "super-admin-frame/paybackimage/" + payback.Image; user_account.Text = payback.User_name; txt_note.Text = payback.Note; } catch (System.Exception ex) { Response.Redirect("error-page.aspx"); } } else { Response.Redirect("error-page.spx"); } } }
/// <summary> /// 获取申请还款的 列表 /// </summary> /// <returns></returns> public ArrayList getPayBackApplyArray() { ArrayList array = new ArrayList(); string sql = "select * from tb_payback_apply where is_agree=0"; DataTable table = new DBOperateCommon().excuteQuery(sql); for (int i = 0; i < table.Rows.Count; i++) { PayBackApply payback = new PayBackApply(); payback.Id = Convert.ToInt32(table.Rows[i]["id"].ToString()); payback.User_name = table.Rows[i]["user_name"].ToString(); payback.Amount = Convert.ToSingle(table.Rows[i]["amount"].ToString()); payback.Staff_apply = table.Rows[i]["apply_staff"].ToString(); payback.Operation = table.Rows[i]["operation"].ToString(); payback.Operation_time = Convert.ToDateTime(table.Rows[i]["operation_time"].ToString()); payback.Note = table.Rows[i]["note"].ToString(); payback.Image = table.Rows[i]["image"].ToString(); payback.Is_aggree = Convert.ToInt32(table.Rows[i]["is_agree"].ToString()); array.Add(payback); } return(array); }
//用户还款的具体实现 protected void btn_user_repay_right_Click(object sender, EventArgs e) { string account = user_account.Text; string money_str = Request.Form["repay_money"]; string note = Request.Form["note_repay"]; string path = uplaod_image.FileName; if (path == "") { alert("请选择图片"); } else { //首先判断该用户是否欠 UserDebt user_debt = new UserDebtDAO().getUserDebt(account); if (user_debt != null) { if (user_debt.Amount >= Convert.ToSingle(money_str)) { //申请返款 PayBackApply payback = new PayBackApply(); payback.User_name = account; payback.Amount = Convert.ToSingle(money_str); payback.Operation = "申请还款"; payback.Staff_apply = Session["staff"].ToString(); payback.Note = note; payback.Operation_time = DateTime.Now; payback.Is_aggree = 0; payback.Image = saveUploadFile(account); if (new PayBackApplyDAO().addPayBackApply(payback)) { //还款成功 // 记录交易信息 alert("申请成功!!"); } else { alert("申请失败!!"); } } else { alert("用户欠款金额为:" + user_debt.Amount + " ;还款金额为:" + money_str + ",无法进行还款申请!!"); } } else { alert("该用户不欠款,请确认用户信息!!"); } } }
/// <summary> /// 添加还款申请 /// </summary> /// <param name="payback"></param> /// <returns></returns> public bool addPayBackApply(PayBackApply payback) { bool flag = false; string sql = "insert into tb_payback_apply values('" + payback.User_name + "'," + payback.Amount + ",'" + payback.Operation + "','" + payback.Staff_apply + "','" + payback.Operation_time.ToString() + "','" + payback.Note + "','" + payback.Image + "'," + payback.Is_aggree + ")"; if (new DBOperateCommon().excuteNoQuery(sql)) { flag = true; } return(flag); }
/// <summary> /// 通过编号获取 待审核的还款信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public PayBackApply getPayBackApply(int id) { PayBackApply payback = new PayBackApply(); string sql = "select * from tb_payback_apply where id=" + id; DataTable table = new DBOperateCommon().excuteQuery(sql); if (table.Rows.Count > 0) { payback.Id = Convert.ToInt32(table.Rows[0]["id"].ToString()); payback.User_name = table.Rows[0]["user_name"].ToString(); payback.Amount = Convert.ToSingle(table.Rows[0]["amount"].ToString()); payback.Staff_apply = table.Rows[0]["staff_apply"].ToString(); payback.Operation = table.Rows[0]["operation"].ToString(); payback.Operation_time = Convert.ToDateTime(table.Rows[0]["operation_time"].ToString()); payback.Note = table.Rows[0]["note"].ToString(); payback.Image = table.Rows[0]["image"].ToString(); payback.Is_aggree = Convert.ToInt32(table.Rows[0]["is_agree"].ToString()); } return(payback); }