Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                if (!(Session["UserRole"].ToString().Contains("模板管理")))
                {
                    Response.Redirect("~/Default.aspx");
                }
                else
                {
                    Label_Grid1_State.Text = "默认数据源";
                    GridView1.DataSource   = upload.SList_TemplateUpload();
                    GridView1.DataBind();
                    UpdatePanel_Temp.Update();
                }
            }
            catch (Exception)
            {
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('可能您没有权限操作和查看本页面,请退出选择其他账号登陆,或联系管理员!')", true);
                Response.Redirect("~/Default.aspx");
            }

            Label_Grid1_State.Text = "默认数据源";
            GridView1.DataSource   = upload.SList_TemplateUpload();
            GridView1.DataBind();
            UpdatePanel_Temp.Update();
        }
    }
Пример #2
0
 protected void Button_CloseS_Click(object sender, EventArgs e)
 {
     GridView1.SelectedIndex = -1;
     Panel_PT.Visible        = false;
     UpdatePanel_PT.Update();
     Panel_Product.Visible = false;
     UpdatePanel_Product.Update();
     UpdatePanel_Temp.Update();
 }
Пример #3
0
    protected void Button_SearchReset_Click(object sender, EventArgs e)
    {
        Label_Grid1_State.Text = "默认数据源";
        Txt_search.Text        = "";
        GridView1.DataSource   = upload.SList_TemplateUpload();
        GridView1.DataBind();
        UpdatePanel_Temp.Update();
        UpdatePanel_Search.Update();

        GridView1.SelectedIndex = -1;

        Panel_PT.Visible = false;
        UpdatePanel_PT.Update();
        Panel_Product.Visible = false;
        UpdatePanel_Product.Update();
    }
Пример #4
0
 protected void Btn_Search_Click(object sender, EventArgs e)
 {
     Label_Grid1_State.Text = "模糊搜索数据源";
     Label_Search.Text      = Txt_search.Text.Trim();
     if (Txt_search.Text != "")
     {
         GridView1.DataSource = upload.S_TemplateUpload(Txt_search.Text.Trim());
         GridView1.DataBind();
         UpdatePanel_Temp.Update();
     }
     else
     {
         Label_Grid1_State.Text = "默认数据源";
         GridView1.DataSource   = upload.SList_TemplateUpload();
         GridView1.DataBind();
         UpdatePanel_Temp.Update();
     }
 }
Пример #5
0
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        Label_Grid1_State.Text = "默认数据源";
        Boolean   fileOk = false;
        DataSet   ds     = upload.S_TemplatUpload_Name(txt_Tmp.Text);
        DataTable dt     = ds.Tables[0];
        DataView  dv     = ds.Tables[0].DefaultView;

        if (dt.Rows.Count != 0)
        {
            ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), "alert", "alert('系统中已有该模板名称,不能重名!')", true);
            return;
        }
        if (txt_Tmp.Text != "")
        {
            if (this.ImgFileUpload.HasFile)
            {
                //取得文件的扩展名,并转换成小写
                string fileExtension = Path.GetExtension(ImgFileUpload.FileName).ToLower();
                //验证上传文件是否图片格式
                fileOk = IsImage(fileExtension);
                if (fileOk)
                {
                    //对上传文件的大小进行检测,限定文件最大不超过8M
                    if (ImgFileUpload.PostedFile.ContentLength < 8192000)
                    {
                        string filepath = "/TemplateUpload/";
                        if (Directory.Exists(Server.MapPath(filepath)) == false)//如果不存在就创建file文件夹
                        {
                            Directory.CreateDirectory(Server.MapPath(filepath));
                        }
                        string             virpath = filepath + ImgFileUpload.FileName;
                        string             mappath = Server.MapPath(virpath);
                        System.IO.FileInfo fi      = new System.IO.FileInfo(mappath);
                        if (fi.Exists)
                        {
                            ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), "alert", "alert('存在同名文件,请修改后上传!')", true);
                            return;
                        }
                        ImgFileUpload.SaveAs(mappath);
                        tempInfo.TmpUpload_Name   = txt_Tmp.Text.Trim();
                        tempInfo.TmpUpload_ImgUrl = virpath;
                        tempInfo.TmpUpload_Person = Session["UserName"].ToString();
                        tempInfo.TmpUpload_Time   = DateTime.Now;
                        upload.I_TemplatUpload(tempInfo);

                        GridView1.DataSource = upload.SList_TemplateUpload();
                        GridView1.DataBind();
                        txt_Tmp.Text = "";
                        UpdatePanel_Temp.Update();
                        ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('模板新增成功!')", true);
                        PanelAdd.Visible = false;
                        UpdatePanel1.Update();
                    }

                    else
                    {
                        ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), "alert", "alert('文件大小超出8M!请重新选择!')", true);
                        return;
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), "alert", "alert('上传文件类型有误!')", true);
                    return;
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), "alert", "alert('没有上传文件!')", true);
                return;
            }
        }

        else
        {
            ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "alert", "alert('模板名称不能为空!')", true);
            return;
        }
    }
