Esempio n. 1
0
    protected void btn_saveitem_Click(object sender, EventArgs e)
    {
        Entity.stationP entity = new Entity.stationP();
        entity.wrwtype    = strSelectedId;
        entity.createuser = "";
        entity.bz         = txt_Remark.Text.Trim();
        if (strHyId != " " && strHyId != "")
        {
            entity.ID = int.Parse(strHyId);
        }
        else
        {
            entity.ID = 0;
        }

        foreach (ListItem LI in cb_analysisList.Items)
        {
            if (LI.Selected)
            {
                Entity.Item temp = new Entity.Item();
                temp.itemid = LI.Value;
                temp.itemfw = "";
                entity.itemlist.Add(temp);
            }
        }
        foreach (ListItem LI in cb_other.Items)
        {
            if (LI.Selected)
            {
                Entity.Item temp = new Entity.Item();
                temp.itemid = LI.Value;
                temp.itemfw = "";
                entity.itemlist.Add(temp);
            }
        }
        DAl.StationParam doobj = new DAl.StationParam();
        if (doobj.AddItemParam(entity) > 0)
        {
            panel_Item.Visible = false;
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "click", "alert('数据保存成功!');", true);
        }
        else
        {
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "click", "alert('数据保存失败!');", true);
        }

        ItemParam();
    }
    protected void btn_OK_Click(object sender, EventArgs e)
    {
        if (btn_OK.Text == "编辑")
        {
            AllTxtCanWrite();
            btn_OK.Text   = "确定";
            lbl_Type.Text = "编辑";
        }
        else
        {
            //if (myDR2.Tables[0].Rows.Count > 0)
            //{
            //    compay = myDR2.Tables[0].Rows[0]["id"].ToString();
            //}
            //else
            //{
            //    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "click", "alert('系统不存在该企业,请核实!');", true);
            //    return;
            //}
            #region 当按钮文字为“确定”时,执行添加或编辑操作
            DAl.StationParam doobj  = new DAl.StationParam();
            Entity.stationP  entity = new Entity.stationP();
            //初始化信息
            //获取样品类型编码
            string  typename = "";
            DataSet myDR1    = new MyDataOp("select ClassID TypeID from t_M_AnalysisMainClassEx where ClassName='" + DropList_SampleType.Text.Trim() + "'").CreateDataSet();
            if (myDR1.Tables[0].Rows.Count > 0)
            {
                typename = myDR1.Tables[0].Rows[0]["TypeID"].ToString();
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "click", "alert('系统不存在该样品类型,请核实!');", true);
                return;
            }
            string checkstr = "";
            if (lbl_Type.Text == "添加")
            {
                checkstr = "select count(id) from t_hyClassParam where hyid='" + drop_hy.SelectedValue.ToString().Trim() + "' and wrwtype='" + typename + "' and bz='" + drop_bz.SelectedValue.Trim() + "' and itemlist='" + txt_Item.Text.Trim() + "'";
            }
            else
            {
                checkstr = "select count(id) from t_hyClassParam where hyid='" + drop_hy.SelectedValue.ToString().Trim() + "' and wrwtype='" + typename + "' and bz='" + drop_bz.SelectedValue.Trim() + "' and itemlist='" + txt_Item.Text.Trim() + "' and id!='" + strSelectedId + "'";
            }

            DataSet myCheck = new MyDataOp(checkstr).CreateDataSet();


            if (int.Parse(myCheck.Tables[0].Rows[0][0].ToString()) > 0)
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "click", "alert('系统已存在改行业污染物执行标准的设定!');", true);
                return;
            }
            entity.wrwtype = typename;

            // //获取企业编号
            string compay = drop_hy.SelectedValue.ToString();
            //DataSet myDR2 = new MyDataOp("select id from t_企业信息 where 单位全称='" + txt_SampleSource.Text.Trim() + "'").CreateDataSet();
            //if (myDR2.Tables[0].Rows.Count > 0)
            //{
            //    compay = myDR2.Tables[0].Rows[0]["id"].ToString();
            //}
            //else
            //{
            //    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "click", "alert('系统不存在该企业,请核实!');", true);
            //    return;
            //}
            entity.bz         = drop_bz.SelectedValue.Trim();
            entity.qyid       = compay;
            entity.createdate = DateTime.Now;
            entity.createuser = Request.Cookies["Cookies"].Values["u_id"].ToString();
            entity.item       = txt_Item.Text;
            for (int j = 0; j < grv_Item.Rows.Count; j++)
            {
                Entity.Item temp = new Entity.Item();
                if (grv_Item.Rows[j].Cells[3].Text.Trim() != "" && grv_Item.Rows[j].Cells[3].Text.Trim() != "&nbsp;")
                {
                    try
                    {
                        temp.itemid = grv_Item.Rows[j].Cells[3].Text.Trim();//分析项目ID
                        TextBox txt_fw = grv_Item.Rows[j].Cells[5].FindControl("itemvalue") as TextBox;

                        try
                        {
                            temp.itemfw = txt_fw.Text.Trim();//分析项目范围
                        }
                        catch
                        { temp.itemfw = ""; }
                        entity.itemlist.Add(temp);
                    }
                    catch
                    { temp.itemid = ""; }
                }
            }
            //添加新纪录
            if (lbl_Type.Text == "添加")
            {
                if (doobj.add(entity) > 0)
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "click", "hiddenDetail();alert('数据添加成功!');", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "click", "hiddenDetail();alert('数据添加失败!');", true);
                }

                Query();
            }

            //编辑记录
            if (lbl_Type.Text == "编辑")
            {
                entity.ID = int.Parse(strSelectedId);
                if (doobj.update(entity) > 0)
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "click", "hiddenDetail();alert('数据编辑成功!');", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "click", "hiddenDetail();alert('数据编辑失败!');", true);
                }

                Query();
            }
            #endregion
        }
    }
    protected void btn_OK_Click(object sender, EventArgs e)
    {
        if (btn_OK.Text == "编辑")
        {
            AllTxtCanWrite();
            btn_OK.Text   = "确定";
            lbl_Type.Text = "编辑";
        }
        else
        {
            #region 当按钮文字为“确定”时,执行添加或编辑操作
            DAl.StationParam doobj  = new DAl.StationParam();
            Entity.stationP  entity = new Entity.stationP();
            //初始化信息
            //获取样品类型编码
            string typename = drop_wrw.SelectedValue.Trim();
            entity.wrwtype = typename;

            //获取企业编号
            string strcheck = "";
            if (lbl_Type.Text == "添加")
            {
                strcheck = "select id from t_OUTNO where outNO='" + txt_SampleSource.Text.Trim() + "'";
            }
            else
            {
                strcheck = "select id from t_OUTNO where outNO='" + txt_SampleSource.Text.Trim() + "' and id!='" + strSelectedId + "'";
            }
            DataSet myDR2 = new MyDataOp(strcheck).CreateDataSet();
            if (myDR2.Tables[0].Rows.Count > 0)
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "click", "alert('系统已存在改采样点!');", true);
                return;
            }
            else
            {
                entity.bz         = txt_SampleSource.Text.Trim();
                entity.createdate = DateTime.Now;
                entity.createuser = Request.Cookies["Cookies"].Values["u_id"].ToString();
                for (int j = 0; j < grv_Item.Rows.Count; j++)
                {
                    Entity.Item temp = new Entity.Item();
                    if (grv_Item.Rows[j].Cells[3].Text.Trim() != "" && grv_Item.Rows[j].Cells[3].Text.Trim() != "&nbsp;")
                    {
                        try
                        {
                            temp.itemid = grv_Item.Rows[j].Cells[3].Text.Trim();//分析项目ID
                            TextBox txt_fw = grv_Item.Rows[j].Cells[5].FindControl("itemvalue") as TextBox;

                            try
                            {
                                temp.itemfw = txt_fw.Text.Trim();//分析项目范围
                            }
                            catch
                            { temp.itemfw = ""; }
                            entity.itemlist.Add(temp);
                        }
                        catch
                        { temp.itemid = ""; }
                    }
                }
                //添加新纪录
                if (lbl_Type.Text == "添加")
                {
                    if (doobj.addOUTNOParam(entity) > 0)
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "click", "hiddenDetail();alert('数据添加成功!');", true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "click", "hiddenDetail();alert('数据添加失败!');", true);
                    }

                    Query();
                }

                //编辑记录
                if (lbl_Type.Text == "编辑")
                {
                    entity.ID = int.Parse(strSelectedId);
                    if (doobj.updateOUTNOParam(entity) > 0)
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "click", "hiddenDetail();alert('数据编辑成功!');", true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "click", "hiddenDetail();alert('数据编辑失败!');", true);
                    }

                    Query();
                }
            }
            #endregion
        }
    }