后台 :using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Drawing;
using StoredProcedure;
using JsFunction;
using WebFunction;
using Function;
public partial class Jybg_jyxm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.Cookies["User"] != null)//cookic判断是否为空
            {
                HiddenUser.Value = HttpUtility.UrlDecode(Request.Cookies["User"].Value);
                HiddenConfig.Value = FunCls.GetPost(HiddenUser.Value);
                if (HiddenConfig.Value == "")
                {
                    Response.Redirect("../error.aspx");
                }
            }
            else
            {
                Response.Redirect("../error.aspx");
            }
            if (Request.QueryString["bgbh"] != null)//cookic判断是否为空
            {
                TextBgbh.Text = Request.QueryString["bgbh"];
            }
            else if (Request.Cookies["Bgbh"] != null)
            {
                TextBgbh.Text = HttpUtility.UrlDecode(Request.Cookies["Bgbh"].Value);
            }
            GridViewBgbhBind();
            GridViewJyxmBind();
        }
        //设置JavaScript
        SetJs();
        SetBgfl();
        //设置焦点
        SetFocus("TextXm");
    }
    protected void SetJs()//设置js
    {
        JsCls.SetIsChangeJs(this.Controls);
        JsCls.SetJmInputJs(TextBz);
        JsCls.SetKeyInputJs(TextPdbz);
    }
    protected void SetText()//设置默认
    {
        //TextXm.Text = "";
        //TextBz.Text = "";
        //TextDw.Text = "";
        ButtonJyxmInsert.Enabled = false;
        ButtonJyxmDelete.Enabled = false;
        ButtonJyxmEdit.Enabled = false;
        SetFocus("TextXm");
    }
    protected void SetBgfl()//报告分类
    {
        string sql = "select distinct left(报告编号,5) as bgfl from ViewBgbh where 综合判定='/' and 报告编号 not in (select 报告编号 from ViewJyxm where 总项数>0) order by bgfl";
        DataTable dt = SpCls.GetDt(sql);
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            RadioButton rb = new RadioButton();
            rb.ID = "RadioButtonBgfl" + (i + 1).ToString();
            rb.Text = dt.Rows[i]["bgfl"].ToString();
            rb.GroupName = "bgfl";
            rb.AutoPostBack = true;
            rb.ForeColor = Color.ForestGreen;
            PanelSelect.Controls.Add(rb);
            rb.CheckedChanged += new EventHandler(RadioButton_CheckedChanged);
        }
    }
    protected void GridViewBgbh_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onclick", "RowSelected('GridViewBgbh'," + (e.Row.RowIndex + 1).ToString() + ");");
            e.Row.Attributes["style"] = "Cursor:hand";
        }
        e.Row.Cells[4].Style.Add("display", "none");
        e.Row.Cells[5].Style.Add("display", "none");
    }
    protected void GridViewBgbhBind()
    {
        string sql = "select * from ViewBgbh where 综合判定='/' and 报告编号 not in (select 报告编号 from ViewJyxm where 总项数>0) ";
        foreach (Control ctl in this.Page.FindControl("PanelSelect").Controls)
        {
            if (ctl is RadioButton)
            {
                RadioButton rb = (RadioButton)ctl;
                if (rb.Checked)
                {
                    switch (rb.ID)
                    {
                        case "RadioButtonBgfl0":
                            sql=sql+ " order by 报告编号";
                            break;
                        default:
                            sql=sql+ " and 报告编号 like '" + rb.Text + "%' order by 报告编号";
                            break;
                    }
                }
            }
        }
        //sql = "select * from ViewBgbh where 报告编号 like '%ck%'";
        WebCls.GridViewBind(GridViewBgbh, sql);
    }
    protected void GridViewJyxm_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onclick", "RowSelected('GridViewJyxm'," + (e.Row.RowIndex + 1).ToString() + ");");
            e.Row.Attributes["style"] = "Cursor:hand";
        }
        e.Row.Cells[0].Style.Add("display", "none");
        e.Row.Cells[1].Style.Add("display", "none");
        e.Row.Cells[3].Style.Add("display", "none");
        e.Row.Cells[4].Style.Add("display", "none");
        e.Row.Cells[8].Style.Add("display", "none");
        e.Row.Cells[9].Style.Add("display", "none");
        //e.Row.Cells[12].Style.Add("display", "none");
        e.Row.Cells[13].Style.Add("display", "none");
        e.Row.Cells[14].Style.Add("display", "none");
        if (e.Row.RowIndex != -1)
        {
            if (e.Row.Cells[10].Text != "/")
            {
                e.Row.Cells[10].Text = "<a href=javascript:OpenPDF('" + e.Row.Cells[10].Text + "')>" + e.Row.Cells[10].Text + "</a>";
            }
            if (e.Row.Cells[11].Text != "/")
            {
                e.Row.Cells[11].Text = "<a href=javascript:OpenPDF('" + e.Row.Cells[11].Text + "')>" + e.Row.Cells[11].Text + "</a>";
            }
            e.Row.Cells[7].Text = Server.HtmlDecode(e.Row.Cells[7].Text);
        }
    }
    protected void GridViewJyxmBind()
    {
        string sql = "select * from ViewJyxm where 报告编号='" + TextBgbh.Text + "' order by 序号";
        WebCls.GridViewBind(GridViewJyxm, sql);
    }
    protected void ButtonJyxmRead_Click(object sender, EventArgs e)
    {
        GridViewJyxmBind();
        if (GridViewJyxm.Rows.Count == 0)
        {
            ButtonYlbz.Enabled = true;
            ButtonXsbg.Enabled = true;
        }
        else
        {
            ButtonYlbz.Enabled = false;
            ButtonXsbg.Enabled = false;
        }
    }
    protected void FindBz(object sender, EventArgs e)//查找已录标准或相似报告
    {
        var button = sender as Button;
        switch (button.ClientID)//获得点击按钮的ID
        {
            case "ButtonXsbg":
                Response.Redirect("bgcx.aspx?bgbh=" + TextBgbh.Text + "&bzh=" + HiddenPdbz.Text);
                break;
            case "ButtonYlbz":
                Response.Redirect("../Bzgl/bzxz.aspx?bgbh=" + TextBgbh.Text + "&bzh=" + HiddenPdbz.Text);
                break;
        }
    }
    protected void SaveJyxmData(object sender, EventArgs e)//保存通讯录数据的修改
    {
        Int32 RowIndex = GridViewJyxm.Rows.Count;
        string[] InputData = { "", "", "", "", "", "", "", "", "", "", "", "", "" };
        InputData[0] = HiddenUser.Value;
        InputData[1] = TextBgbh.Text;
        InputData[2] = TextXh.Text;
        InputData[3] = TextXm.Text;
        InputData[4] = TextDw.Text;
        InputData[5] = TextBz.Text;
        InputData[6] = TextJybz.Text;
        InputData[7] = TextPdbz.Text;
        InputData[8] = HiddenJyxmId.Text;
        var button = sender as Button;
        switch (button.ClientID)//获得点击按钮的ID
        {
            case "ButtonJyxmAdd":
                RowIndex = RowIndex + 1;
                InputData[2] = "0";
                InputData[8] = "0";
                break;
            case "ButtonJyxmDelete":
                InputData[0] = "删除";
                break;
            case "ButtonJyxmEdit":
                break;
            case "ButtonJyxmInsert":
                InputData[8] = "0";
                break;
        }
        SpCls.SaveJyxmData(InputData);
        GridViewJyxmBind();//保存修改日期及人员
    }
    protected void GridViewBgbh_PageIndexChanged(object sender, EventArgs e)
    {
        GridViewBgbhBind();
    }
    protected void GridViewBgbh_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridViewBgbh.PageIndex = e.NewPageIndex;
    }
    protected void RadioButton_CheckedChanged(object sender, EventArgs e)//选择类别
    {
        GridViewBgbhBind();
    }
}