Exemplo n.º 1
0
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == "QuickUpdate")
        {
            string CommentID, Priority = "", IsApproved, IsAvailable;
            var    oComment = new Comment();

            foreach (GridDataItem item in RadGrid1.Items)
            {
                CommentID   = item.GetDataKeyValue("CommentID").ToString();
                IsApproved  = ((CheckBox)item.FindControl("chkIsApproved")).Checked.ToString();
                IsAvailable = ((CheckBox)item.FindControl("chkIsAvailable")).Checked.ToString();

                oComment.CommentQuickUpdate(
                    CommentID,
                    IsApproved,
                    IsAvailable,
                    Priority
                    );
            }
        }
    }
Exemplo n.º 2
0
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == "alpha" || e.CommandName == "NoFilter")
        {
            String value = null;
            switch (e.CommandName)
            {
            case ("alpha"):
            {
                value = string.Format("{0}%", e.CommandArgument);
                break;
            }

            case ("NoFilter"):
            {
                value = "%";
                break;
            }
            }
            ObjectDataSource1.SelectParameters["Title"].DefaultValue = value;
            ObjectDataSource1.DataBind();
            RadGrid1.Rebind();
        }
        else if (e.CommandName == "QuickUpdate")
        {
            string CommentID, Priority, IsAvailable, IsApproved;
            var    oComment = new Comment();

            foreach (GridDataItem item in RadGrid1.Items)
            {
                CommentID   = item.GetDataKeyValue("CommentID").ToString();
                Priority    = ((RadNumericTextBox)item.FindControl("txtPriority")).Text.Trim();
                IsApproved  = ((CheckBox)item.FindControl("chkIsApproved")).Checked.ToString();
                IsAvailable = ((CheckBox)item.FindControl("chkIsAvailable")).Checked.ToString();

                oComment.CommentQuickUpdate(
                    CommentID,
                    IsApproved,
                    IsAvailable,
                    Priority
                    );
            }
        }
        //else if (e.CommandName == "DeleteSelected")
        //{
        //    string OldImageName;
        //    var oComment = new Comment();

        //    foreach (GridDataItem item in RadGrid1.SelectedItems)
        //    {
        //        OldImageName = ((HiddenField)item.FindControl("hdnImageName")).Value;
        //        DeleteImage(OldImageName);
        //    }
        //}
        else if (e.CommandName == "PerformInsert" || e.CommandName == "Update")
        {
            var command       = e.CommandName;
            var row           = command == "PerformInsert" ? (GridEditFormInsertItem)e.Item : (GridEditFormItem)e.Item;
            var FileImageName = (RadUpload)row.FindControl("FileImageName");
            var oComment      = new Comment();

            string strCommentID = ((HiddenField)row.FindControl("hdnCommentID")).Value;
            //string strOldImageName = ((HiddenField)row.FindControl("hdnOldImageName")).Value;
            //string strImageName = FileImageName.UploadedFiles.Count > 0 ? FileImageName.UploadedFiles[0].GetName() : "";
            string strPriority = "";// ((RadNumericTextBox)row.FindControl("txtPriority")).Text.Trim();
            //string strTitle = ((Label)row.FindControl("lblTitle")).Text.Trim();
            string strTitle    = ((TextBox)row.FindControl("txtTitle")).Text.Trim();
            string strTitleEn  = ((TextBox)row.FindControl("txtTitleEn")).Text.Trim();
            string strUserName = ((TextBox)row.FindControl("txtUserName")).Text.Trim();
            string strPhone    = ((TextBox)row.FindControl("txtPhone")).Text.Trim();
            string strEmail    = ((TextBox)row.FindControl("txtEmail")).Text.Trim();
            string strConvertedCommentTitle = Common.ConvertTitle(strTitle);
            string strContent     = ((TextBox)row.FindControl("txtContent")).Text.Trim();
            string strContentEn   = ((TextBox)row.FindControl("txtContentEn")).Text.Trim();
            string strAnswer      = HttpUtility.HtmlDecode(FCKEditorFix.Fix(((RadEditor)row.FindControl("txtAnswer")).Content.Trim()));
            string strAnswerEn    = HttpUtility.HtmlDecode(FCKEditorFix.Fix(((RadEditor)row.FindControl("txtAnswerEn")).Content.Trim()));
            string strIsAvailable = ((CheckBox)row.FindControl("chkIsAvailable")).Checked.ToString();
            string strIsApproved  = ((CheckBox)row.FindControl("chkIsApproved")).Checked.ToString();


            if (e.CommandName == "PerformInsert")
            {
                oComment.CommentInsert(
                    strUserName,
                    "",
                    strTitle,
                    strTitleEn,
                    strPhone,
                    strEmail,
                    strContent,
                    strContentEn,
                    strAnswer,
                    strAnswerEn,
                    strPriority,
                    strIsApproved,
                    strIsAvailable
                    );

                //string strFullPath = "~/res/comment/" + strImageName;
                //if (!string.IsNullOrEmpty(strImageName))
                //{
                //    FileImageName.UploadedFiles[0].SaveAs(Server.MapPath(strFullPath));
                //    ResizeCropImage.ResizeByCondition(strFullPath, 450, 306);
                //    string bgColor = "#ffffff";
                //    ResizeCropImage.CreateThumbNailWithBackGroundColor("~/res/comment/", "~/res/comment/thumbs/", strImageName, 156, 156, bgColor);
                //}
                RadGrid1.Rebind();
            }
            else
            {
                var dsUpdateParam = ObjectDataSource1.UpdateParameters;
                //var strOldImagePath = Server.MapPath("~/res/comment/" + strOldImageName);
                //var strOldThumbImagePath = Server.MapPath("~/res/comment/thumbs/" + strOldImageName);

                dsUpdateParam["UserName"].DefaultValue  = strUserName;
                dsUpdateParam["Title"].DefaultValue     = strTitle;
                dsUpdateParam["TitleEn"].DefaultValue   = strTitleEn;
                dsUpdateParam["Content"].DefaultValue   = strContent;
                dsUpdateParam["ContentEn"].DefaultValue = strContentEn;
                dsUpdateParam["Answer"].DefaultValue    = strAnswer;
                dsUpdateParam["AnswerEn"].DefaultValue  = strAnswerEn;
                //dsUpdateParam["ConvertedCommentTitle"].DefaultValue = strConvertedCommentTitle;
                //dsUpdateParam["ImageName"].DefaultValue = strImageName;
                dsUpdateParam["IsApproved"].DefaultValue  = strIsApproved;
                dsUpdateParam["IsAvailable"].DefaultValue = strIsAvailable;

                //if (!string.IsNullOrEmpty(strImageName))
                //{
                //    if (File.Exists(strOldImagePath))
                //        File.Delete(strOldImagePath);
                //    if (File.Exists(strOldThumbImagePath))
                //        File.Delete(strOldThumbImagePath);

                //    strImageName = (string.IsNullOrEmpty(strConvertedCommentTitle) ? "" : strConvertedCommentTitle + "-") + strCommentID + strImageName.Substring(strImageName.LastIndexOf('.'));

                //    string strFullPath = "~/res/comment/" + strImageName;

                //    FileImageName.UploadedFiles[0].SaveAs(Server.MapPath(strFullPath));
                //    ResizeCropImage.ResizeByCondition(strFullPath, 450, 306);
                //    string bgColor = "#ffffff";
                //    ResizeCropImage.CreateThumbNailWithBackGroundColor("~/res/comment/", "~/res/comment/thumbs/", strImageName, 156, 156, bgColor);
                //}
            }
        }
        //if (e.CommandName == "DeleteImage")
        //{
        //    var oComment = new Comment();
        //    var lnkDeleteImage = (LinkButton)e.CommandSource;
        //    var s = lnkDeleteImage.Attributes["rel"].ToString().Split('#');
        //    var strCommentID = s[0];
        //    var strImageName = s[1];

        //    oComment.CommentImageDelete(strCommentID);
        //    DeleteImage(strImageName);
        //    RadGrid1.Rebind();
        //}
    }