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 { }
- }
- /*[ID]
- ,[Account]
- ,[Password]
- ,[Contacts]
- ,[Telephone]
- ,[Sex]
- ,[CompanyName]
- ,[CompanyAddress]
- ,[PeriodOfValidity]
- ,[StartSimulatorCount]
- ,[HardwareCode]
- ,[IP]
- ,[RegistrationTime]
- ,[LatestLoginTime]
- ,[IsEnabled]
- * <label>*企业名称</label>
- <input name="CompanyName" id="CompanyName" type="text" value="" class="input-xlarge">
- <label>企业地址</label>
- <input name="CompanyAddress" id="CompanyAddress" type="text" value="" class="input-xlarge">
- <label>*硬件码</label>
- <input name="HardwareCode" id="HardwareCode" type="text" value="" class="input-xlarge">
- <label>*帐号</label>
- <input name="Account" id="Account" type="text" value="" class="input-xlarge">
- <label>*密码</label>
- <input name="Password" id="Password" type="text" value="" class="input-xlarge">
- <label>*联系人</label>
- <input name="Contacts" id="Contacts" type="text" value="" class="input-xlarge">
- <label>性别</label>
- <select name="sex" id="sex" class="input-xlarge">
- <option value="1">男</option>
- <option value="0">女</option>
- </select>
- <label>*联系电话</label>
- <input name="Telephone" id="Telephone" type="text" value="" class="input-xlarge">
- <label>*有效期</label>
- <input name="PeriodOfValidity" id="PeriodOfValidity" type="text" value="" class="input-xlarge">
- <label>*模拟器个数</label>
- <input name="StartSimulatorCount" id="StartSimulatorCount" type="text" value="" class="input-xlarge">
- <label>*状态</label>
- <input name="IsEnabled" id="IsEnabled" type="text" value="" class="input-xlarge">
- */
- 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;
- }
- }
- }
|