protected void Button1_Click(object sender, EventArgs e)
    {
        //if (ddlCompany.SelectedValue == "")
        //{
        //    Label1.Text = ("请选择企业!");
        //    return;
        //}

        if (RName.Text.Length == 0)
        {
            Label1.Text = ("成果姓名不允许为空!");
            RName.Focus();
            return;
        }
        try
        {
            Convert.ToSingle(ZiJin.Text);
        }
        catch
        {
            Label1.Text = ("资金,必须为数字!");
            ZiJin.Focus();
            return;
        }
        if (LeiBie.SelectedValue == "0")
        {
            Label1.Text = ("成果类别必须选择");
            LeiBie.Focus();
            return;
        }
        //try
        //{
        //    Convert.ToSingle(ZiJin.Text);
        //}
        //catch
        //{
        //    Label1.Text = ("设备投资,必须为数字!");
        //    return;
        //}
        //try
        //{
        //    Convert.ToSingle(tblirui.Text);
        //}
        //catch
        //{
        //    Label1.Text = ("新增利润,必须为数字!");
        //    return;
        //}
        //try
        //{
        //    Convert.ToSingle(tbjieye.Text);
        //}
        //catch
        //{
        //    Label1.Text = ("节省成本,必须为数字!");
        //    return;
        //}
        string classid = "0";
        string cbtext1 = "";
        //for (int i = 0; i < YingYongLingYu.Items.Count; i++)
        //{
        //    if (YingYongLingYu.Items[i].Selected == true)
        //    {
        //        //这个打勾的
        //        cbtext1 += YingYongLingYu.Items[i].Value + ",";
        //        if (classid == "0")
        //        {
        //            classid = YingYongLingYu.Items[i].Value;
        //        }
        //    }
        //    else
        //    {
        //        //这是没打的
        //    }
        //}
        string cbtexthy = "";

        for (int i = 0; i < hangyec.Items.Count; i++)
        {
            if (hangyec.Items[i].Selected == true)
            {
                //这个打勾的
                cbtexthy += hangyec.Items[i].Value + ",";
                //if (classid == "0")
                //{
                //    classid = hangye.Items[i].Value;
                //}
            }
            else
            {
                //这是没打的
            }
        }
        cid = Request.QueryString["id"].ToString();
        this.content1.Text = Request.Form["content"];
        string XingZhiBiao = "";

        switch (LeiBie.SelectedValue)
        {
        case "211":
            XingZhiBiao = "A";
            break;

        case "210":
            XingZhiBiao = "B";
            break;

        case "214":
            XingZhiBiao = "D";
            break;

        case "215":
            XingZhiBiao = "E";
            break;

        case "216":
            XingZhiBiao = "F";
            break;

        case "217":
            XingZhiBiao = "G";
            break;

        case "1311":
            XingZhiBiao = "C";
            break;

        case "1312":
            XingZhiBiao = "A";
            break;

        case "1313":
            XingZhiBiao = "E";
            break;

        case "1314":
            XingZhiBiao = "F";
            break;

        default:
            XingZhiBiao = "C";
            break;
        }
        XingZhiBiao = XingZhiBiao + "";
        string sql = "";
        {
            sql = @"update  [dbo].[Results]
            set [RName]='" + Common.strFilter(RName.Text) + "'           ,[JianJie]='" + Common.strFilter(JianJie.Text)
                  + "',[JieShao] ='" + Common.strFilter(content1.Text) + "'                           ,[JieDuan]='" + Common.strFilter(JieDuan.Text)
                  + "'           ,[LeiBie]='" + Common.strFilter(LeiBie.SelectedValue) + "'          ,[DiZhi]='" + Common.strFilter(DiZhi.SelectedValue) + "'                 ,[ZiJin]='" + Common.strFilter(ZiJin.Text)

                  + "' ,[ShuiPing]='" + Common.strFilter(ShuiPing.SelectedValue) + "'           ,[MiJi]='" + Common.strFilter(MiJi.SelectedValue) + "'           ,[ShuXing]='" + Common.strFilter(ShuXing.SelectedValue) + "'          ,[ChuangXinXingShi]='" + Common.strFilter(ChuangXinXingShi.SelectedValue)
                  + "'           ,[YingYongQingKuang]='" + Common.strFilter(YingYongQingKuang.SelectedValue) + "'           ,[NoYingYYin]='" + Common.strFilter(NoYingYYin.SelectedValue) + "'           ,[ChiYouRenID]='" + Common.strFilter(ChiYouRenID.SelectedValue) + "'           ,[KeHuJingLi]='" + Session["userid"]
                  + "'           ,[JiaoYiState]='" + Common.strFilter(JiaoYiState.SelectedValue) + "'           , RNo='" + XingZhiBiao + cid + "'          ,hangye='" + Common.strFilter(cbtexthy) + "',webtype= '" + Common.strFilter(webtype.SelectedValue) + "'         ,ChiYouRenType='" + (RadioButtonList1.SelectedIndex) + "'"
                  + ",indexlocation='" + (indexlocation.SelectedValue) + "',hezuo='" + ((hezuo.Checked) ? "1" : "0") + "',zhanshi='" + ((zhanshi.Checked) ? "1" : "0") + "' ,[biaoqian]='" + biaoqian.Text + "' ,[zhongyao]='" + Common.strFilter(zhongyao.SelectedItem.Text) + "' ,[wanzheng]='" + Common.strFilter(wanzheng.SelectedItem.Text) + "' ,qianjisltl= '" + Common.strFilter(qianjisltl.SelectedValue) + "' where id=" + cid;
            //  ,[YingYongLingYu]='" + cbtext1 + "'    去掉应用领域
        }
        int count = DBqiye.getRowsCount(sql);

        sql = "";
        if (count > 0)
        {
            Label1.Text = "保存成功" + sql;
        }
        else
        {
            Label1.Text = "保存失败" + sql;
        }
        //[userid]='" + yewu.SelectedValue + "',
        //只能超级管理员可以修改业务员

        //合作方式
        {
            sql = @"update  [dbo].[Results] set [hezuotype1]='" + Common.strFilter(((hezuotype1.Checked) ? "1" : "0")) + "',[hezuotype2]='" + Common.strFilter(((hezuotype2.Checked) ? "1" : "0")) + "',[hezuotype3]='" + Common.strFilter(((hezuotype3.Checked) ? "1" : "0")) + "',[hezuotype4]='" + Common.strFilter(((hezuotype4.Checked) ? "1" : "0"))
                  + "',[hezuocost1]='" + Common.strFilter(hezuocost1.Text) + "',[hezuocost2]='" + Common.strFilter(hezuocost2.Text) + "',[hezuocost3]='" + Common.strFilter((hezuocost3.Text)) + "' where id=" + cid;
        }
        count = DBqiye.getRowsCount(sql);

        if (Session["userid"].ToString() == "41" || Session["userid"].ToString() == "13" || Session["userid"].ToString() == "47")
        {
            sql = "update  [dbo].[Results] set [userid]='" + yewu.SelectedValue + "' where id=" + cid;
            DBqiye.getRowsCount(sql);
        }
    }
    //private void company()
    //{
    //    string sql = "SELECT  [ID] ,[Name] FROM  [dbo].[Company] where 1=1 ";
    //    if (Session["title"].ToString() != "3")
    //    {
    //        sql += " and UserID='" + Session["userid"] + "' ";
    //    }
    //    DataTable dt = DBqiye.getDataTable(sql);
    //    ChiYouRenID.DataSource = dt;
    //    ChiYouRenID.DataTextField = "Name";
    //    ChiYouRenID.DataValueField = "ID";
    //    ChiYouRenID.DataBind();
    //    //ddlCompany.Items.Insert(0, new ListItem("==请选择==", ""));
    //    //ddlCompany.SelectedValue = "";
    //}

    protected void Button1_Click(object sender, EventArgs e)
    {
        //if (ddlCompany.SelectedValue == "")
        //{
        //    Label1.Text = ("请选择企业!");
        //    return;
        //}

        if (RName.Text.Length == 0)
        {
            Label1.Text = ("成果姓名不允许为空!");
            RName.Focus();
            return;
        }
        try
        {
            Convert.ToSingle(ZiJin.Text);
        }
        catch
        {
            Label1.Text = ("资金,必须为数字!");
            ZiJin.Focus();
            return;
        }
        //try
        //{
        //    Convert.ToSingle(ZiJin.Text);
        //}
        //catch
        //{
        //    Label1.Text = ("设备投资,必须为数字!");
        //    return;
        //}
        //try
        //{
        //    Convert.ToSingle(tblirui.Text);
        //}
        //catch
        //{
        //    Label1.Text = ("新增利润,必须为数字!");
        //    return;
        //}
        //try
        //{
        //    Convert.ToSingle(tbjieye.Text);
        //}
        //catch
        //{
        //    Label1.Text = ("节省成本,必须为数字!");
        //    return;
        //}

        if (JieDuan.SelectedValue == "0")
        {
            Label1.Text = ("成果阶段必须选择");
            JieDuan.Focus();
            return;
        }

        if (LeiBie.SelectedValue == "0")
        {
            Label1.Text = ("成果类别必须选择");
            LeiBie.Focus();
            return;
        }
        if (webtype.SelectedValue == "0")
        {
            Label1.Text = ("强基分类必须选择");
            webtype.Focus();
            return;
        }
        if (qianjisltl.SelectedValue == "0")
        {
            Label1.Text = ("工业强基十六条龙计划必须选择");
            qianjisltl.Focus();
            return;
        }
        //if (ShuiPing.SelectedValue == "0")
        //{
        //    Label1.Text = ("成果水平必须选择");
        //    return;
        //}
        if (YingYongQingKuang.SelectedValue == "205" && NoYingYYin.SelectedValue == "0")
        {
            Label1.Text = ("未应用时,必须选择未应用原因");
            return;
        }
        string classid = "0";
        string cbtext1 = "";
        //for (int i = 0; i < YingYongLingYu.Items.Count; i++)
        //{
        //    if (YingYongLingYu.Items[i].Selected == true)
        //    {
        //        //这个打勾的
        //        cbtext1 += YingYongLingYu.Items[i].Value + ",";
        //        if (classid == "0")
        //        {
        //            classid = YingYongLingYu.Items[i].Value;
        //        }
        //    }
        //    else
        //    {
        //        //这是没打的
        //    }
        //}
        string cbtexthy = "";

        for (int i = 0; i < hangyec.Items.Count; i++)
        {
            if (hangyec.Items[i].Selected == true)
            {
                //这个打勾的
                cbtexthy += hangyec.Items[i].Value + ",";
                //if (classid == "0")
                //{
                //    classid = hangye.Items[i].Value;
                //}
            }
            else
            {
                //这是没打的
            }
        }
        string XingZhiBiao = "";

        switch (LeiBie.SelectedValue)
        {
        case "211":
            XingZhiBiao = "A";
            break;

        case "210":
            XingZhiBiao = "B";
            break;

        case "214":
            XingZhiBiao = "D";
            break;

        case "215":
            XingZhiBiao = "E";
            break;

        case "216":
            XingZhiBiao = "F";
            break;

        case "217":
            XingZhiBiao = "G";
            break;

        case "1311":
            XingZhiBiao = "C";
            break;

        case "1312":
            XingZhiBiao = "A";
            break;

        case "1313":
            XingZhiBiao = "E";
            break;

        case "1314":
            XingZhiBiao = "F";
            break;

        default:
            XingZhiBiao = "C";
            break;
        }
        this.content1.Text = Request.Form["content"];

        string sql = "";
        {
            sql = @"INSERT INTO [dbo].[Results]
           ([RName]           ,[JianJie]
           ,[JieShao]       ,[JieDuan]
           ,[LeiBie]           ,[DiZhi]                     ,[ZiJin]
          
           ,[ShuiPing]           ,[MiJi]           ,[ShuXing]           ,[ChuangXinXingShi]
           ,[YingYongQingKuang]           ,[NoYingYYin]                  ,[KeHuJingLi]
           ,[JiaoYiState]           ,[Update]           ,[userid]           ,[state],hangye,webtype,indexlocation,biaoqian,zhongyao,wanzheng,qianjisltl)
               VALUES ('" + Common.strFilter(RName.Text) + "','" + Common.strFilter(JianJie.Text) + "','" +
                  Common.strFilter(content1.Text) + "','" + Common.strFilter(JieDuan.Text) + "','" +
                  Common.strFilter(LeiBie.SelectedValue) + "','" + Common.strFilter(DiZhi.SelectedValue) + "','" + Common.strFilter(ZiJin.Text) + "','" +
                  //Common.strFilter(((ZhuanLi.Checked) ? "1" : "0")) + "','" + Common.strFilter(((ChaXin.Checked) ? "1" : "0")) + "','" + Common.strFilter(((JianCe.Checked) ? "1" : "0")) + "','" + ((ShiYongBao.Checked) ? "1" : "0") + "','" +
                  Common.strFilter(ShuiPing.SelectedValue) + "','" + Common.strFilter(MiJi.SelectedValue) + "','" + Common.strFilter(ShuXing.SelectedValue) + "','" + Common.strFilter(ChuangXinXingShi.SelectedValue) + "','" +
                  Common.strFilter(YingYongQingKuang.SelectedValue) + "','" + Common.strFilter(NoYingYYin.SelectedValue) + "','" + Session["userid"] + "','" +
                  Common.strFilter(JiaoYiState.SelectedValue) + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + Session["userid"] + "',1,'" + Common.strFilter(cbtexthy) + "','" + Common.strFilter(webtype.SelectedValue) + "','" + ((indexlocation.SelectedValue)) + "','" + biaoqian.Text + "',11,11,'" + Common.strFilter(qianjisltl.SelectedValue) + "')";
        }
        int id = DBqiye.getRowsreturnid(sql + "Select @@Identity");

        //int Gid = Convert.ToInt32(DBqiye.ExecuteScalar());
        //sql = "";
        XingZhiBiao = XingZhiBiao + "";

        string sql1 = "update Results set RNo='" + XingZhiBiao + id + "' where ID='" + id + "' ";

        DBqiye.getRowsCount(sql1);
        //合作方式
        {
            sql = @"update  [dbo].[Results] set [hezuotype1]='" + Common.strFilter(((hezuotype1.Checked) ? "1" : "0")) + "',[hezuotype2]='" + Common.strFilter(((hezuotype2.Checked) ? "1" : "0")) + "',[hezuotype3]='" + Common.strFilter(((hezuotype3.Checked) ? "1" : "0")) + "',[hezuotype4]='" + Common.strFilter(((hezuotype4.Checked) ? "1" : "0"))
                  + "',[hezuocost1]='" + Common.strFilter(hezuocost1.Text) + "',[hezuocost2]='" + Common.strFilter(hezuocost2.Text) + "',[hezuocost3]='" + Common.strFilter((hezuocost3.Text)) + "' where id=" + id;
        }
        int count = DBqiye.getRowsCount(sql);

        //图片上传
        if (!upfile.HasFile)
        {
            Label1.Text = "请选择文件后上传"; return;
        }
        if (upfile.FileBytes.Length > 1024 * 1024)
        {
            Label1.Text = "文件不能大于1M"; return;
        }
        string ext = upfile.FileName.Substring(upfile.FileName.Length - 3).ToLower();

        if (ext != "png" && ext != "jpg" && ext != "gif")
        {
            Label1.Text = "文件格式只能是png或jpg"; return;
        }
        string file     = DateTime.Now.ToString("yyyMMddHHmmss.ss");
        string filename = Server.MapPath("~/upload/") + file + "." + ext;
        //upfile.SaveAs(filename);
        string filename1 = Server.MapPath("~/yuan/upload/") + file + "." + ext;

        upfile.SaveAs(filename1);
        pic.Text = "/upload/" + file + "." + ext;
        imgtext.BuildWatermark(filename1, Server.MapPath("/") + "/images/shunyin.png", "www.kjcgjy.com", filename);
        //imgtext.AddWaterText(filename1, "www.kjcgjy.com", filename, 255, 50);
        //imgh.ImageUrl = "/upload/" + file + "." + ext;
        //DBC.getRowsCount("update users set headimg='" + headimg.Text + "' where id=" + Session["userid"].ToString());
        //imgh.ImageUrl = imgh.ImageUrl;
        //Session["headimg"] = imgh.ImageUrl;
        //Global.ROOM.updateheadIMG(ulong.Parse(Session["userid"].ToString()), imgh.ImageUrl);
        Label1.Text = "上传成功";
        ///cid = Request.QueryString["id"].ToString();
        sql = "";
        {
            sql = @"INSERT INTO [dbo].[ResultPic]           ([CID]           ,[FileName]                    ,[datetime]           ,[state],[viewindex])VALUES('"
                  + id + "','" + Common.strFilter(pic.Text) + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',1,1)";
        }
        count = DBqiye.getRowsCount(sql);
        sql   = "";
        if (count > 0)
        {
            Label1.Text = "保存成功" + sql;
        }
        else
        {
            Label1.Text = "保存失败" + sql;
        }
    }