protected void btnAdd_Click(object sender, EventArgs e)
        {
            var Finfo = new FileInfo(FileUploadMAster.PostedFile.FileName);

            try
            {
                if (FileUploadMAster.HasFile)
                {
                    if (Finfo.Extension.ToLower() == ".jpg" || Finfo.Extension.ToLower() == ".png" || Finfo.Extension.ToLower() == ".gif" || Finfo.Extension.ToLower() == ".jpeg")
                    {
                        string Name = GetNewName();
                        string path = Server.MapPath("/images/portfolio/" + Name + Path.GetExtension(FileUploadMAster.PostedFile.FileName));
                        FileUploadMAster.SaveAs(path);
                        BL.ins_tblMasterPic(txtPName.Text, TxtName_En.Text, (@"images\portfolio\" + Name + Path.GetExtension(FileUploadMAster.PostedFile.FileName)), int.Parse(ddlType.SelectedItem.Value), TextArea1.InnerText);
                        DataTable dt = new DataTable();
                        dt = BL.Get_tblMasterPic();
                        this.ViewState.Clear();
                        Response.Redirect("Manger_SubPic.aspx?ID=" + dt.Rows[0][0].ToString(), false);
                    }

                    else
                    {
                        Label5.Visible = true;
                    }
                }
            }
            catch { Response.Redirect("Error.aspx", false); }
        }
예제 #2
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (!FileUploadMAster.HasFile)
                {
                    BL.Update_tblMasterPic(TxtName.Text, TxtName_En.Text, "", int.Parse(ViewState["PICID"].ToString()), false, TextArea1.InnerText, DropDownList1.SelectedIndex);
                }
                else
                {
                    var Finfo = new FileInfo(FileUploadMAster.PostedFile.FileName);

                    if (Finfo.Extension.ToLower() == ".jpg" || Finfo.Extension.ToLower() == ".png" || Finfo.Extension.ToLower() == ".gif" || Finfo.Extension.ToLower() == ".jpeg")
                    {
                        string Name = GetNewName();
                        string path = Server.MapPath("~/images/portfolio/" + Name + Path.GetExtension(FileUploadMAster.PostedFile.FileName));
                        FileUploadMAster.SaveAs(path);
                        try
                        {
                            FileInfo fi = new FileInfo(Server.MapPath((GridView1.SelectedRow.Cells[2].Text.ToString())));
                            fi.Delete();
                        }
                        catch { return; }


                        BL.Update_tblMasterPic(TxtName.Text, TxtName_En.Text, (@"images\portfolio\" + Name + Path.GetExtension(FileUploadMAster.PostedFile.FileName)), int.Parse(ViewState["PICID"].ToString()), true, TextArea1.InnerText, DropDownList1.SelectedIndex);
                    }
                    else
                    {
                        Label13.Visible = true;
                    }
                }
                Response.Redirect("UpDateProjects.aspx", false);
            }
            catch { Response.Redirect("Error.aspx", false); }
            finally{
                //this.ViewState.Clear();
            }
        }