Пример #6
0
    protected void Btn_SubmitEdit_Click(object sender, EventArgs e)
    {
        Label_Grid1_State.Text = "默认数据源";
        Boolean fileOk = false;

        if (TextBox_Edit.Text != "")
        {
            if (this.FileUploadEdit.HasFile)
            {
                //取得文件的扩展名,并转换成小写
                string fileExtension = Path.GetExtension(FileUploadEdit.FileName).ToLower();
                //验证上传文件是否图片格式
                fileOk = IsImage(fileExtension);
                if (fileOk)
                {
                    //对上传文件的大小进行检测,限定文件最大不超过8M
                    if (FileUploadEdit.PostedFile.ContentLength < 8192000)
                    {
                        string name    = Label_ImgUrl.Text;
                        string mapname = Server.MapPath(name);
                        System.IO.File.Delete(mapname);
                        string filepath = "/TemplateUpload/";
                        if (Directory.Exists(Server.MapPath(filepath)) == false)//如果不存在就创建file文件夹
                        {
                            Directory.CreateDirectory(Server.MapPath(filepath));
                        }
                        string             virpath = filepath + FileUploadEdit.FileName;
                        string             mappath = Server.MapPath(virpath);
                        System.IO.FileInfo fi      = new System.IO.FileInfo(mappath);
                        if (fi.Exists)
                        {
                            ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), "alert", "alert('存在同名文件,请修改后上传!')", true);
                            return;
                        }
                        FileUploadEdit.SaveAs(mappath);
                        tempInfo.TmpUpload_ID     = new Guid(Label_EditTmpID.Text.ToString());
                        tempInfo.TmpUpload_Name   = TextBox_Edit.Text.Trim();
                        tempInfo.TmpUpload_ImgUrl = virpath;
                        tempInfo.TmpUpload_Person = Session["UserName"].ToString();
                        tempInfo.TmpUpload_Time   = DateTime.Now;
                        upload.U_TemplatUpload(tempInfo);
                        GridView1.DataSource = upload.SList_TemplateUpload();
                        GridView1.DataBind();
                        TextBox_Edit.Text = "";
                        UpdatePanel_Temp.Update();
                        ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), "alert", "alert('模板上传且修改成功!')", true);
                        PanelEdit.Visible = false;
                        UpdatePanel1.Update();
                        PanelShowImage.Visible = false;
                        UpdatePanel_ShowImage.Update();
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), "alert", "alert('文件大小超出8M!请重新选择!')", true);
                        return;
                    }
                }

                else
                {
                    ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), "alert", "alert('上传文件类型有误!')", true);
                    return;
                }
            }
            else
            {
                tempInfo.TmpUpload_ID     = new Guid(Label_EditTmpID.Text.ToString());
                tempInfo.TmpUpload_Name   = TextBox_Edit.Text.Trim();
                tempInfo.TmpUpload_ImgUrl = Label_ImgUrl.Text;
                tempInfo.TmpUpload_Person = Session["UserName"].ToString();
                tempInfo.TmpUpload_Time   = DateTime.Now;
                upload.U_TemplatUpload(tempInfo);

                GridView1.DataSource = upload.SList_TemplateUpload();
                GridView1.DataBind();
                TextBox_Edit.Text = "";
                UpdatePanel_Temp.Update();
                ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(Page), "alert", "alert('模板修改成功!')", true);
                PanelEdit.Visible = false;
                UpdatePanel1.Update();
                PanelShowImage.Visible = false;
                UpdatePanel_ShowImage.Update();
            }
        }
        else
        {
            ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "alert", "alert('模板名称不能为空!')", true);
            return;
        }
    }
