123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- using LYFZ.WeixinServers.WeiXinAPP;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace LYFZ.WeixinServers.DZKJ
- {
- public partial class DZKJ_AddDistributor : System.Web.UI.Page
- {
- public long eid = -1;
- public LYFZ.WeixinServiceDate.Model.Model_DZKJ_DistributorAccount dzkjModel = new WeixinServiceDate.Model.Model_DZKJ_DistributorAccount();
- LYFZ.WeixinServiceDate.DAL.DAL_DZKJ_DistributorAccount DDzkjDistAccount = new WeixinServiceDate.DAL.DAL_DZKJ_DistributorAccount();
- public string TxtReadonly = "";
- protected void Page_Load(object sender, EventArgs e)
- {
- CommonHandler.CheckLoginJump(this);
- if (!IsPostBack)
- {
- if (Request.QueryString["eid"] != null && Request.QueryString["eid"].ToString().Trim().Length > 0)
- {
- try
- {
- if (CommonHandler.CheckAdmin(this))
- {
- eid = Convert.ToInt64(Request.QueryString["eid"].ToString().Trim());
- dzkjModel = DDzkjDistAccount.GetModel(eid);
- TxtReadonly = "readonly=\"readonly\"";
- }
- }
- catch { }
- }
- else if (Request.QueryString["s"] != null && Request.QueryString["s"].ToString().Trim() == "edit")
- {
- if (CommonHandler.CheckAdmin(this))
- {
- getEditID();
- AddOrEditCustomerAccount();
- }
- }
- }
- }
- void getEditID()
- {
- try
- {
- eid = Convert.ToInt64(Request.QueryString["id"].ToString().Trim());
- }
- catch { }
- }
-
- LYFZ.WeixinServiceDate.DAL.DAL_DZKJ_DistributorRechargeRecords DZKJRec_Dal = new WeixinServiceDate.DAL.DAL_DZKJ_DistributorRechargeRecords();
- void AddOrEditCustomerAccount()
- {
- LYFZ.WeixinServiceDate.Model.Model_DZKJ_DistributorAccount DZKJModel = new WeixinServiceDate.Model.Model_DZKJ_DistributorAccount();
- LYFZ.WeixinServiceDate.Model.Model_AdminUser userModel = new WeixinServiceDate.Model.Model_AdminUser();
- LYFZ.WeixinServiceDate.DAL.DAL_AdminUser userDal = new WeixinServiceDate.DAL.DAL_AdminUser();
- if (eid > 0)
- {
- DZKJModel = DDzkjDistAccount.GetModel(eid);
- }
- DZKJModel.CompanyName = Request.Form["CompanyName"].ToString();
- DZKJModel.CompanyAddress = Request.Form["CompanyAddress"].ToString();
- DZKJModel.Contacts = Request.Form["Contacts"].ToString();
- DZKJModel.Sex = Convert.ToInt32(Request.Form["sex"].ToString());
- DZKJModel.Telephone = Request.Form["Telephone"].ToString();
- DZKJModel.StartSimulatorCount = 0;
- int StartSimulatorCount = 0;
- try
- {
- StartSimulatorCount = Convert.ToInt32(Request.Form["StartSimulatorCount"].ToString());
- }
- catch
- {
- MsegesBox("操作失败,购买软件套数格式不正确");
- return;
- }
- DZKJModel.IsEnabled = Convert.ToInt32(Request.Form["IsEnabled"].ToString());
- bool ret = false;
- try
- {
- if (eid > 0)
- {
- ret = DDzkjDistAccount.Update(DZKJModel);
- }
- else
- {
-
- userModel.UserName = Request.Form["CompanyName"].ToString();
- userModel.Account = Request.Form["Account"].ToString();
- userModel.Phone = Request.Form["Telephone"].ToString();
- userModel.Password = Request.Form["Password"].ToString();
- userModel.Competence = 2;
- ret = false;
- int Id = userDal.Add(userModel);
- DZKJModel.AccountID = Id;
- DZKJModel.IP = "";
- DZKJModel.RegistrationTime = DateTime.Now;
- DZKJModel.ID= LYFZ.WinAPI.CustomPublicMethod.GenerateId();
- ret = DDzkjDistAccount.Add(DZKJModel);
- if (ret)
- {
- DDzkjDistAccount.Recharge(DZKJModel.ID, CommonHandler.GetAdminUser(this).Account, 0, StartSimulatorCount, "直接购买时的软件套数");
- }
- }
- }
- catch (Exception ex){
- if (ex.Message.ToLower().Contains("PK_tb_DZKJ_DistributorAccount".ToLower()))
- {
- MsegesBox("帐号“" + DZKJModel.AccountID + "”已经存在,不能重复。" + ex.Message);
- }
- else {
- MsegesBox("操作失败:" + ex.Message);
- }
-
- return;
- }
- if (ret)
- {
- Global.RefreshDZKJ_CustomerAccountDataTable();
- MsegesBox("操作成功");
- }
- else
- {
- MsegesBox("操作失败,请重试");
- }
- }
- void MsegesBox(string msg)
- {
- Response.Write("<script>alert(\"" + msg.Replace("\r\n", "").Replace("\r", "").Replace("\n", "") + "\");document.location='DZKJ_DistributorAccount.aspx';</script>"); return;
- }
- }
- }
|