public static ModelAddState Add(ProductModelInfo model) { int num = ProductModel.ExistsModel(model.ModelName, model.TableName); ModelAddState result; if (num > 0) { result = (ModelAddState)num; } else { string tableName = "dbo." + model.TableName; int num2 = BizBase.dbo.InsertModel <ProductModelInfo>(model); if (num2 > 0) { try { TableManager.CreateTable(tableName, "AutoID"); TableManager.AddTableColumn(tableName, "ProID", "INT", false, "0"); ProductModel.AddDefaultField(num2); CacheUtils.Del("JsonLeeCMS_CacheForPROMODEL"); result = ModelAddState.Success; return(result); } catch { result = ModelAddState.CreateTableError; return(result); } } CacheUtils.Del("JsonLeeCMS_CacheForPROMODEL"); result = ModelAddState.Error; } return(result); }
public static ModelDeleteStatus Delete(int modelID) { ProductModelInfo cacheModelById = ProductModel.GetCacheModelById(modelID); ModelDeleteStatus result; if (cacheModelById == null) { result = ModelDeleteStatus.ModelNotExists; } else if (ProductModel.IsModelRefingByPro(modelID)) { result = ModelDeleteStatus.UserRef; } else if (BizBase.dbo.DeleteModel <ProductModelInfo>(cacheModelById)) { BizBase.dbo.ExecSQL(" DROP TABLE " + cacheModelById.TableName); CacheUtils.Del("JsonLeeCMS_CacheForPROMODEL"); result = ModelDeleteStatus.Success; } else { CacheUtils.Del("JsonLeeCMS_CacheForPROMODEL"); result = ModelDeleteStatus.Error; } return(result); }
public static bool AddCustomProduct(ProductModelInfo model, IList <ProductFieldInfo> fieldList) { string commandText = Product.GenerateSqlOfInsert(model.TableName, fieldList); SqlParameter[] parameters = Product.PrepareSqlParameters(fieldList); return(DBHelper.ExecuteNonQuery(commandText, parameters) > 0); }
public static IList <ProductFieldInfo> GetFieldListWithValue(int intProID, int intModelID) { IList <ProductFieldInfo> fieldListByModelID = ProductField.GetFieldListByModelID(intModelID, true); IList <ProductFieldInfo> usingFieldList = ProductField.GetUsingFieldList(intModelID); ProductModelInfo cacheModelById = ProductModel.GetCacheModelById(intModelID); if (cacheModelById != null) { DataTable dataTable = BizBase.dbo.GetDataTable(string.Concat(new object[] { "SELECT * FROM shop_Product AS A,", cacheModelById.TableName, " AS B WHERE A.AutoID=", intProID, " AND B.ProID=", intProID })); if (dataTable.Rows.Count == 1) { foreach (ProductFieldInfo current in fieldListByModelID) { if (dataTable.Columns.Contains(current.FieldName)) { current.Value = dataTable.Rows[0][current.FieldName].ToString(); } else { current.Value = current.DefaultValue; } } } } return(fieldListByModelID); }
private string NodeToXml(CategoryInfo cate) { System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); ProductModelInfo cacheModelById = ProductModel.GetCacheModelById(cate.ModelID); stringBuilder.Append(string.Concat(new string[] { "<Cate name=\"", cate.CategoryName, "\" id=\"", cate.UrlRewriteName, "\" model=\"", (cacheModelById == null) ? "0" : cacheModelById.ModelName, "\" >" })); if (cate.ChildCount > 0) { foreach (CategoryInfo current in SinGooCMS.BLL.Category.GetCacheChildCate(cate.AutoID)) { stringBuilder.Append(this.NodeToXml(current)); } } stringBuilder.Append("</Cate>"); return(stringBuilder.ToString()); }
public static FieldAddState Add(ProductFieldInfo field) { ProductModelInfo dataById = ProductModel.GetDataById(field.ModelID); FieldAddState result; if (dataById == null) { result = FieldAddState.ModelNotExists; } else { int value = BizBase.dbo.GetValue <int>(string.Concat(new object[] { "SELECT COUNT(*) FROM shop_ProductField WHERE ModelID=", field.ModelID, " AND FieldName='", field.FieldName, "'" })); if (value > 0) { result = FieldAddState.FieldNameExists; } else { if (BizBase.dbo.InsertModel <ProductFieldInfo>(field) > 0) { try { string text = field.DataType; if (string.Compare(text, "nvarchar", true) == 0) { object obj = text; text = string.Concat(new object[] { obj, "(", field.DataLength, ")" }); } TableManager.AddTableColumn(dataById.TableName, field.FieldName, text, true, field.DefaultValue); } catch { result = FieldAddState.CreateColumnError; return(result); } } CacheUtils.Del("JsonLeeCMS_CacheForGetUserGroup"); result = FieldAddState.Success; } } return(result); }
protected void Page_Load(object sender, System.EventArgs e) { this.IsOnSale = WebUtils.GetQueryString("Status", "On"); this.currCate = SinGooCMS.BLL.Category.GetCacheCategoryByID(WebUtils.GetQueryInt("CateID")); this.goodsClass = SinGooCMS.BLL.GoodsClass.GetDataById(WebUtils.GetQueryInt("ClassID")); if (base.IsEdit) { this.proInit = Product.GetDataById(base.OpID); if (this.currCate == null) { this.currCate = SinGooCMS.BLL.Category.GetDataById((this.proInit == null) ? 0 : this.proInit.CateID); } if (this.goodsClass == null) { this.goodsClass = SinGooCMS.BLL.GoodsClass.GetDataById((this.proInit == null) ? 0 : this.proInit.ClassID); } } this.panelgg.Visible = (this.panelswitch.Visible = ((this.goodsClass == null) ? false : true)); if (this.currCate == null) { base.ClientScript.RegisterClientScriptBlock(base.GetType(), "alertandredirect", string.Concat(new object[] { "<script>alert('Không tìm thấy thông tin');location='Products.aspx?CatalogID=", base.CurrentCatalogID, "&Module=", base.CurrentModuleCode, "&action=View'</script>" })); } else if (base.IsEdit && this.proInit == null) { base.ClientScript.RegisterClientScriptBlock(base.GetType(), "alertandredirect", string.Concat(new object[] { "<script>alert('Thông tin sản phẩm không tìm thấy');location='Products.aspx?CatalogID=", base.CurrentCatalogID, "&Module=", base.CurrentModuleCode, "&action=View'</script>" })); } else { this.proModel = (base.IsEdit ? ProductModel.GetCacheModelById(this.proInit.ModelID) : ProductModel.GetCacheModelById(this.currCate.ModelID)); if (!base.IsPostBack) { this.BindBrand(); this.BindAreaModel(); this.BindPostageModel(); this.BindTags(); this.BindData(); } } }
public static bool Delete(int fieldID) { ProductFieldInfo dataById = ProductField.GetDataById(fieldID); ProductModelInfo dataById2 = ProductModel.GetDataById(dataById.ModelID); if (BizBase.dbo.DeleteModel <ProductFieldInfo>(dataById)) { TableManager.DropTableColumn(dataById2.TableName, dataById.FieldName); } CacheUtils.Del("JsonLeeCMS_CacheForPROMODEL"); return(true); }
private void InitForModify() { ProductModelInfo dataById = ProductModel.GetDataById(base.OpID); this.TextBox1.Text = dataById.ModelName; this.TextBox2.Text = dataById.TableName.Split(new char[] { '_' })[2]; this.TextBox3.Text = dataById.ModelDesc; this.TextBox2.Enabled = false; }
public static bool Update(ProductInfo proMain, Dictionary <string, ProductFieldInfo> dicField, List <PhotoAlbumInfo> listPhoto) { proMain.Specifications = Product.GetStringFromDic("Specifications", dicField); proMain.ModelNum = Product.GetStringFromDic("ModelNum", dicField); proMain.Size = Product.GetStringFromDic("Size", dicField); proMain.Weight = Product.GetStringFromDic("Weight", dicField); proMain.Color = Product.GetStringFromDic("Color", dicField); proMain.Material = Product.GetStringFromDic("Material", dicField); proMain.ProducingArea = Product.GetStringFromDic("ProducingArea", dicField); proMain.ShortDesc = Product.GetStringFromDic("ShortDesc", dicField); proMain.ProDetail = Product.GetStringFromDic("ProDetail", dicField); bool result; if (Product.Update(proMain)) { ProductModelInfo cacheModelById = ProductModel.GetCacheModelById(proMain.ModelID); IList <ProductFieldInfo> customFieldListByModelID = ProductField.GetCustomFieldListByModelID(proMain.ModelID); foreach (ProductFieldInfo current in customFieldListByModelID) { if (current.FieldName == "ProID") { current.Value = proMain.AutoID.ToString(); } else { current.Value = Product.GetStringFromDic(current.FieldName, dicField); } } if (Product.ExistsCustomTableData(cacheModelById.TableName, proMain.AutoID)) { Product.UpdateCustomTable(proMain.AutoID, cacheModelById.TableName, customFieldListByModelID); } else { Product.AddCustomProduct(cacheModelById, customFieldListByModelID); } PhotoAlbum.DelPhotoByProID(proMain.AutoID); if (listPhoto.Count > 0) { foreach (PhotoAlbumInfo current2 in listPhoto) { current2.ProID = proMain.AutoID; } PhotoAlbum.AddPhotoList(listPhoto); } result = true; } else { result = false; } return(result); }
protected void Page_Load(object sender, System.EventArgs e) { this.intModelID = WebUtils.GetQueryInt("ModelID"); this.modelParent = ProductModel.GetCacheModelById(this.intModelID); if (this.modelParent == null) { base.ShowMsg("Thông tin mô hình sản phẩm không tìm thấy"); } else if (!base.IsPostBack) { this.BindData(); } }
public static bool Add(ProductInfo proMain, Dictionary <string, ProductFieldInfo> dicField, List <PhotoAlbumInfo> listPhoto) { proMain.Specifications = Product.GetStringFromDic("Specifications", dicField); proMain.ModelNum = Product.GetStringFromDic("ModelNum", dicField); proMain.Size = Product.GetStringFromDic("Size", dicField); proMain.Weight = Product.GetStringFromDic("Weight", dicField); proMain.Color = Product.GetStringFromDic("Color", dicField); proMain.Material = Product.GetStringFromDic("Material", dicField); proMain.ProducingArea = Product.GetStringFromDic("ProducingArea", dicField); proMain.ShortDesc = Product.GetStringFromDic("ShortDesc", dicField); proMain.ProDetail = Product.GetStringFromDic("ProDetail", dicField); proMain.Sort = Product.MaxSort + 1; proMain.AutoTimeStamp = DateTime.Now; proMain.Lang = JObject.cultureLang; int num = Product.Add(proMain); bool result; if (num > 0) { proMain.AutoID = num; ProductModelInfo cacheModelById = ProductModel.GetCacheModelById(proMain.ModelID); IList <ProductFieldInfo> customFieldListByModelID = ProductField.GetCustomFieldListByModelID(proMain.ModelID); foreach (ProductFieldInfo current in customFieldListByModelID) { if (current.FieldName == "ProID") { current.Value = num.ToString(); } else { current.Value = Product.GetStringFromDic(current.FieldName, dicField); } } Product.AddCustomProduct(cacheModelById, customFieldListByModelID); if (listPhoto.Count > 0) { foreach (PhotoAlbumInfo current2 in listPhoto) { current2.ProID = num; } PhotoAlbum.AddPhotoList(listPhoto); } result = true; } else { result = false; } return(result); }
protected void lnk_Delete_Click(object sender, System.EventArgs e) { if (!base.IsAuthorizedOp(ActionType.Delete.ToString())) { base.ShowAjaxMsg(this.UpdatePanel1, "Không có thẩm quyền"); } else { int @int = WebUtils.GetInt((sender as LinkButton).CommandArgument); ProductModelInfo cacheModelById = ProductModel.GetCacheModelById(@int); if (cacheModelById == null) { base.ShowAjaxMsg(this.UpdatePanel1, "Những thông tin này không được tìm thấy, các dữ liệu không tồn tại hoặc đã bị xóa"); } else { ModelDeleteStatus modelDeleteStatus = ProductModel.Delete(@int); ModelDeleteStatus modelDeleteStatus2 = modelDeleteStatus; switch (modelDeleteStatus2) { case ModelDeleteStatus.Error: base.ShowAjaxMsg(this.UpdatePanel1, "删除模型失败"); break; case ModelDeleteStatus.ModelNotExists: base.ShowAjaxMsg(this.UpdatePanel1, "模型不存在或者已经被删除"); break; case ModelDeleteStatus.NodesRef: case ModelDeleteStatus.ContentRef: break; case ModelDeleteStatus.UserRef: base.ShowAjaxMsg(this.UpdatePanel1, "无法删除,正被产品引用"); break; default: if (modelDeleteStatus2 == ModelDeleteStatus.Success) { ProductField.DeleteByModelID(@int); this.BindData(); PageBase.log.AddEvent(base.LoginAccount.AccountName, "删除模型[" + cacheModelById.ModelName + "] thành công"); base.ShowAjaxMsg(this.UpdatePanel1, "Thao tác thành công"); } break; } } } }
private void AddCategory(XmlNode node, int intParentID) { CategoryInfo categoryInfo = (from p in SinGooCMS.BLL.Category.GetCacheCategoryList() where p.AutoID.Equals(intParentID) select p).FirstOrDefault <CategoryInfo>(); string strModelName = "普通商品模型"; if (node.Attributes["model"] != null) { strModelName = node.Attributes["model"].Value.Trim(); } ProductModelInfo modelByName = ProductModel.GetModelByName(strModelName); if (node.Attributes["name"] != null && modelByName != null) { string text = node.Attributes["name"].Value.Trim(); string text2 = StringUtils.GetNewFileName(); if (node.Attributes["id"] != null) { text2 = node.Attributes["id"].Value.Trim(); } CategoryInfo cate = new CategoryInfo { CategoryName = text, ParentID = intParentID, ModelID = modelByName.AutoID, SeoKey = text, SeoDescription = text, Remark = string.Empty, ItemPageSize = 10, IsTop = false, IsRecommend = false, Lang = base.cultureLang, AutoTimeStamp = System.DateTime.Now }; int intParentID2 = 0; if (SinGooCMS.BLL.Category.Add(cate, out intParentID2) == NodeAddStatus.Success) { if (node.HasChildNodes) { foreach (XmlNode node2 in node.ChildNodes) { this.AddCategory(node2, intParentID2); } } } } }
public static ProductInfo GetProduct(int intProductID) { ProductInfo dataById = Product.GetDataById(intProductID); if (dataById != null) { ProductModelInfo cacheModelById = ProductModel.GetCacheModelById(dataById.ModelID); dataById.CustomTable = Product.GetCustomContentInfo(intProductID, cacheModelById.TableName); dataById.PhotoAlbums = PhotoAlbum.GetPhotoAlbumByPID(intProductID); UserInfo user = User.GetLoginUser(); if (user != null) { dataById.MemberPriceSets = MemberPriceSet.GetList(dataById.MemberPriceSet, dataById.SellPrice); MemberPriceSetInfo memberPriceSetInfo = (from p in dataById.MemberPriceSets where p.UserLevelID.Equals(user.LevelID) select p).FirstOrDefault <MemberPriceSetInfo>(); if (memberPriceSetInfo != null) { dataById.MemberPrice = ((memberPriceSetInfo.Price > 0m) ? memberPriceSetInfo.Price : memberPriceSetInfo.DiscoutPrice); if (dataById.MemberPrice == 0m) { dataById.MemberPrice = dataById.SellPrice; } } } dataById.PriceRange = dataById.SellPrice.ToString("f2"); dataById.RealStock = dataById.Stock; if (dataById.ClassID > 0) { List <decimal> priceRange = GoodsSpecify.GetPriceRange(dataById); if (priceRange[0] == priceRange[1]) { dataById.PriceRange = priceRange[0].ToString("f2"); } else { dataById.PriceRange = priceRange[0].ToString("f2") + " - " + priceRange[1].ToString("f2"); } dataById.GuiGe = GoodsSpecify.GetListByProID(dataById.AutoID); if (dataById.GuiGe != null && dataById.GuiGe.Count > 0) { dataById.RealStock = dataById.GuiGe.Sum((GoodsSpecifyInfo p) => p.Stock); } } } return(dataById); }
protected void Page_Load(object sender, System.EventArgs e) { this.intModelID = WebUtils.GetQueryInt("ModelID"); this.modelParent = ProductModel.GetCacheModelById(this.intModelID); if (this.modelParent == null) { base.ClientScript.RegisterClientScriptBlock(base.GetType(), "alertandredirect", "<script>alert('Thông tin kiểu dữ liệu không tìm thấy');history.go(-1);</script>"); } else { this.labModelName.Text = this.modelParent.ModelName; if (base.IsEdit && !base.IsPostBack) { this.InitForModify(); } } }
public static ProductModelInfo GetCacheModelById(int intModelID) { ProductModelInfo result = null; IList <ProductModelInfo> cacheModelList = ProductModel.GetCacheModelList(); if (cacheModelList != null && cacheModelList.Count > 0) { foreach (ProductModelInfo current in cacheModelList) { if (current.AutoID == intModelID) { result = current; break; } } } return(result); }
public static bool Update(ProductFieldInfo field) { ProductModelInfo dataById = ProductModel.GetDataById(field.ModelID); ProductFieldInfo dataById2 = ProductField.GetDataById(field.AutoID); bool result; if (BizBase.dbo.UpdateModel <ProductFieldInfo>(field)) { if (!dataById2.IsSystem) { try { string text = field.DataType; if (string.Compare(text, "nvarchar", true) == 0) { object obj = text; text = string.Concat(new object[] { obj, "(", field.DataLength, ")" }); } TableManager.AlterTableColumn(dataById.TableName, dataById2.FieldName, field.FieldName, text, true, field.DefaultValue); } catch (Exception ex) { throw ex; } } CacheUtils.Del("JsonLeeCMS_CacheForPROMODEL"); result = true; } else { result = false; } return(result); }
public static bool CopyProduct(int intProductID) { ProductInfo dataById = Product.GetDataById(intProductID); bool result; if (dataById != null) { ProductModelInfo cacheModelById = ProductModel.GetCacheModelById(dataById.ModelID); dataById.ProductName = "复件:" + dataById.ProductName; dataById.ProductSN = Product.GetProductSN(); dataById.Status = 0; dataById.AutoTimeStamp = DateTime.Now; dataById.Sales = 0; dataById.Sort = Product.MaxSort + 1; int num = BizBase.dbo.InsertModel <ProductInfo>(dataById); if (num > 0) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(" INSERT INTO " + cacheModelById.TableName + " ( "); IList <ProductFieldInfo> customFieldListByModelID = ProductField.GetCustomFieldListByModelID(cacheModelById.AutoID); for (int i = 0; i < customFieldListByModelID.Count; i++) { if (customFieldListByModelID[i].FieldName != "AutoID") { if (i == customFieldListByModelID.Count - 1) { stringBuilder.Append(customFieldListByModelID[i].FieldName); } else { stringBuilder.Append(customFieldListByModelID[i].FieldName + ","); } } } stringBuilder.Append(" ) "); stringBuilder.Append(" SELECT "); for (int i = 0; i < customFieldListByModelID.Count; i++) { if (customFieldListByModelID[i].FieldName != "AutoID") { if (i == customFieldListByModelID.Count - 1) { if (customFieldListByModelID[i].FieldName.Equals("ProID")) { stringBuilder.Append(num.ToString()); } else { stringBuilder.Append(customFieldListByModelID[i].FieldName); } } else if (customFieldListByModelID[i].FieldName.Equals("ProID")) { stringBuilder.Append(num.ToString() + ","); } else { stringBuilder.Append(customFieldListByModelID[i].FieldName + ","); } } } stringBuilder.Append(string.Concat(new object[] { " FROM ", cacheModelById.TableName, " WHERE ProID=", dataById.AutoID })); result = BizBase.dbo.ExecSQL(stringBuilder.ToString()); return(result); } } result = false; return(result); }
public static bool Update(ProductModelInfo model) { CacheUtils.Del("JsonLeeCMS_CacheForPROMODEL"); return(BizBase.dbo.UpdateModel <ProductModelInfo>(model)); }
protected void btnok_Click(object sender, System.EventArgs e) { if (base.Action.Equals(ActionType.Add.ToString()) && !base.IsAuthorizedOp(ActionType.Add.ToString())) { base.ShowMsg("Không có thẩm quyền"); } else if (base.Action.Equals(ActionType.Modify.ToString()) && !base.IsAuthorizedOp(ActionType.Modify.ToString())) { base.ShowMsg("Không có thẩm quyền"); } else { ProductModelInfo productModelInfo = new ProductModelInfo(); if (base.IsEdit) { productModelInfo = ProductModel.GetCacheModelById(base.OpID); } productModelInfo.ModelName = WebUtils.GetString(this.TextBox1.Text); productModelInfo.TableName = "shop_P_" + WebUtils.GetString(this.TextBox2.Text); productModelInfo.ModelDesc = WebUtils.GetString(this.TextBox3.Text); productModelInfo.Creator = base.LoginAccount.AccountName; if (string.IsNullOrEmpty(productModelInfo.ModelName)) { base.ShowMsg("模型名称不能为空"); } else if (string.IsNullOrEmpty(this.TextBox2.Text)) { base.ShowMsg("数据表名不能为空"); } else { if (base.Action.Equals(ActionType.Add.ToString())) { productModelInfo.Sort = ProductModel.MaxSort + 1; productModelInfo.AutoTimeStamp = System.DateTime.Now; ModelAddState modelAddState = ProductModel.Add(productModelInfo); ModelAddState modelAddState2 = modelAddState; switch (modelAddState2) { case ModelAddState.Error: base.ShowMsg("添加产品模型失败"); break; case ModelAddState.ModelNameExists: base.ShowMsg("产品模型名称已经存在"); break; case ModelAddState.TableNameIsUsing: base.ShowMsg("已经存在相同的自定义表名称"); break; case ModelAddState.TableExists: base.ShowMsg("自定义表已经存在"); break; case ModelAddState.CreateTableError: base.ShowMsg("创建自定义表失败"); break; default: if (modelAddState2 == ModelAddState.Success) { PageBase.log.AddEvent(base.LoginAccount.AccountName, "添加产品模型[" + productModelInfo.ModelName + "] thành công"); MessageUtils.DialogCloseAndParentReload(this); } break; } } if (base.Action.Equals(ActionType.Modify.ToString())) { if (ProductModel.Update(productModelInfo)) { PageBase.log.AddEvent(base.LoginAccount.AccountName, "修改产品模型[" + productModelInfo.ModelName + "] thành công"); MessageUtils.DialogCloseAndParentReload(this); } else { base.ShowMsg("修改产品模型失败"); } } } } }