Пример #7
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Delete1")
        {
            GridViewRow row = ((LinkButton)e.CommandSource).Parent.Parent as GridViewRow;
            GridView1.SelectedIndex = row.RowIndex;
            GridView1.SelectedIndex = -1;
            string id      = GridView1.DataKeys[row.RowIndex].Values["TmpUpload_ID"].ToString();
            Guid   guid_id = new Guid(id);
            string imgUrl  = GridView1.DataKeys[row.RowIndex].Values["TmpUpload_ImgUrl"].ToString();
            int    i       = upload.D_TemplatUpload(guid_id);
            if (i > 0)
            {
                System.IO.File.Delete(Server.MapPath(imgUrl));
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('模板删除成功!')", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('模板删除失败!')", true);
            }
            GridView1.DataSource = upload.SList_TemplateUpload();
            GridView1.DataBind();
            UpdatePanel_Temp.Update();
            PanelAdd.Visible       = false;
            PanelEdit.Visible      = false;
            PanelShowImage.Visible = false;
            UpdatePanel_ShowImage.Update();
            UpdatePanel1.Update();
            //无关信息隐藏
            //Panel10.Visible = false;
            //UpdatePanel_AddTmp.Update();
        }
        if (e.CommandName == "CheckProType")
        {
            Panel_PT.Visible        = true;
            GridView2.SelectedIndex = -1;

            GridViewRow row = ((LinkButton)e.CommandSource).Parent.Parent as GridViewRow;
            GridView1.SelectedIndex = row.RowIndex;

            string id = GridView1.DataKeys[row.RowIndex].Values["TmpUpload_ID"].ToString();
            Label_TmpID.Text = id;
            databind();
            //无关信息隐藏
            // Panel10.Visible = false;
            // UpdatePanel_AddTmp.Update();
            Panel_Product.Visible = false;
            UpdatePanel_Product.Update();
        }
        if (e.CommandName == "EditTemplate")
        {
            GridViewRow row = ((LinkButton)e.CommandSource).Parent.Parent as GridViewRow;
            GridView1.SelectedIndex = row.RowIndex;

            TextBox_Edit.Text    = GridView1.DataKeys[row.RowIndex].Values["TmpUpload_Name"].ToString();
            Label_ImgUrl.Text    = GridView1.DataKeys[row.RowIndex].Values["TmpUpload_ImgUrl"].ToString();
            Label_EditTmpID.Text = GridView1.DataKeys[row.RowIndex].Values["TmpUpload_ID"].ToString();
            PanelEdit.Visible    = true;
            UpdatePanel1.Update();
        }
        if (e.CommandName == "CheckImage")
        {
            GridViewRow row = ((LinkButton)e.CommandSource).Parent.Parent as GridViewRow;
            GridView1.SelectedIndex = row.RowIndex;

            Label_ImgName.Text     = GridView1.DataKeys[row.RowIndex].Values["TmpUpload_Name"].ToString();
            Label_ShowImgUrl.Text  = GridView1.DataKeys[row.RowIndex].Values["TmpUpload_ImgUrl"].ToString();
            TempImage.ImageUrl     = Label_ShowImgUrl.Text.ToString();
            PanelShowImage.Visible = true;
            UpdatePanel_ShowImage.Update();
        }
    }