Ejemplo n.º 1
0
 public static bool CreateFriendlyLink(FriendlyLinksInfo friendlyLink)
 {
     if (null == friendlyLink)
     {
         return false;
     }
     return StoreProvider.Instance().CreateUpdateDeleteFriendlyLink(friendlyLink, DataProviderAction.Create);
 }
Ejemplo n.º 2
0
 private void AddNewFriendlyLink(FriendlyLinksInfo friendlyLink)
 {
     if (SubsiteStoreHelper.CreateFriendlyLink(friendlyLink))
     {
         ShowMsg("成功添加了一个友情链接", true);
     }
     else
     {
         ShowMsg("未知错误", false);
     }
 }
Ejemplo n.º 3
0
 private void btnSubmitLinks_Click(object sender, EventArgs e)
 {
     string str = string.Empty;
     if (!(uploadImageUrl.HasFile || !string.IsNullOrEmpty(txtaddTitle.Text.Trim())))
     {
         ShowMsg("友情链接Logo和网站名称不能同时为空", false);
     }
     else
     {
         FriendlyLinksInfo target = new FriendlyLinksInfo();
         if (uploadImageUrl.HasFile)
         {
             try
             {
                 str = SubsiteStoreHelper.UploadLinkImage(uploadImageUrl.PostedFile);
             }
             catch
             {
                 ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false);
                 return;
             }
         }
         target.ImageUrl = str;
         target.LinkUrl = txtaddLinkUrl.Text;
         target.Title = Globals.HtmlEncode(txtaddTitle.Text.Trim());
         target.Visible = radioShowLinks.SelectedValue;
         ValidationResults results = Hishop.Components.Validation.Validation.Validate<FriendlyLinksInfo>(target, new string[] { "ValFriendlyLinksInfo" });
         string msg = string.Empty;
         if (results.IsValid)
         {
             AddNewFriendlyLink(target);
             Reset();
         }
         else
         {
             foreach (ValidationResult result in (IEnumerable<ValidationResult>)results)
             {
                 msg = msg + Formatter.FormatErrorMessage(result.Message);
             }
             ShowMsg(msg, false);
         }
     }
 }
Ejemplo n.º 4
0
 public override bool CreateUpdateDeleteFriendlyLink(FriendlyLinksInfo friendlyLink, DataProviderAction action)
 {
     if (null == friendlyLink)
     {
         return false;
     }
     DbCommand storedProcCommand = database.GetStoredProcCommand("cp_FriendlyLink_CreateUpdateDelete");
     database.AddInParameter(storedProcCommand, "Action", DbType.Int32, (int)action);
     database.AddOutParameter(storedProcCommand, "Status", DbType.Int32, 4);
     if (action != DataProviderAction.Create)
     {
         database.AddInParameter(storedProcCommand, "LinkId", DbType.Int32, friendlyLink.LinkId);
     }
     if (action != DataProviderAction.Delete)
     {
         database.AddInParameter(storedProcCommand, "ImageUrl", DbType.String, friendlyLink.ImageUrl);
         database.AddInParameter(storedProcCommand, "LinkUrl", DbType.String, friendlyLink.LinkUrl);
         database.AddInParameter(storedProcCommand, "Title", DbType.String, friendlyLink.Title);
         database.AddInParameter(storedProcCommand, "Visible", DbType.Boolean, friendlyLink.Visible);
     }
     database.ExecuteNonQuery(storedProcCommand);
     return (((int)database.GetParameterValue(storedProcCommand, "Status")) == 0);
 }
Ejemplo n.º 5
0
 public abstract bool CreateUpdateDeleteFriendlyLink(FriendlyLinksInfo friendlyLink, DataProviderAction action);
Ejemplo n.º 6
0
 public static FriendlyLinksInfo PopulateFriendlyLink(IDataRecord reader)
 {
     if (null == reader)
     {
         return null;
     }
     FriendlyLinksInfo info = new FriendlyLinksInfo();
     info.LinkId = new int?((int) reader["LinkId"]);
     info.Visible = (bool) reader["Visible"];
     info.DisplaySequence = (int) reader["DisplaySequence"];
     if (reader["ImageUrl"] != DBNull.Value)
     {
         info.ImageUrl = (string) reader["ImageUrl"];
     }
     if (reader["Title"] != DBNull.Value)
     {
         info.Title = (string) reader["Title"];
     }
     if (reader["LinkUrl"] != DBNull.Value)
     {
         info.LinkUrl = (string) reader["LinkUrl"];
     }
     return info;
 }
Ejemplo n.º 7
0
 private void UpdateFriendlyLink(FriendlyLinksInfo friendlyLink)
 {
     if (SubsiteStoreHelper.UpdateFriendlyLink(friendlyLink))
     {
         imgPic.ImageUrl = string.Empty;
         ShowMsg("修改友情链接信息成功", true);
     }
     else
     {
         ShowMsg("修改友情链接信息失败", false);
     }
 }
Ejemplo n.º 8
0
 public override FriendlyLinksInfo GetFriendlyLink(int linkId)
 {
     FriendlyLinksInfo info = new FriendlyLinksInfo();
     DbCommand sqlStringCommand = database.GetSqlStringCommand("SELECT * FROM Hishop_FriendlyLinks WHERE LinkId=@LinkId");
     database.AddInParameter(sqlStringCommand, "LinkId", DbType.Int32, linkId);
     using (IDataReader reader = database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             info = DataMapper.PopulateFriendlyLink(reader);
         }
     }
     return info;
 }