309 lines
13 KiB
C#
309 lines
13 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.Data;
|
|
namespace Mtxfw.WebSite._Admin
|
|
{
|
|
public partial class Admin_Member_business0_add : Mtxfw.Utility.MemberBase
|
|
{
|
|
public Mtxfw.DAL.business_info daoBus = new Mtxfw.DAL.business_info();
|
|
DAL.P_Category daoCategory = new DAL.P_Category();
|
|
DAL.user_info daoUser = new DAL.user_info();
|
|
public Mtxfw.Utility.Config config = new Mtxfw.Utility.Config("");
|
|
public String TitName = String.Empty;
|
|
public String CityID = String.Empty;
|
|
public String CountyID = String.Empty;
|
|
public string strimg = "", strBody = "";
|
|
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();
|
|
}
|
|
if (Request.QueryString["action"] == "add")
|
|
{
|
|
TitName = "添加门店";
|
|
if (!IsPostBack)
|
|
{
|
|
Btn_Update.Visible = false;
|
|
if (Session["Province"] != null)
|
|
{
|
|
for (int i = 0; i < Drop_Province.Items.Count; i++)
|
|
{
|
|
if (Drop_Province.Items[i].Value == Session["Province"].ToString())
|
|
{
|
|
Drop_Province.Items[i].Selected = true;
|
|
}
|
|
else
|
|
{
|
|
Drop_Province.Items[i].Selected = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (Session["City"] != null)
|
|
{
|
|
CityID = Session["City"].ToString();
|
|
}
|
|
if (Session["County"] != null)
|
|
{
|
|
CountyID = Session["County"].ToString();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
TitName = "修改门店";
|
|
if (!IsPostBack)
|
|
{
|
|
Btn_Insert.Visible = false;
|
|
}
|
|
Mtxfw.Model.business_info model = daoBus.GetModel(int.Parse(Request.QueryString["ID"]));
|
|
if (model != null)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
Text_CompanyName.Text = model.CompanyName;
|
|
Text_ContactPeople.Text = model.ContactPeople;
|
|
Text_ContactPhone.Text = model.ContactPhone;
|
|
Drop_Cls.SelectedValue = model.ClsID.ToString();
|
|
Drop_Province.SelectedValue = model.Province;
|
|
Text_Industry.Text = model.Industry;
|
|
Text_WebSize.Text = model.InternetSite;
|
|
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;
|
|
|
|
}
|
|
}
|
|
CityID = model.City;
|
|
CountyID = model.County;
|
|
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 += " 已设为封面";
|
|
}
|
|
else
|
|
{
|
|
strimg += " <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.ClsID = int.Parse(Drop_Cls.SelectedItem.Value);
|
|
model.ClsnName = Drop_Cls.SelectedItem.Text;
|
|
model.ClsID2 = 0;
|
|
model.ClsnName2 = "";
|
|
model.Province = Drop_Province.SelectedItem.Value;
|
|
if (Request.Form["Drop_City"] != null)
|
|
{
|
|
model.City = Request.Form["Drop_City"];
|
|
}
|
|
else
|
|
{
|
|
model.City = "";
|
|
}
|
|
if (Request.Form["Drop_County"] != null)
|
|
{
|
|
model.County = Request.Form["Drop_County"];
|
|
}
|
|
else
|
|
{
|
|
model.County = "";
|
|
}
|
|
model.Industry = "";
|
|
model.Introduction2 = "";
|
|
model.Introduction3 = "";
|
|
model.Busroutes = "";
|
|
Session["Province"] = model.Province;
|
|
Session["City"] = model.City;
|
|
Session["County"] = model.County;
|
|
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.InternetSite = Text_WebSize.Text;
|
|
model.Industry = Text_Industry.Text;
|
|
model.Introduction = Hidd_myEditor.Value;
|
|
model.ContactPeople = Text_ContactPeople.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 = "";
|
|
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);
|
|
model.Id = ID;
|
|
model.CompanyName = Text_CompanyName.Text;
|
|
model.ClsID = int.Parse(Drop_Cls.SelectedItem.Value);
|
|
model.ClsnName = Drop_Cls.SelectedItem.Text;
|
|
model.Province = Drop_Province.SelectedItem.Value;
|
|
if (Request.Form["Drop_City"] != null)
|
|
{
|
|
model.City = Request.Form["Drop_City"];
|
|
}
|
|
else
|
|
{
|
|
model.City = "";
|
|
}
|
|
if (Request.Form["Drop_County"] != null)
|
|
{
|
|
model.County = Request.Form["Drop_County"];
|
|
}
|
|
else
|
|
{
|
|
model.County = "";
|
|
}
|
|
model.Introduction2 = "";
|
|
model.Introduction3 = "";
|
|
|
|
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.Companyaddress = Text_CompanyAddress.Text;
|
|
model.InternetSite = Text_WebSize.Text;
|
|
model.Industry = Text_Industry.Text;
|
|
model.Introduction = Hidd_myEditor.Value;
|
|
model.ContactPeople = Text_ContactPeople.Text;
|
|
model.ContactPhone = Text_ContactPhone.Text;
|
|
|
|
model.Discount = "";
|
|
model.CompanyId = Hidd_CompanyId.Value;
|
|
model.xcoo = xcoo.Value;
|
|
model.ycoo = ycoo.Value;
|
|
daoBus.Update(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);
|
|
};
|
|
}
|
|
|
|
protected void Select_Bind()
|
|
{
|
|
DataSet ds = daoCategory.GetList("gtype=" + gtype + " and ttype=8 Order By C_LinkID");
|
|
foreach (System.Data.DataRow Dr in ds.Tables[0].Rows)
|
|
{
|
|
Drop_Cls.Items.Add(new ListItem(Dr["C_NAME"].ToString(), Dr["C_ID"].ToString()));
|
|
}
|
|
ds.Clear();
|
|
Mtxfw.DAL.province daoPro = new Mtxfw.DAL.province();
|
|
System.Data.DataSet Ds = daoPro.GetCacheList("", "1=1 Order by Id Asc", "Province");
|
|
System.Data.DataTable Dt = (Ds != null && Ds.Tables[0] != null) ? Ds.Tables[0] : null;
|
|
foreach (System.Data.DataRow Dr in Dt.Rows)
|
|
{
|
|
Drop_Province.Items.Add(new ListItem(Dr["ProvinceName"].ToString(), Dr["ProvinceID"].ToString()));
|
|
}
|
|
}
|
|
}
|
|
} |