Files
g.hnyhua.cn/Mtxfw.VipSite/Admin_Member_business_add.aspx.cs
2026-02-07 15:48:27 +08:00

482 lines
23 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
using System.Data;
using Newtonsoft.Json;
using System.Web.Script.Serialization;
namespace Mtxfw.VipSite
{
public partial class Admin_Member_business_add : Mtxfw.Utility.MemberBase
{
public Mtxfw.DAL.business_info daoBus = new Mtxfw.DAL.business_info();
DAL.user_Goods_lb daolb = new DAL.user_Goods_lb();
DAL.user_info daoUser = new DAL.user_info();
public Mtxfw.Utility.Config config = new Mtxfw.Utility.Config("");
public String TitName = String.Empty;
protected String pid, cid, qid, tid;
public string strimg = "", strBody = "",utype="0";
public int gtype = 0;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
string hostname = Request.Url.Host;
gtype = new DAL.host().GetId(hostname);
if (!IsPostBack)
{
Select_Bind();
Hidd_Url.Value = Request.UrlReferrer.ToString();
string[] stra = config.webbank.Split('|');
foreach (string str in stra)
{
if (str != "")
{
DropBank.Items.Add(new ListItem(str, str));
}
}
}
if (Request.QueryString["action"] == "add")
{
TitName = "添加门店";
if (!IsPostBack)
{
Btn_Update.Visible = false;
}
}
else
{
TitName = "修改门店";
if (!IsPostBack)
{
Btn_Insert.Visible = false;
}
Mtxfw.Model.business_info model = daoBus.GetModel(int.Parse(Request.QueryString["ID"]));
if (model != null)
{
utype = model.utype;
if (!IsPostBack)
{
Text_CompanyName.Text = model.CompanyName;
Mtxfw.Model.user_info umodel = daoUser.GetModel(model.UserId);
if (umodel != null)
{
Text_UserName.Text = umodel.UserName;
Text_CompanyNumber.Text = umodel.CompanyNumber;
Text_CompanyCert.Text = umodel.CompanyCert;
Text_CompanyPic.Text = umodel.CompanyPic;
Text_CompanyProvince.Text = umodel.CompanyProvince;
Text_CompanyCity.Text = umodel.CompanyCity;
if (utype == "0")
{
Text_ylmoney.Text = umodel.umoney42.ToString();
}
}
if (utype == "3")
{
Text_ylmoney.Text = model.email;
}
Text_dgzh.Text = model.ClsnName2;
Text_frname.Text = model.frname;
Text_fridcard.Text = model.fridcard;
Text_ContactPhone.Text = model.ContactPhone;
Drop_Cls.SelectedValue = model.ClsID.ToString();
Text_Industry.Text = model.Industry;
Text_CompanyAddress.Text = model.Companyaddress;
Text_BusinessRange.Text = model.BusinessRange;
hiddenphotos.Value = model.picture;
Hidd_CompanyId.Value = model.CompanyId;
xcoo.Value = model.xcoo;
ycoo.Value = model.ycoo;
for (int i = 0; i < DropBank.Items.Count; i++)
{
if (DropBank.Items[i].Value == model.InternetSite)
{
DropBank.Items[i].Selected = true;
}
else
{
DropBank.Items[i].Selected = false;
}
}
Text_BankCard.Text = model.Busroutes;
Text_BankName.Text = model.Introduction;
Text_KHName.Text = model.ContactPeople;
Text_huifu_uid.Text = model.huifu_uid;
if (model.IFFill == 1)
{
tradingname.Text = model.Agentrading;
}
for (int i = 0; i < DropBank.Items.Count; i++)
{
if (DropBank.Items[i].Value == model.InternetSite)
{
DropBank.Items[i].Selected = true;
}
else
{
DropBank.Items[i].Selected = false;
}
}
for (int i = 0; i < Radio_D0.Items.Count; i++)
{
if (Radio_D0.Items[i].Value == model.ifd0.ToString())
{
Radio_D0.Items[i].Selected = true;
}
else
{
Radio_D0.Items[i].Selected = false;
}
}
for (int i = 0; i < Radio_paytype.Items.Count; i++)
{
if (Radio_paytype.Items[i].Value == model.paytype.ToString())
{
Radio_paytype.Items[i].Selected = true;
}
else
{
Radio_paytype.Items[i].Selected = false;
}
}
}
}
pid = model.Province;
cid = model.City;
qid = model.County;
tid = (model.IFFill == 1 ? "-1" : model.Agentrading);
strBody = model.Introduction;
}
if (hiddenphotos.Value != "")
{
string[] strjiaoyouPhotoA = hiddenphotos.Value.Split('|');
for (int i = 0; i < strjiaoyouPhotoA.Length; i++)
{
if (strjiaoyouPhotoA[i] != "")
{
string[] strPhoto = strjiaoyouPhotoA[i].Split(',');
if (strPhoto[0].IndexOf("https://") == -1 && strPhoto[0].IndexOf("http") == -1)
{
strPhoto[0] = "/GetFiles.ashx?image=" + strPhoto[0].Replace("Files/Image/", "") + "&itsize=100x100&itmode=cut";
}
strimg += "<li id='picli" + i + "'><img src='" + strPhoto[0] + "' width='100'/><a href=javascript:DeletePic('" + strjiaoyouPhotoA[i] + "'," + i + ")>删除</a>";
if (i == 0)
{
strimg += "&nbsp;已设为封面";
}
else
{
strimg += "&nbsp;<a href=javascript:SetPic('" + strjiaoyouPhotoA[i] + "'," + i + ")>设为封面</a>";
}
strimg += "</li>";
}
}
}
Btn_Insert.Click += delegate(object s, EventArgs ex)
{
Mtxfw.Model.business_info model = new Mtxfw.Model.business_info();
model.CompanyName = Text_CompanyName.Text;
model.frname= Text_frname.Text;
model.fridcard= Text_fridcard.Text;
model.email= "";
model.ClsID = int.Parse(Drop_Cls.SelectedItem.Value);
model.ClsnName = Drop_Cls.SelectedItem.Text;
model.ClsID2 = 0;
model.ClsnName2 = Text_dgzh.Text;
string strProvince = "", strCity = "", strCounty = "";
if (Request.Form["select_p"] != null)
{
strProvince = Request.Form["select_p"].ToString();
}
if (Request.Form["select_c"] != null)
{
strCity = Request.Form["select_c"].ToString();
}
if (Request.Form["select_q"] != null)
{
strCounty = Request.Form["select_q"].ToString();
}
string tradingarea = "";
if (Request.Form["select_t"] != null)
{
tradingarea = Request.Form["select_t"].ToString();
}
model.Province = strProvince;
model.City = strCity;
model.County = strCounty;
model.IFFill = (tradingarea == "-1" ? 1 : 0);
model.Agentrading = (tradingarea == "-1" ? tradingname.Text.Trim() : tradingarea);;
model.Industry = Text_Industry.Text;
model.Introduction2 = "";
model.Introduction3 = "";
model.Busroutes = "";
string strPhotos = "";
if (hiddenphotos.Value != "")
{
string[] strjiaoyouPhotoA = hiddenphotos.Value.Split('|');
int j = 0;
for (int i = 0; i < strjiaoyouPhotoA.Length; i++)
{
if (strjiaoyouPhotoA[i] != "")
{
string[] strPhoto = strjiaoyouPhotoA[i].Split(',');
strPhotos += strPhoto[0] + "|";
j += 1;
}
}
}
model.picture = strPhotos;
model.BusinessRange = Text_BusinessRange.Text;
model.Businesslicense = "";
model.TaxRegistration = "";
model.Companyaddress = Text_CompanyAddress.Text;
model.ContactPeople = Text_KHName.Text;
model.InternetSite = DropBank.SelectedItem.Value;
model.Busroutes = Text_BankCard.Text;
model.Introduction = Text_BankName.Text;
model.ContactPhone = Text_ContactPhone.Text;
model.ApplyTime = DateTime.Now;
model.CompanyId = "0";
model.Discount = "";
model.xcoo = xcoo.Value;
model.ycoo = ycoo.Value;
model.utype = "0";
model.gtype = gtype;
model.seef = 0;
model.ApplyState = "";
int userid = 0;
string strzd = daoUser.Getzd("id", "IFStores=0 and UserName='" + Text_UserName.Text + "'").ToString();
if (strzd != "")
{
userid = Convert.ToInt32(strzd);
}
model.UserId = userid;
daoBus.Add(model);
if (Session["UploadFileIng"] != null)
{
string[] stra = Session["UploadFileIng"].ToString().Split(',');
foreach (string str in stra)
{
if (str.Trim() != "")
{
if (model.Introduction.IndexOf(str.Trim()) == -1)
{
if (System.IO.File.Exists(Server.MapPath(str.Trim())))
{
System.IO.File.Delete(Server.MapPath(str.Trim()));
}
}
}
}
}
Session.Remove("UploadFileIng");
Response.Redirect(Hidd_Url.Value);
};
Btn_Update.Click += delegate(object s, EventArgs ex)
{
Int32 ID = int.Parse(Request.QueryString["ID"]);
Mtxfw.Model.business_info model = daoBus.GetModel(ID);
if (model != null)
{
int userid = 0;
string strzd = daoUser.Getzd("id", "IFStores=0 and UserName='" + Text_UserName.Text + "'").ToString();
if (strzd != "")
{
userid = Convert.ToInt32(strzd);
}
if (userid > 0)
{
model.UserId = userid;
Mtxfw.Model.user_info umodel = daoUser.GetModel(model.UserId);
if (umodel != null)
{
string editbody = "";
if (umodel.umoney42.ToString() != Text_ylmoney.Text)
{
editbody += " 原门店让利" + umodel.umoney42.ToString() + "改为" + Text_ylmoney.Text;
}
int ifeditbank = 0;
if (model.ContactPeople != Text_KHName.Text)
{
editbody += " 原开户名" + model.ContactPeople + "改为" + Text_KHName.Text;
ifeditbank = 1;
}
if (model.InternetSite != DropBank.SelectedItem.Value)
{
editbody += " 原银行名称" + model.InternetSite + "改为" + DropBank.SelectedItem.Value;
ifeditbank = 1;
}
if (model.Busroutes != Text_BankCard.Text)
{
editbody += " 原银行卡号" + model.Busroutes + "改为" + Text_BankCard.Text;
ifeditbank = 1;
}
if (model.Introduction != Text_BankName.Text)
{
editbody += " 原开户行" + model.Introduction + "改为" + Text_BankName.Text;
ifeditbank = 1;
}
model.Id = ID;
model.CompanyName = Text_CompanyName.Text;
model.frname = Text_frname.Text;
model.fridcard = Text_fridcard.Text;
model.ClsID = int.Parse(Drop_Cls.SelectedItem.Value);
model.ClsnName = Drop_Cls.SelectedItem.Text;
model.ClsnName2 = Text_dgzh.Text;
string strProvince = "", strCity = "", strCounty = "";
if (Request.Form["select_p"] != null)
{
strProvince = Request.Form["select_p"].ToString();
}
if (Request.Form["select_c"] != null)
{
strCity = Request.Form["select_c"].ToString();
}
if (Request.Form["select_q"] != null)
{
strCounty = Request.Form["select_q"].ToString();
}
string tradingarea = "";
if (Request.Form["select_t"] != null)
{
tradingarea = Request.Form["select_t"].ToString();
}
model.Province = strProvince;
model.City = strCity;
model.County = strCounty;
model.IFFill = (tradingarea == "-1" ? 1 : 0);
model.Agentrading = (tradingarea == "-1" ? tradingname.Text.Trim() : tradingarea);
string strPhotos = "";
if (hiddenphotos.Value != "")
{
string[] strjiaoyouPhotoA = hiddenphotos.Value.Split('|');
int j = 0;
for (int i = 0; i < strjiaoyouPhotoA.Length; i++)
{
if (strjiaoyouPhotoA[i] != "")
{
string[] strPhoto = strjiaoyouPhotoA[i].Split(',');
strPhotos += strPhoto[0] + "|";
j += 1;
}
}
}
if (utype == "3")
{
model.email = Text_ylmoney.Text;
}
model.picture = strPhotos;
model.BusinessRange = Text_BusinessRange.Text;
model.Companyaddress = Text_CompanyAddress.Text;
model.Industry = Text_Industry.Text;
model.ContactPhone = Text_ContactPhone.Text;
model.ContactPeople = Text_KHName.Text;
model.InternetSite = DropBank.SelectedItem.Value;
model.Busroutes = Text_BankCard.Text;
model.Introduction = Text_BankName.Text;
model.CompanyId = Hidd_CompanyId.Value;
model.huifu_uid = Text_huifu_uid.Text;
model.xcoo = xcoo.Value;
model.ycoo = ycoo.Value;
model.ifd0 = Convert.ToInt32(Radio_D0.SelectedItem.Value);
model.paytype = Convert.ToInt32(Radio_paytype.SelectedItem.Value);
daoBus.Update(model);
daoUser.UpdatePassword("CompanyNumber", Text_CompanyNumber.Text, model.UserId);
daoUser.UpdatePassword("CompanyCert", Text_CompanyCert.Text, model.UserId);
daoUser.UpdatePassword("CompanyPic", Text_CompanyPic.Text, model.UserId);
daoUser.UpdatePassword("CompanyProvince", Text_CompanyProvince.Text, model.UserId);
daoUser.UpdatePassword("CompanyCity", Text_CompanyCity.Text, model.UserId);
if (utype == "0")
{
daoUser.UpdateMoney2("umoney42", Convert.ToDouble(Text_ylmoney.Text), model.UserId);
}
Model.User_CZ_log logmodel = new Model.User_CZ_log();
logmodel.MemberId = Card;
logmodel.AddTime = DateTime.Now;
logmodel.IP = Mtxfw.Utility.Common.GetIP;
logmodel.Body = "银花优选修改门店" + model.CompanyName + editbody;
logmodel.UType = 0;
logmodel.gtype = gtype;
new DAL.User_CZ_log().Add(logmodel);
if (Session["UploadFileIng"] != null)
{
string[] stra = Session["UploadFileIng"].ToString().Split(',');
foreach (string str in stra)
{
if (str.Trim() != "")
{
if (model.Introduction.IndexOf(str.Trim()) == -1)
{
if (System.IO.File.Exists(Server.MapPath(str.Trim())))
{
System.IO.File.Delete(Server.MapPath(str.Trim()));
}
}
}
}
}
Session.Remove("UploadFileIng");
Response.Redirect(Hidd_Url.Value);
}
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('所属会员填写错误!');</script>");
}
}
};
}
protected void Select_Bind()
{
DataSet ds = daolb.GetList("gtype=" + gtype + " and utype=1 Order By LBLinkID");
foreach (System.Data.DataRow Dr in ds.Tables[0].Rows)
{
Drop_Cls.Items.Add(new ListItem(Dr["LBName"].ToString(), Dr["id"].ToString()));
}
ds.Clear();
}
public object Fromamap_ResultJson(string json)
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize<VipSite.amap_Result>(json);
}
public object Fromhuifupayresult1Json(string json)
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize<huifupayresult1>(json);
}
public object FromhuifuresultJson(string json)
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize<huifuresult>(json);
}
public object FromhuifubasicdataresultJson(string json)
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize<huifubasicdataresult>(json);
}
public object FromhuifucardlistJson(string json)
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize<List<huifucardlist>>(json);
}
}
}