コード例 #1
0
        protected void ButtonAddStoreCustomAttachment_Click(object sender, EventArgs e)
        {
            LabelError.Text = "";
            bool hasError = false;

            PanelError.Visible = false;

            if (TextBoxDescription.Text.Length == 0)
            {
                LabelError.Text   += "Attachment Description is required.\n";
                PanelError.Visible = true;
                hasError           = true;
            }

            if (!FileStoreCustomAttachment.HasFile)
            {
                LabelError.Text   += "Attachment is required.\n";
                PanelError.Visible = true;
                hasError           = true;
            }

            if (hasError == false)
            {
                try
                {
                    StoreCustomAttachment storeCustomAttachment = new StoreCustomAttachment();
                    storeCustomAttachment.Description   = TextBoxDescription.Text;
                    storeCustomAttachment.Attachment    = UploadAttachment();
                    storeCustomAttachment.StoreCustomId = this.storeCustomId;
                    storeCustomAttachment.ModifiedUser  = this.Master.LoggedOnAccount;

                    storeCustomAttachment.Save();
                    BindStoreCustomAttachmentList();
                    TextBoxDescription.Text = "";
                }
                catch (System.Data.SqlClient.SqlException sqlEx)
                {
                    LabelError.Text = "";
                    for (int i = 0; i < sqlEx.Errors.Count; i++)
                    {
                        LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                    }
                    PanelError.Visible = true;
                }
            }
        }
コード例 #2
0
        protected void GridViewStoreCustomAttachment_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                switch (e.CommandName.ToLower())
                {
                case "removeclaimattachment":
                {
                    StoreCustomAttachment.DeleteStoreCustomAttachmentByStoreCustomAttachmentId(Convert.ToInt32(e.CommandArgument));
                    BindStoreCustomAttachmentList();
                    break;
                }

                case "viewclaimattachment":
                {
                    StoreCustomAttachment storeCustomAttachment = StoreCustomAttachment.GetStoreCustomAttachmentByStoreCustomAttachmentId(Convert.ToInt32(e.CommandArgument));

                    Response.Clear();
                    Response.ContentType = "image/jpg";
                    Response.AppendHeader("Content-Disposition", "attachment; filename=StoreCustomAttachment.jpg");
                    Response.TransmitFile(storeCustomAttachment.Attachment);
                    Response.End();

                    break;
                }
                }
            }
            catch (System.Data.SqlClient.SqlException sqlEx)
            {
                LabelError.Text = "";
                for (int i = 0; i < sqlEx.Errors.Count; i++)
                {
                    LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                }
                PanelError.Visible = true;
            }
        }
コード例 #3
0
 private void BindStoreCustomAttachmentList()
 {
     GridViewStoreCustomAttachment.DataSource = StoreCustomAttachment.GetStoreCustomAttachmentListByStoreCustomId(this.storeCustomId, this.companyId);
     GridViewStoreCustomAttachment.DataBind();
 }