using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using Ajax; public partial class CustomerRetention_Form : System.Web.UI.Page { //所有客户名称 public string wuliaomingtishi = ""; //创建一个共用的编码bll层 Maticsoft.BLL.nr_sys_bianma bm = new Maticsoft.BLL.nr_sys_bianma(); //创建一个共用的类型BLL层 Maticsoft.BLL.nr_sys_leixing bmlx = new Maticsoft.BLL.nr_sys_leixing(); //创建一个共用的客户预存款bll层 Maticsoft.BLL.nr_z_khyck khyckbll = new Maticsoft.BLL.nr_z_khyck(); //创建一个共用的客户预存款模板 Maticsoft.Model.nr_z_khyck khyckmodel = new Maticsoft.Model.nr_z_khyck(); //创建一个操作记录模板 Maticsoft.Model.nr_sys_rizhi rizhi = new Maticsoft.Model.nr_sys_rizhi(); //创建一个操作记录bll Maticsoft.BLL.nr_sys_rizhi rizhibll = new Maticsoft.BLL.nr_sys_rizhi(); protected void Page_Load(object sender, EventArgs e) { Utility.RegisterTypeForAjax(typeof(CustomerRetention_Form)); if (!IsPostBack) { if (Session["user"] == null) { Response.Redirect("../index.aspx"); } //获取角色权限 Maticsoft.Model.nr_z_yhzh user = (Maticsoft.Model.nr_z_yhzh)(Session["user"]); binddata(); if (Request.QueryString["uid"] != null && Request.QueryString["uid"].ToString().Length > 0) { pdquanxianbj(user.juese); string uid = Request.QueryString["uid"].ToString(); id.Value = uid; initdata(uid); } else { pdquanxian(user.juese); if (Request.QueryString["fid"] != null && Request.QueryString["fid"].ToString().Length > 0) { string fid = Request.QueryString["fid"].ToString(); initdata(fid); } //赋值默认值 rq.Text = DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day; skr.Text = user.zhanghao; } } } #region 用来初始化绑定下拉框等值 private void binddata() { DataSet hylx = bmlx.GetAllList(); DataRow[] dr = hylx.Tables[0].Select("leixing='付款方式'"); if (dr != null && dr.Length > 0) { DataSet hy = bm.GetList("zhongleiid='" + dr[0]["id"] + "'"); if (hy != null) { fkfs.DataSource = hy.Tables[0].DefaultView; fkfs.DataValueField = "id"; fkfs.DataTextField = "mingcheng"; fkfs.DataBind(); } } } #endregion #region 修改时获取真正数据值 private void initdata(string did) { int idz = Convert.ToInt32(did); DataTable dt = DBHlper.Execute("select * from view_nr_z_khyck where id=" + did).Tables[0]; kh_bh.Value = dt.Rows[0]["kh_bh"].ToString(); rq.Text = DateTime.Parse(dt.Rows[0]["rq"].ToString()).ToString("yyyy-MM-dd"); ycje.Value = dt.Rows[0]["ycje"].ToString(); skr.Text = dt.Rows[0]["skr"].ToString(); fkfs.Text = dt.Rows[0]["fkfs"].ToString(); fkr.Text = dt.Rows[0]["fkr"].ToString(); shzt.Text = dt.Rows[0]["shzt"].ToString(); kh_mc.Value = dt.Rows[0]["kh_mc"].ToString(); bz.Text = dt.Rows[0]["bz"].ToString(); } #endregion #region 获取页面参数赋值model对象 private void getmd() { khyckmodel.rq =Convert.ToDateTime(rq.Text); khyckmodel.kh_bh = kh_bh.Value; khyckmodel.fkfs = fkfs.SelectedItem.Text; khyckmodel.ycje =Convert.ToDecimal(ycje.Value); khyckmodel.skr = skr.Text; khyckmodel.bz = bz.Text; khyckmodel.shzt = shzt.Text; khyckmodel.fkr = fkr.Text; //给日志模板赋值 rizhi.riqi = DateTime.Now; rizhi.leixing = "客户预存款"; } #endregion #region 敏感权限查看 void pdquanxian(int juese) { Maticsoft.Model.nr_z_yhzh user = (Maticsoft.Model.nr_z_yhzh)(Session["user"]); if (DBHlper.getzt(user.id) != 1) { Response.Redirect("../index.aspx"); } if (DBHlper.GetPermission(juese, "客户预存款", "nr_z_khyck", "添加") == false) { Response.Redirect("../Common/nopower.htm"); } } #endregion #region 敏感权限查看 void pdquanxianbj(int juese) { Maticsoft.Model.nr_z_yhzh user = (Maticsoft.Model.nr_z_yhzh)(Session["user"]); if (DBHlper.getzt(user.id) != 1) { Response.Redirect("../index.aspx"); } if (DBHlper.GetPermission(juese, "客户预存款", "nr_z_khyck", "编辑全部") == false && DBHlper.GetPermission(juese, "客户预存款", "nr_z_khyck", "编辑个人") == false) { Response.Redirect("../Common/nopower.htm"); } } #endregion //保存操作 protected void bt_tj_Click(object sender, EventArgs e) { try { string caozuo = "添加"; getmd(); //接收成功参数值 int rtx = 0; //判断uid是否存在值,有值为修改,无值为添加 if (id.Value != null && id.Value != "") { khyckmodel.id = Convert.ToInt32(id.Value); if (khyckbll.Update(khyckmodel)) { rtx = Convert.ToInt32(id.Value); caozuo = "修改"; } } else { rtx = khyckbll.Add(khyckmodel); } if (rtx > 0) { //将session转换对象取值 Maticsoft.Model.nr_z_yhzh zh = (Maticsoft.Model.nr_z_yhzh)Session["user"]; rizhi.yonghuming = zh.zhanghao; //拼接字符串插入日志 rizhi.jilu = zh.zhanghao + caozuo + "了客户预存款,客户编号为:" + kh_bh.Value.Trim(); rizhibll.Add(rizhi); Response.Redirect("CustomerRetention_browse.aspx?uid=" + rtx, false); } else { Response.Redirect("../Common/error.aspx"); } } catch (Exception) { Response.Redirect("../Common/error.aspx"); } } }