public List <AnalysResultTotal> Get_Params(string ProName, string SelectedParam, string NodeName)
        {
            string sql = "select * from tb_AnalysisResult where ProName=@ProName and Pramas=@SelectedParam and NodeName=@NodeName ";
            List <AnalysResultTotal> AnalysResultTotalList = null;

            SqlParameter[] sqlParameter =
            {
                new SqlParameter("@ProName",       SqlDbType.VarChar),
                new SqlParameter("@SelectedParam", SqlDbType.VarChar),
                new SqlParameter("@NodeName",      SqlDbType.VarChar)
            };
            sqlParameter[0].Value = ProName;
            sqlParameter[1].Value = SelectedParam;
            sqlParameter[2].Value = NodeName;
            using (SqlDataReader sdr = SqlHelper.ExecuteReader(sql, sqlParameter))
            {
                if (sdr.HasRows)
                {
                    AnalysResultTotalList = new List <AnalysResultTotal>();
                    while (sdr.Read())
                    {
                        AnalysResultTotal analysResult = new AnalysResultTotal();
                        //analysResult.ProjectName = sdr.GetString(0);
                        analysResult.RecordName         = sdr.GetString(1);
                        analysResult.Pramas             = sdr.GetString(2);
                        analysResult.PramasAndIntroduce = sdr.GetString(3);
                        analysResult.DeviateDescription = sdr.GetString(4);
                        analysResult.Reason             = sdr.GetString(5);
                        analysResult.F0          = sdr.GetString(6);
                        analysResult.Consequence = sdr.GetString(7);
                        analysResult.Si          = sdr.GetString(8);
                        analysResult.Li          = sdr.GetString(9);
                        analysResult.Ri          = sdr.GetString(10);
                        analysResult.Measure     = sdr.GetString(11);
                        analysResult.Fs          = sdr.GetString(12);
                        analysResult.S           = sdr.GetString(13);
                        analysResult.L           = sdr.GetString(14);
                        analysResult.R           = sdr.GetString(15);
                        analysResult.Suggestion  = sdr.GetString(16);
                        analysResult.Company     = sdr.GetString(17);
                        analysResult.Mark        = sdr.GetString(18);
                        analysResult.ResultID    = sdr.GetInt32(19);
                        AnalysResultTotalList.Add(analysResult);
                    }
                }
            }
            return(AnalysResultTotalList);
        }
        public bool SaveContent()
        {
            bool flag = false;
            List <AnalysResultTotal> analysResultTotalsInfo = new List <AnalysResultTotal>();
            List <int>     ResuletID      = new List <int>();;
            AnalyResultBLL analyResultBLL = new AnalyResultBLL();

            if (this.trvUcAnaly.SelectedNode.Level == 2)
            {
                #region
                if (dgvCcAnalys1.Rows.Count > 1)
                {
                    for (int i = 0; i < dgvCcAnalys1.Rows.Count - 1; i++)
                    {
                        AnalysResultTotal AnalysResultTotal = new AnalysResultTotal();
                        AnalysResultTotal.ProjectName = InitialInterface.ProName;
                        AnalysResultTotal.RecordName  = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyNum"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyNum"].Value.ToString();
                        AnalysResultTotal.Pramas      = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyParams"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyParams"].Value.ToString();
                        if (AnalysResultTotal.Pramas.Length == 0)
                        {
                            if (this.trvUcAnaly.SelectedNode.Level == 2)
                            {
                                AnalysResultTotal.Pramas = this.trvUcAnaly.SelectedNode.Text;
                            }
                        }
                        AnalysResultTotal.PramasAndIntroduce = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyParamsAndIntro"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyParamsAndIntro"].Value.ToString();
                        AnalysResultTotal.DeviateDescription = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyDesc"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyDesc"].Value.ToString();
                        AnalysResultTotal.Reason             = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyReason"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyReason"].Value.ToString();
                        AnalysResultTotal.F0          = "";
                        AnalysResultTotal.Consequence = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyConseq"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyConseq"].Value.ToString();
                        AnalysResultTotal.Si          = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalySi"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalySi"].Value.ToString();
                        AnalysResultTotal.Li          = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyLi"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyLi"].Value.ToString();
                        AnalysResultTotal.Ri          = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyRi"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyRi"].Value.ToString();
                        AnalysResultTotal.Measure     = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyMessure"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyMessure"].Value.ToString();
                        AnalysResultTotal.Fs          = "";
                        AnalysResultTotal.S           = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyS"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyS"].Value.ToString();
                        AnalysResultTotal.L           = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyL"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyL"].Value.ToString();
                        AnalysResultTotal.R           = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyR"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyR"].Value.ToString();
                        AnalysResultTotal.Suggestion  = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalySugges"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalySugges"].Value.ToString();
                        AnalysResultTotal.Company     = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyCompany"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyCompany"].Value.ToString();
                        AnalysResultTotal.Mark        = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyMark"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyMark"].Value.ToString();
                        //AnalysResultTotal.NodeName
                        if (this.trvUcAnaly.SelectedNode.Level == 1)
                        {
                            AnalysResultTotal.NodeName = this.trvUcAnaly.SelectedNode.Text;
                        }
                        if (this.trvUcAnaly.SelectedNode.Level == 2)
                        {
                            AnalysResultTotal.NodeName = this.trvUcAnaly.SelectedNode.Parent.Text;
                        }
                        if (this.trvUcAnaly.SelectedNode.Level == 3)
                        {
                            AnalysResultTotal.NodeName = this.trvUcAnaly.SelectedNode.Parent.Parent.Text;
                        }
                        analysResultTotalsInfo.Add(AnalysResultTotal);
                        if (dgvCcAnalys1.Rows[i].Cells["ResultID"].Value != null)
                        {
                            if ((int)dgvCcAnalys1.Rows[i].Cells["ResultID"].Value != 0)
                            {
                                ResuletID.Add((int)dgvCcAnalys1.Rows[i].Cells["ResultID"].Value);
                            }
                        }
                    }

                    if (ResuletID.Count > 0)
                    {
                        if (analyResultBLL.Del_AnalysisResult(ResuletID))
                        {
                            if (analyResultBLL.Add_AnalysisResult(analysResultTotalsInfo))
                            {
                                AfterSaveBinding(TreeViewSelected, TreeViewSelectedE);
                                flag = true;
                            }
                            else
                            {
                                MessageBox.Show("保存失败!");
                            }
                        }
                    }
                    else
                    {
                        if (analysResultTotalsInfo != null)
                        {
                            if (analyResultBLL.Add_AnalysisResult(analysResultTotalsInfo))
                            {
                                AfterSaveBinding(TreeViewSelected, TreeViewSelectedE);
                                flag = true;
                            }
                            else
                            {
                                MessageBox.Show("保存失败!");
                            }
                        }
                    }
                }
                #endregion
            }
            else
            {
                if (dgvCcAnalys1.Rows.Count > 0)
                {
                    for (int i = 0; i < dgvCcAnalys1.Rows.Count; i++)
                    {
                        AnalysResultTotal AnalysResultTotal = new AnalysResultTotal();
                        AnalysResultTotal.ProjectName = InitialInterface.ProName;
                        AnalysResultTotal.RecordName  = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyNum"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyNum"].Value.ToString();
                        //AnalysResultTotal.Pramas = this.trvUcAnaly.SelectedNode.Text;
                        AnalysResultTotal.Pramas             = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyParams"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyParams"].Value.ToString();
                        AnalysResultTotal.PramasAndIntroduce = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyParamsAndIntro"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyParamsAndIntro"].Value.ToString();
                        AnalysResultTotal.DeviateDescription = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyDesc"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyDesc"].Value.ToString();
                        AnalysResultTotal.Reason             = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyReason"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyReason"].Value.ToString();
                        AnalysResultTotal.F0          = "";
                        AnalysResultTotal.Consequence = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyConseq"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyConseq"].Value.ToString();
                        AnalysResultTotal.Si          = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalySi"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalySi"].Value.ToString();
                        AnalysResultTotal.Li          = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyLi"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyLi"].Value.ToString();
                        AnalysResultTotal.Ri          = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyRi"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyRi"].Value.ToString();
                        AnalysResultTotal.Measure     = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyMessure"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyMessure"].Value.ToString();
                        AnalysResultTotal.Fs          = "";
                        AnalysResultTotal.S           = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyS"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyS"].Value.ToString();
                        AnalysResultTotal.L           = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyL"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyL"].Value.ToString();
                        AnalysResultTotal.R           = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyR"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyR"].Value.ToString();
                        AnalysResultTotal.Suggestion  = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalySugges"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalySugges"].Value.ToString();
                        AnalysResultTotal.Company     = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyCompany"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyCompany"].Value.ToString();
                        AnalysResultTotal.Mark        = dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyMark"].Value == null ? "" : dgvCcAnalys1.Rows[i].Cells["dgcCcAnalyMark"].Value.ToString();
                        //AnalysResultTotal.NodeName
                        if (this.trvUcAnaly.SelectedNode.Level == 1)
                        {
                            AnalysResultTotal.NodeName = this.trvUcAnaly.SelectedNode.Text;
                        }
                        if (this.trvUcAnaly.SelectedNode.Level == 2)
                        {
                            AnalysResultTotal.NodeName = this.trvUcAnaly.SelectedNode.Parent.Text;
                        }
                        if (this.trvUcAnaly.SelectedNode.Level == 3)
                        {
                            AnalysResultTotal.NodeName = this.trvUcAnaly.SelectedNode.Parent.Parent.Text;
                        }
                        analysResultTotalsInfo.Add(AnalysResultTotal);
                        if (dgvCcAnalys1.Rows[i].Cells["ResultID"].Value != null)
                        {
                            if ((int)dgvCcAnalys1.Rows[i].Cells["ResultID"].Value != 0)
                            {
                                ResuletID.Add((int)dgvCcAnalys1.Rows[i].Cells["ResultID"].Value);
                            }
                        }
                    }

                    if (ResuletID.Count > 0)
                    {
                        if (analyResultBLL.Del_AnalysisResult(ResuletID))
                        {
                            if (analyResultBLL.Add_AnalysisResult(analysResultTotalsInfo))
                            {
                                AfterSaveBinding(TreeViewSelected, TreeViewSelectedE);
                                flag = true;
                            }
                            else
                            {
                                MessageBox.Show("保存失败!");
                            }
                        }
                    }
                    else
                    {
                        if (analysResultTotalsInfo != null)
                        {
                            if (analyResultBLL.Add_AnalysisResult(analysResultTotalsInfo))
                            {
                                AfterSaveBinding(TreeViewSelected, TreeViewSelectedE);
                                flag = true;
                            }
                            else
                            {
                                MessageBox.Show("保存失败!");
                            }
                        }
                    }
                }
            }


            return(flag);
            //List<AnalysResultTotal> analysResultTotals = new List<AnalysResultTotal>();
            //analysResultTotals = analyResultBLL.Get_All(InitialInterface.ProName,this.trvUcAnaly.SelectedNode.Text);
            //this.dgvCcAnalys1.DataSource = analysResultTotals;
        }