/// <summary> /// 增加一条数据 /// </summary> public int Add(zlzw.Model.StoreImageListModal model) { int rowsAffected; SqlParameter[] parameters = { new SqlParameter("@StoreImageID", SqlDbType.Int, 4), new SqlParameter("@StoreImageGUID", SqlDbType.UniqueIdentifier, 16), new SqlParameter("@DictionaryKey", SqlDbType.NVarChar, 50), new SqlParameter("@StoreImageTitle", SqlDbType.NVarChar, 200), new SqlParameter("@StoreImageDesc", SqlDbType.NVarChar), new SqlParameter("@StoreImagePath", SqlDbType.NVarChar, 200), new SqlParameter("@IsEnable", SqlDbType.Int, 4), new SqlParameter("@IsHot", SqlDbType.Int, 4), new SqlParameter("@PublishDate", SqlDbType.DateTime), new SqlParameter("@Other01", SqlDbType.NVarChar, 50), new SqlParameter("@Other02", SqlDbType.NVarChar, 50), new SqlParameter("@Other03", SqlDbType.NVarChar, 50) }; parameters[0].Direction = ParameterDirection.Output; parameters[1].Value = Guid.NewGuid(); parameters[2].Value = model.DictionaryKey; parameters[3].Value = model.StoreImageTitle; parameters[4].Value = model.StoreImageDesc; parameters[5].Value = model.StoreImagePath; parameters[6].Value = model.IsEnable; parameters[7].Value = model.IsHot; parameters[8].Value = model.PublishDate; parameters[9].Value = model.Other01; parameters[10].Value = model.Other02; parameters[11].Value = model.Other03; DbHelperSQL.RunProcedure("StoreImageList_ADD", parameters, out rowsAffected); return((int)parameters[0].Value); }
protected void btnDel_Click(object sender, EventArgs e) { if (grid1.SelectedRowIndexArray != null && grid1.SelectedRowIndexArray.Length > 0) { string strSelectID = "0"; for (int i = 0, count = grid1.SelectedRowIndexArray.Length; i < count; i++) { int rowIndex = grid1.SelectedRowIndexArray[i]; foreach (object key in grid1.DataKeys[rowIndex]) { strSelectID = key.ToString(); } } #region 除逻辑 zlzw.BLL.StoreImageListBLL storeImageListBLL = new zlzw.BLL.StoreImageListBLL(); DataTable dt = storeImageListBLL.GetList("StoreImageGUID='" + strSelectID + "'").Tables[0]; zlzw.Model.StoreImageListModal storeImageListModal = storeImageListBLL.GetModel(int.Parse(dt.Rows[0]["StoreImageID"].ToString())); storeImageListModal.IsEnable = 0; storeImageListBLL.Update(storeImageListModal); StoreImageList_BindGrid(); #endregion } else { return; } }
protected void btnSaveRefresh_Click(object sender, EventArgs e) { if (Request.QueryString["Type"] == "1") { //编辑保存 zlzw.Model.StoreImageListModal storeImageListModal = new zlzw.Model.StoreImageListModal(); storeImageListModal.Other01 = drpRegionList.SelectedValue; storeImageListModal.DictionaryKey = drpStoreType.SelectedValue; //所属门店 storeImageListModal.StoreImageTitle = txbStoreImageTitle.Text; //门店名称 storeImageListModal.StoreImageDesc = txbStoreImageDesc.Text; //合作伙伴简介 if (btnStoreImageUpload.PostedFile.ContentLength > 0) { btnStoreImageUpload.SaveAs(Server.MapPath(ViewState["StoreImagePath"].ToString())); storeImageListModal.StoreImagePath = ViewState["StoreImagePath"].ToString();//保存门店展示图片路径 } else { storeImageListModal.StoreImagePath = ViewState["StoreImagePath"].ToString(); } storeImageListModal.IsEnable = 1; storeImageListModal.PublishDate = DateTime.Parse(ViewState["PublishDate"].ToString()); storeImageListModal.StoreImageID = int.Parse(Get_StoreImageID(Request.QueryString["value"])); storeImageListModal.StoreImageGUID = new Guid(Request.QueryString["value"]); zlzw.BLL.StoreImageListBLL storeImageListBLL = new zlzw.BLL.StoreImageListBLL(); storeImageListBLL.Update(storeImageListModal); } else { //添加保存 zlzw.Model.StoreImageListModal storeImageListModal = new zlzw.Model.StoreImageListModal(); storeImageListModal.Other01 = drpRegionList.SelectedValue; storeImageListModal.DictionaryKey = drpStoreType.SelectedValue; //所属门店 storeImageListModal.StoreImageTitle = txbStoreImageTitle.Text; //门店名称 storeImageListModal.StoreImageDesc = txbStoreImageDesc.Text; //合作伙伴简介 storeImageListModal.IsEnable = 1; if (btnStoreImageUpload.HasFile) { string fileName = DateTime.Now.Ticks.ToString() + "_" + btnStoreImageUpload.FileName; btnStoreImageUpload.SaveAs(Server.MapPath("~/storefrontEleganceImages/storeImages/" + fileName)); storeImageListModal.StoreImagePath = "~/storefrontEleganceImages/storeImages/" + fileName;//保存门店展示图片路径 } else { Alert.Show("请上传一张尺寸为166 * 55 的门店展示图片", "错误提醒", MessageBoxIcon.Error); return; } storeImageListModal.StoreImageGUID = Guid.NewGuid(); storeImageListModal.PublishDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")); zlzw.BLL.StoreImageListBLL storeImageListBLL = new zlzw.BLL.StoreImageListBLL(); storeImageListBLL.Add(storeImageListModal); } // 2. Close this window and Refresh parent window PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); }
/// <summary> /// 得到一个对象实体 /// </summary> public zlzw.Model.StoreImageListModal DataRowToModel(DataRow row) { zlzw.Model.StoreImageListModal model = new zlzw.Model.StoreImageListModal(); if (row != null) { if (row["StoreImageID"] != null && row["StoreImageID"].ToString() != "") { model.StoreImageID = int.Parse(row["StoreImageID"].ToString()); } if (row["StoreImageGUID"] != null && row["StoreImageGUID"].ToString() != "") { model.StoreImageGUID = new Guid(row["StoreImageGUID"].ToString()); } if (row["DictionaryKey"] != null) { model.DictionaryKey = row["DictionaryKey"].ToString(); } if (row["StoreImageTitle"] != null) { model.StoreImageTitle = row["StoreImageTitle"].ToString(); } if (row["StoreImageDesc"] != null) { model.StoreImageDesc = row["StoreImageDesc"].ToString(); } if (row["StoreImagePath"] != null) { model.StoreImagePath = row["StoreImagePath"].ToString(); } if (row["IsEnable"] != null && row["IsEnable"].ToString() != "") { model.IsEnable = int.Parse(row["IsEnable"].ToString()); } if (row["IsHot"] != null && row["IsHot"].ToString() != "") { model.IsHot = int.Parse(row["IsHot"].ToString()); } if (row["PublishDate"] != null && row["PublishDate"].ToString() != "") { model.PublishDate = DateTime.Parse(row["PublishDate"].ToString()); } if (row["Other01"] != null) { model.Other01 = row["Other01"].ToString(); } if (row["Other02"] != null) { model.Other02 = row["Other02"].ToString(); } if (row["Other03"] != null) { model.Other03 = row["Other03"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(zlzw.Model.StoreImageListModal model) { int rowsAffected = 0; SqlParameter[] parameters = { new SqlParameter("@StoreImageID", SqlDbType.Int, 4), new SqlParameter("@StoreImageGUID", SqlDbType.UniqueIdentifier, 16), new SqlParameter("@DictionaryKey", SqlDbType.NVarChar, 50), new SqlParameter("@StoreImageTitle", SqlDbType.NVarChar, 200), new SqlParameter("@StoreImageDesc", SqlDbType.NVarChar), new SqlParameter("@StoreImagePath", SqlDbType.NVarChar, 200), new SqlParameter("@IsEnable", SqlDbType.Int, 4), new SqlParameter("@IsHot", SqlDbType.Int, 4), new SqlParameter("@PublishDate", SqlDbType.DateTime), new SqlParameter("@Other01", SqlDbType.NVarChar, 50), new SqlParameter("@Other02", SqlDbType.NVarChar, 50), new SqlParameter("@Other03", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.StoreImageID; parameters[1].Value = model.StoreImageGUID; parameters[2].Value = model.DictionaryKey; parameters[3].Value = model.StoreImageTitle; parameters[4].Value = model.StoreImageDesc; parameters[5].Value = model.StoreImagePath; parameters[6].Value = model.IsEnable; parameters[7].Value = model.IsHot; parameters[8].Value = model.PublishDate; parameters[9].Value = model.Other01; parameters[10].Value = model.Other02; parameters[11].Value = model.Other03; DbHelperSQL.RunProcedure("StoreImageList_Update", parameters, out rowsAffected); if (rowsAffected > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public zlzw.Model.StoreImageListModal GetModel(int StoreImageID) { SqlParameter[] parameters = { new SqlParameter("@StoreImageID", SqlDbType.Int, 4) }; parameters[0].Value = StoreImageID; zlzw.Model.StoreImageListModal model = new zlzw.Model.StoreImageListModal(); DataSet ds = DbHelperSQL.RunProcedure("StoreImageList_GetModel", parameters, "ds"); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
private void LoadData(string strType) { if (strType == "1") { string strID = Request.QueryString["value"];//操作ID zlzw.BLL.StoreImageListBLL storeImageListBLL = new zlzw.BLL.StoreImageListBLL(); DataTable dt = storeImageListBLL.GetList("StoreImageGUID='" + strID + "'").Tables[0]; zlzw.Model.StoreImageListModal storeImageListModal = storeImageListBLL.GetModel(int.Parse(dt.Rows[0]["StoreImageID"].ToString())); drpRegionList.SelectedValue = storeImageListModal.Other01.ToString(); drpStoreType.SelectedValue = storeImageListModal.DictionaryKey; //所属门店 txbStoreImageTitle.Text = storeImageListModal.StoreImageTitle; //门店名称 txbStoreImageDesc.Text = storeImageListModal.StoreImageDesc; //门店简介 imgUploadLogo.ImageUrl = storeImageListModal.StoreImagePath; //显示上传后的图片 imgUploadLogo.Visible = true; ViewState["StoreImagePath"] = storeImageListModal.StoreImagePath; //门店图片地址 ViewState["PublishDate"] = storeImageListModal.PublishDate.ToString(); ViewState["StoreImageGUID"] = storeImageListModal.StoreImageGUID.ToString(); ToolbarText2.Text = "编辑一个门店展示图片"; } btnClose.OnClientClick = ActiveWindow.GetConfirmHideReference(); }