/// <summary> /// 得到一个对象实体 by SQLpara /// </summary> public Lebi_Area GetModel(SQLPara para) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from [Lebi_Area] "); if (para.Where != "") { strSql.Append(" where " + para.Where + ""); } Lebi_Area model = new Lebi_Area(); DataSet ds = SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString(), para.Para); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["Parentid"].ToString() != "") { model.Parentid = int.Parse(ds.Tables[0].Rows[0]["Parentid"].ToString()); } model.Name = ds.Tables[0].Rows[0]["Name"].ToString(); if (ds.Tables[0].Rows[0]["Sort"].ToString() != "") { model.Sort = int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString()); } model.Code = ds.Tables[0].Rows[0]["Code"].ToString(); return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Lebi_Area model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [Lebi_Area]("); strSql.Append("Parentid,Name,Sort,Code)"); strSql.Append(" values ("); strSql.Append("@Parentid,@Name,@Sort,@Code)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Parentid", model.Parentid), new SqlParameter("@Name", model.Name), new SqlParameter("@Sort", model.Sort), new SqlParameter("@Code", model.Code) }; object obj = SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
private string CreatSelect(int id) { string str = "<select id=\"Area_" + id + "\" onchange=\"SelectAreaList(" + topid + ",'Area_" + id + "');\">"; Lebi_Area area = B_Lebi_Area.GetModel(id); if (area == null) { return(""); } if (topid == area.id) { return(""); } List <Lebi_Area> models = B_Lebi_Area.GetList("Parentid=" + area.Parentid + "", "Sort asc"); if (models.Count == 0) { return(""); } foreach (Lebi_Area model in models) { if (id == model.id) { str += "<option value=\"" + model.id + "\" selected>" + model.Name + "</option>"; } else { str += "<option value=\"" + model.id + "\">" + model.Name + "</option>"; } } str += "</select> "; str = CreatSelect(area.Parentid) + str; return(str); }
protected void Page_Load(object sender, EventArgs e) { int id = RequestTool.RequestInt("id", 0); pid = RequestTool.RequestInt("pid", 0); if (id == 0) { if (!EX_Admin.Power("area_add", "添加地名")) { WindowNoPower(); } } else { if (!EX_Admin.Power("area_edit", "编辑地名")) { WindowNoPower(); } } model = B_Lebi_Area.GetModel(id); if (model == null) { model = new Lebi_Area(); model.Parentid = pid; } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Lebi_Area model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [Lebi_Area] set "); strSql.Append("Parentid= @Parentid,"); strSql.Append("Name= @Name,"); strSql.Append("Sort= @Sort,"); strSql.Append("Code= @Code"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@Parentid", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.NVarChar, 100), new SqlParameter("@Sort", SqlDbType.Int, 4), new SqlParameter("@Code", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.id; parameters[1].Value = model.Parentid; parameters[2].Value = model.Name; parameters[3].Value = model.Sort; parameters[4].Value = model.Code; SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters); }
protected Lebi_Area Getarea(int id) { Lebi_Area area = B_Lebi_Area.GetModel(id); if (area == null) { area = new Lebi_Area(); } return(area); }
/// <summary> /// 返回一个AREA的所有父id(不含自己) /// </summary> /// <param name="id"></param> /// <returns></returns> public static string Parentids_Get(int area_id) { string ids = ""; Lebi_Area area = B_Lebi_Area.GetModel(area_id); if (area != null) { ids = area.Parentid.ToString(); if (area.Parentid > 0) { ids += "," + Parentids_Get(area.Parentid); } } return(ids); }
public string AreaName(int id) { string str = ""; Lebi_Area area = B_Lebi_Area.GetModel(id); if (area != null) { str = area.Name + "> "; if (area.Parentid > 0) { str = AreaName(area.Parentid) + str; } } return(str); }
protected string Getpath(int id) { string str = ""; Lebi_Area area = B_Lebi_Area.GetModel(id); if (area != null) { str = " > <a href=\"?pid=" + id + "\">" + area.Name + "</a>"; if (area.Parentid > 0) { str = Getpath(area.Parentid) + str; } } return(str); }
/// <summary> /// 返回地区名称目录 /// </summary> /// <param name="area_id"></param> /// <param name="deep">目录深度</param> /// <returns></returns> public static string GetAreaName(int area_id, int deep) { string res = ""; deep--; Lebi_Area area = B_Lebi_Area.GetModel(area_id); if (area == null) { return(res); } res = area.Name; if (deep > 0) { res = GetAreaName(area.Parentid, deep) + " " + res; } return(res); }
/// <summary> /// 返回地区名称目录 /// </summary> /// <param name="area_id"></param> /// <param name="deep">目录深度 0</param> /// <param name="loop">显示层级</param> /// <returns></returns> public static string GetAreaName(int area_id, int deep, int loop) { string res = ""; loop++; Lebi_Area area = B_Lebi_Area.GetModel(area_id); if (area == null) { return(res); } res = area.Name; if (area.Parentid > 0 && loop < 5) { res = GetAreaName(area.Parentid, deep, loop); } return(res); }
/// <summary> /// 查询对于的代理资格设置 /// </summary> /// <param name="areaid"></param> /// <returns></returns> private Lebi_Agent_Area GetAgentArea(int areaid) { Lebi_Agent_Area agentarea = B_Lebi_Agent_Area.GetModel("Area_id=" + areaid + " and IsFailure=0"); if (agentarea != null) { return(agentarea); } else { Lebi_Area area = B_Lebi_Area.GetModel(areaid); if (area != null) { return(GetAgentArea(area.Parentid)); } } return(null); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Lebi_Area model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [Lebi_Area]("); strSql.Append("[Parentid],[Name],[Sort],[Code])"); strSql.Append(" values ("); strSql.Append("@Parentid,@Name,@Sort,@Code)"); OleDbParameter[] parameters = { new OleDbParameter("@Parentid", model.Parentid), new OleDbParameter("@Name", model.Name), new OleDbParameter("@Sort", model.Sort), new OleDbParameter("@Code", model.Code) }; AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters); return(1); }
/// <summary> /// 获取指定运输公司,指定区域的价格 /// </summary> /// <returns></returns> public static Lebi_Transport_Price GetAreaPrice(int transport_id, int area_id, int supplierid) { Lebi_Transport_Price price = B_Lebi_Transport_Price.GetModel("Transport_id=" + transport_id + " and Area_id=" + area_id + " and Supplier_id=" + supplierid + ""); if (price == null) { Lebi_Area area = B_Lebi_Area.GetModel(area_id); if (area != null) { if (area.Parentid > 0) { return(GetAreaPrice(transport_id, area.Parentid, supplierid)); } return(null); } return(null); } return(price); }
/// <summary> /// 返回一个AREA的最后一个父id(不含自己) /// </summary> /// <param name="id"></param> /// <returns></returns> public static int Parentids_Get(int area_id, int path) { int id = 0; Lebi_Area area = B_Lebi_Area.GetModel(area_id); if (area == null) { return(area_id); } else { id = area.Parentid; if (area.Parentid > 0) { id = Parentids_Get(area.Parentid, path); } } return(id); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Lebi_Area model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [Lebi_Area] set "); strSql.Append("[Parentid]=@Parentid,"); strSql.Append("[Name]=@Name,"); strSql.Append("[Sort]=@Sort,"); strSql.Append("[Code]=@Code"); strSql.Append(" where id=" + model.id); OleDbParameter[] parameters = { new OleDbParameter("@Parentid", model.Parentid), new OleDbParameter("@Name", model.Name), new OleDbParameter("@Sort", model.Sort), new OleDbParameter("@Code", model.Code) }; AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters); }
/// <summary> /// 安全方式绑定对象表单 /// </summary> public Lebi_Area SafeBindForm(Lebi_Area model) { if (HttpContext.Current.Request["Parentid"] != null) { model.Parentid = Shop.Tools.RequestTool.RequestInt("Parentid", 0); } if (HttpContext.Current.Request["Name"] != null) { model.Name = Shop.Tools.RequestTool.RequestSafeString("Name"); } if (HttpContext.Current.Request["Sort"] != null) { model.Sort = Shop.Tools.RequestTool.RequestInt("Sort", 0); } if (HttpContext.Current.Request["Code"] != null) { model.Code = Shop.Tools.RequestTool.RequestSafeString("Code"); } return(model); }
public static string GetAreaNameNoPath(int area_id, int deep) { string res = ""; deep--; Lebi_Area area = B_Lebi_Area.GetModel(area_id); if (area == null) { return(res); } res = area.Name; if (area.Parentid > 0 && deep > 0) { res = GetAreaNameNoPath(area.Parentid, deep); return(res); } DateTime dt = System.DateTime.Now.Date.AddDays(0 - System.DateTime.Now.Day); return(res); }
/// <summary> /// 递归处理运费价格 /// </summary> /// <param name="area"></param> /// <param name="trans"></param> /// <returns></returns> private static List <Lebi_Transport_Price> TransportPrice(Lebi_Area area, List <Lebi_Transport_Price> trans, int supplierid) { if (trans == null) { trans = B_Lebi_Transport_Price.GetList("Area_id=" + area.id + " and Supplier_id=" + supplierid + "", ""); } else { string pids = ""; List <Lebi_Transport_Price> models = B_Lebi_Transport_Price.GetList("Area_id=" + area.id + " and Supplier_id=" + supplierid + "", ""); foreach (Lebi_Transport_Price model in models) { //排除包含的关系 //跳过儿子,孙子在列表中的情况 bool flag = false; foreach (Lebi_Transport_Price tran in trans) { pids = EX_Area.Parentids_Get(tran.Area_id); pids = "," + pids + ","; if (pids.Contains("," + model.Area_id + ",") && model.Transport_id == tran.Transport_id) { flag = true; } } if (!flag) { trans.Add(model); } } } if (area.Parentid > 0) { area = B_Lebi_Area.GetModel(area.Parentid); if (area != null) { trans = TransportPrice(area, trans, supplierid); } } return(trans); }
//protected List<Lebi_Area> models; public void LoadPage() { topid = RequestTool.RequestInt("topid", 0); area_id = RequestTool.RequestInt("area_id", 0); int Parentid = 0; area_id = area_id == 0 ? topid : area_id; List <Lebi_Area> models = B_Lebi_Area.GetList("Parentid=" + area_id + "", "Sort asc"); Lebi_Area area = B_Lebi_Area.GetModel(area_id); if (models.Count == 0) { Parentid = area.Parentid; models = B_Lebi_Area.GetList("Parentid=" + Parentid + "", "Sort asc"); } else { Parentid = area_id; } string str = "<select id=\"Area_id\" onchange=\"SelectAreaList(" + topid + ",'Area_id');\">"; str += "<option value=\"0\" selected>" + Tag(" 请选择 ") + "</option>"; foreach (Lebi_Area model in models) { if (area_id == model.id) { str += "<option value=\"" + model.id + "\" selected>" + model.Name + "</option>"; } else { str += "<option value=\"" + model.id + "\">" + model.Name + "</option>"; } } str += "</select> "; //if (models.Count > 0) // str += CreatSelect(models.FirstOrDefault().id); str = CreatSelect(Parentid) + str; Response.Write(str); }
/// <summary> /// 根据配送地区取出运输公司并计算相应运费 /// </summary> public static List <Lebi_Transport_Price> TransportPrices_Get(int area_id, int supplierid) { Lebi_Area area = B_Lebi_Area.GetModel(area_id); if (area == null) { return(new List <Lebi_Transport_Price>()); } List <Lebi_Transport_Price> trans = null;//配送地区含当前地区的运输公司以及价格 trans = TransportPrice(area, trans, supplierid); foreach (Lebi_Transport_Price p in trans) { Lebi_Transport t = B_Lebi_Transport.GetModel(p.Transport_id); if (t != null) { p.Sort = t.Sort; } } trans = trans.OrderByDescending(a => a.Sort).ToList(); return(trans); }
public string ThreadGetAreaList(int topid, int area_id, int Parentid) { List <Lebi_Area> models = B_Lebi_Area.GetList("Parentid=" + area_id + "", "Sort desc"); Lebi_Area area = B_Lebi_Area.GetModel(area_id); if (area == null) { area = new Lebi_Area(); } if (models.Count == 0) { Parentid = area.Parentid; models = B_Lebi_Area.GetList("Parentid=" + Parentid + "", "Sort desc"); } else { Parentid = area_id; } string str = "<select id=\"Area_id\" onchange=\"SelectAreaList(" + topid + ",'Area_id');\" class=\"form-control\">"; str += "<option value=\"0\" selected>" + Tag(" 请选择 ") + "</option>"; foreach (Lebi_Area model in models) { if (area_id == model.id) { str += "<option value=\"" + model.id + "\" selected>" + model.Name + "</option>"; } else { str += "<option value=\"" + model.id + "\">" + model.Name + "</option>"; } } str += "</select>"; if (topid != area_id) { str = CreatSelect(Parentid, topid) + str; } return(str); }
/// <summary> /// 得到一个对象实体 by id /// </summary> public Lebi_Area GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from [Lebi_Area] "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Lebi_Area model = new Lebi_Area(); DataSet ds = SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["Parentid"].ToString() != "") { model.Parentid = int.Parse(ds.Tables[0].Rows[0]["Parentid"].ToString()); } model.Name = ds.Tables[0].Rows[0]["Name"].ToString(); if (ds.Tables[0].Rows[0]["Sort"].ToString() != "") { model.Sort = int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString()); } model.Code = ds.Tables[0].Rows[0]["Code"].ToString(); return(model); } else { return(null); } }
public static string GetAreaNameDesc(int area_id, int deep) { string res = ""; deep--; Lebi_Area area = B_Lebi_Area.GetModel(area_id); if (area == null) { return(res); } res = area.Name; if (deep > 0) { Lebi_Area areacheck = B_Lebi_Area.GetModel(area.Parentid); if (areacheck != null) { res = res + ","; } res = res + GetAreaNameDesc(area.Parentid, deep); } return(res); }
/// <summary> /// 对象实体绑定数据 /// </summary> public Lebi_Area ReaderBind(IDataReader dataReader) { Lebi_Area model = new Lebi_Area(); object ojb; ojb = dataReader["id"]; if (ojb != null && ojb != DBNull.Value) { model.id = (int)ojb; } ojb = dataReader["Parentid"]; if (ojb != null && ojb != DBNull.Value) { model.Parentid = (int)ojb; } model.Name = dataReader["Name"].ToString(); ojb = dataReader["Sort"]; if (ojb != null && ojb != DBNull.Value) { model.Sort = (int)ojb; } model.Code = dataReader["Code"].ToString(); return(model); }
/// <summary> /// 更新一条数据 /// </summary> public static void Update(Lebi_Area model) { D_Lebi_Area.Instance.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public static int Add(Lebi_Area model) { return(D_Lebi_Area.Instance.Add(model)); }
/// <summary> /// 安全方式绑定表单数据 /// </summary> public static Lebi_Area SafeBindForm(Lebi_Area model) { return(D_Lebi_Area.Instance.SafeBindForm(model)); }