//获取效益矩阵字段名字数据,并将对应gridview中的第一列数据进行赋值 protected void GetBenName() { STBC.BLL.ST_FACTDIR factdirB = new STBC.BLL.ST_FACTDIR(); DataSet ds = factdirB.GetList("parent=13"); DataTable dt = ds.Tables[0]; lsBenName.Clear(); foreach (DataRow dr in dt.Rows) { lsBenName.Add(dr["Name"].ToString()); } this.BenefitGrid.DataSource = dt.DefaultView; this.BenefitGrid.DataBind(); }
//获取限制条件第一列的名字 protected void getLimcondName() { #region 获取限制条件第一列的名字,并赋值给lsLimitName存储 STBC.BLL.ST_FACTDIR factdirB = new STBC.BLL.ST_FACTDIR(); DataSet ds = factdirB.GetList("parent=1 or parent =2"); DataTable dt = ds.Tables[0]; lsLimitName.Clear(); foreach (DataRow dr in dt.Rows) { lsLimitName.Add(dr["Name"].ToString()); } this.LimcondGrid.DataSource = ds.Tables[0].DefaultView; this.LimcondGrid.DataBind(); #endregion }
//获取模糊函数第一列的名字: protected void getFuzzfuntionName() { //STBC.BLL.SUITAINDICATOR benefitindicatorB = new STBC.BLL.SUITAINDICATOR(); STBC.BLL.ST_FACTDIR factdirB = new STBC.BLL.ST_FACTDIR(); DataSet ds = factdirB.GetList("parent=1 or parent =2"); DataTable dt = ds.Tables[0]; lsFuzzName.Clear(); foreach (DataRow dr in dt.Rows) { lsFuzzName.Add(dr["Name"].ToString()); } this.FuzzfunctGrid.DataSource = ds.Tables[0].DefaultView; this.FuzzfunctGrid.DataBind(); }
//创建效益评价因子规则(对计算的结果插入到数据库里面) protected void benefitFactorscreateRule_Click(object sender, EventArgs e) { //1获得用户的id int userID = CommonClass.OperateUsers.getUserID(); //、获取措施。因为因为所有的措施中适宜性权重值都相同,这里只是象征性的给它赋值经济林果。其实没什么用的。 string measurename = "经济林果"; for (int i = 0; i < lsBenName.Count; i++) { //3、获取到效益权重的因子名对应的ID STBC.BLL.ST_FACTDIR factdirB = new STBC.BLL.ST_FACTDIR(); DataSet ds2 = factdirB.GetList("Name='" + lsBenName[i].ToString() + "'"); DataTable dt2 = ds2.Tables[0]; int factid = int.Parse(dt2.Rows[0]["ID"].ToString()); STBC.BLL.ST_FACTEVALWEIG factevalweigB = new STBC.BLL.ST_FACTEVALWEIG(); STBC.Model.ST_FACTEVALWEIG factevalweigM = new STBC.Model.ST_FACTEVALWEIG(); factevalweigM.OWNER = userID; factevalweigM.SUITAINDICATOR = factid; factevalweigM.MEASNAME = measurename; factevalweigM.WEIGHT = (decimal)Math.Round(resultBenefit[i, 0], 4); //判断数据是否已经存在,如果不存在则插入数据库里面 if (!factevalweigB.Exists(userID, factid, measurename)) { factevalweigB.Add(factevalweigM); //提醒用户已经插入数据库 if (i == lsBenName.Count - 1) { Response.Write("<script>alert('权重已经插入数据库!');</script>"); } } else { //更新数据 factevalweigB.Update(factevalweigM); //提醒数据已经被更新了 if (i == lsBenName.Count - 1) { Response.Write("<script>alert('权重已经被更新!');</script>"); } } } }
//获取适宜性字段名数据,并将对应相关gridview中的第一列数据 protected void GetSuitName() { #region 获取适宜性字段名数据,并将对应相关gridview中的第一列数据 STBC.BLL.ST_FACTDIR factdirB = new STBC.BLL.ST_FACTDIR(); DataSet ds = factdirB.GetList("ID!=0 and ID!=13 and parent=0"); DataTable dt = ds.Tables[0]; //清空lsSuitName lsSuitName.Clear(); foreach (DataRow dr in dt.Rows) { lsSuitName.Add(dr["Name"].ToString()); } //将表中的Name显示到SuitfactGrid中 this.SuitfactGrid.DataSource = dt.DefaultView; this.SuitfactGrid.DataBind(); //社会因子 设置 DataSet ds2 = factdirB.GetList("ID!=0 and parent=1"); DataTable dt2 = ds2.Tables[0]; lsSuitName2.Clear(); foreach (DataRow dr in dt2.Rows) { lsSuitName2.Add(dr["Name"].ToString()); } this.SuitfactGrid2.DataSource = dt2.DefaultView; this.SuitfactGrid2.DataBind(); //自然因子设置 DataSet ds3 = factdirB.GetList("ID!=0 and parent=2"); DataTable dt3 = ds3.Tables[0]; lsSuitName3.Clear(); foreach (DataRow dr in dt3.Rows) { lsSuitName3.Add(dr["Name"].ToString()); } this.SuitfactGrid3.DataSource = dt3.DefaultView; this.SuitfactGrid3.DataBind(); #endregion }
protected bool insertSuitWeigth(List <string> lsSuitNameList, double[,] resultSuit, int userID, string measurename) { bool isok = false; //效益型权重插入2 for (int i = 0; i < lsSuitNameList.Count; i++) { //3、获取到效益权重的因子名对应的ID //STBC.BLL.SUITAINDICATOR suitaindicatorB = new STBC.BLL.SUITAINDICATOR(); STBC.BLL.ST_FACTDIR factdirB = new STBC.BLL.ST_FACTDIR(); DataSet ds2 = factdirB.GetList("Name='" + lsSuitNameList[i].ToString() + "'"); DataTable dt2 = ds2.Tables[0]; int factID = int.Parse(dt2.Rows[0]["ID"].ToString()); STBC.BLL.ST_FACTEVALWEIG factevalweigB = new STBC.BLL.ST_FACTEVALWEIG(); STBC.Model.ST_FACTEVALWEIG factevalweigM = new STBC.Model.ST_FACTEVALWEIG(); factevalweigM.SUITAINDICATOR = factID; factevalweigM.OWNER = userID; double weight1 = resultSuit[i, 0]; factevalweigM.WEIGHT = (decimal)Math.Round(weight1, 4); factevalweigM.MEASNAME = measurename; //判断数据是否已经存在,如果不存在则插入数据库里面 if (!factevalweigB.Exists(userID, factID, measurename)) { factevalweigB.Add(factevalweigM); } else { //如果数据库已经存在则更新 factevalweigB.Update(factevalweigM); isok = true; } } return(isok); }
protected bool insertSuitWeigth(List<string> lsSuitNameList, double[,] resultSuit, int userID, string measurename) { bool isok = false; //效益型权重插入2 for (int i = 0; i < lsSuitNameList.Count; i++) { //3、获取到效益权重的因子名对应的ID //STBC.BLL.SUITAINDICATOR suitaindicatorB = new STBC.BLL.SUITAINDICATOR(); STBC.BLL.ST_FACTDIR factdirB = new STBC.BLL.ST_FACTDIR(); DataSet ds2 = factdirB.GetList("Name='" + lsSuitNameList[i].ToString() + "'"); DataTable dt2 = ds2.Tables[0]; int factID = int.Parse(dt2.Rows[0]["ID"].ToString()); STBC.BLL.ST_FACTEVALWEIG factevalweigB = new STBC.BLL.ST_FACTEVALWEIG(); STBC.Model.ST_FACTEVALWEIG factevalweigM = new STBC.Model.ST_FACTEVALWEIG(); factevalweigM.SUITAINDICATOR = factID; factevalweigM.OWNER = userID; double weight1 = resultSuit[i, 0]; factevalweigM.WEIGHT = (decimal)Math.Round(weight1, 4); factevalweigM.MEASNAME = measurename; //判断数据是否已经存在,如果不存在则插入数据库里面 if (!factevalweigB.Exists(userID, factID, measurename)) { factevalweigB.Add(factevalweigM); } else { //如果数据库已经存在则更新 factevalweigB.Update(factevalweigM); isok = true; } } return isok; }
//模糊函数创建规则构建,创建规则并提交到数据库中 protected void btn_modelCreated_Click(object sender, EventArgs e) { //获得用户的id int userID = CommonClass.OperateUsers.getUserID(); string measurename = measureFuzzfunct.SelectedItem.Text; STBC.BLL.ST_FUZZFUNCT fuzzfunctB = new STBC.BLL.ST_FUZZFUNCT(); STBC.Model.ST_FUZZFUNCT fuzzfunctM = new STBC.Model.ST_FUZZFUNCT(); for (int i = 0; i < lsFuzzName.Count; i++) { DropDownList ddlFunct = (DropDownList)FuzzfunctGrid.Rows[i].FindControl("ddlFunctSelect"); string functtype = ddlFunct.SelectedItem.Text; //查找到每行因子对应的因子id STBC.BLL.ST_FACTDIR factdirB = new STBC.BLL.ST_FACTDIR(); DataSet ds2 = factdirB.GetList("Name='" + lsFuzzName[i].ToString() + "'"); DataTable dt2 = ds2.Tables[0]; int factid = int.Parse(dt2.Rows[0]["ID"].ToString()); //找到对应的单位 TextBox txtUn = (TextBox)FuzzfunctGrid.Rows[i].FindControl("txtUnit1"); #region 取得拐点值的设置,并把它插入数据库里面 if (functtype == "抛物线型") { //拼接拐点设置条件 TextBox txtPa11 = (TextBox)FuzzfunctGrid.Rows[i].FindControl("txtPa1"); TextBox txtPb11 = (TextBox)FuzzfunctGrid.Rows[i].FindControl("txtPb1"); TextBox txtPb21 = (TextBox)FuzzfunctGrid.Rows[i].FindControl("txtPb2"); TextBox txtPa21 = (TextBox)FuzzfunctGrid.Rows[i].FindControl("txtPa2"); string inflexion = txtPa11.Text + "|" + txtPb11.Text + "|" + txtPb21.Text + "|" + txtPa21.Text; fuzzfunctM.FACTID = factid; fuzzfunctM.FUNCTTYPE = functtype; fuzzfunctM.MEASNAME = measurename; fuzzfunctM.UNIT = txtUn.Text; fuzzfunctM.USERID = userID; fuzzfunctM.INFLEXION = inflexion; //判断数据是否已经存在,如果不存在则插入数据 if (!fuzzfunctB.Exists(factid, userID, measurename)) { fuzzfunctB.Add(fuzzfunctM); } //如果存在,则更新数据 else { fuzzfunctB.Update(fuzzfunctM); } } else if (functtype == "升半梯形") { //拼接拐点设置条件 TextBox txtSa1 = (TextBox)FuzzfunctGrid.Rows[i].FindControl("txtSa"); TextBox txtSb1 = (TextBox)FuzzfunctGrid.Rows[i].FindControl("txtSb"); string inflexion = txtSa1.Text + "|" + txtSb1.Text; fuzzfunctM.FACTID = factid; fuzzfunctM.FUNCTTYPE = functtype; fuzzfunctM.MEASNAME = measurename; fuzzfunctM.UNIT = txtUn.Text; fuzzfunctM.USERID = userID; fuzzfunctM.INFLEXION = inflexion; //判断数据是否已经存在,如果不存在则插入数据 if (!fuzzfunctB.Exists(factid, userID, measurename)) { fuzzfunctB.Add(fuzzfunctM); } //如果存在,则更新数据 else { fuzzfunctB.Update(fuzzfunctM); } } else if (functtype == "降半梯形") { //拼接拐点设置条件 TextBox txtJa1 = (TextBox)FuzzfunctGrid.Rows[i].FindControl("txtJa"); TextBox txtJb1 = (TextBox)FuzzfunctGrid.Rows[i].FindControl("txtJb"); string inflexion = txtJa1.Text + "|" + txtJb1.Text; fuzzfunctM.FACTID = factid; fuzzfunctM.FUNCTTYPE = functtype; fuzzfunctM.MEASNAME = measurename; fuzzfunctM.UNIT = txtUn.Text; fuzzfunctM.USERID = userID; fuzzfunctM.INFLEXION = inflexion; //判断数据是否已经存在,如果不存在则插入数据 if (!fuzzfunctB.Exists(factid, userID, measurename)) { fuzzfunctB.Add(fuzzfunctM); } //如果存在,则更新数据 else { fuzzfunctB.Update(fuzzfunctM); } } //特征函数 else { //拼接拐点设置条件 TextBox txtGsuit1 = (TextBox)FuzzfunctGrid.Rows[i].FindControl("txtGsuit"); TextBox txtBJsuit1 = (TextBox)FuzzfunctGrid.Rows[i].FindControl("txtBJsuit"); TextBox txtYsuit1 = (TextBox)FuzzfunctGrid.Rows[i].FindControl("txtYsuit"); TextBox txtBsuit1 = (TextBox)FuzzfunctGrid.Rows[i].FindControl("txtBsuit"); string inflexion = txtGsuit1.Text + "|" + txtBJsuit1.Text + "|" + txtYsuit1.Text + "|" + txtBsuit1.Text; fuzzfunctM.FACTID = factid; fuzzfunctM.FUNCTTYPE = functtype; fuzzfunctM.MEASNAME = measurename; fuzzfunctM.UNIT = txtUn.Text; fuzzfunctM.USERID = userID; fuzzfunctM.INFLEXION = inflexion; //判断数据是否已经存在,如果不存在则插入数据 if (!fuzzfunctB.Exists(factid, userID, measurename)) { fuzzfunctB.Add(fuzzfunctM); } //如果存在,则更新数据 else { fuzzfunctB.Update(fuzzfunctM); } } if (i == lsFuzzName.Count - 1) { Response.Write("<script>alert('模糊函数已经创建了!');</script>"); } #endregion } }
//重建限制性条件 protected void btn_limitativeRule_Click(object sender, EventArgs e) { //获得用户的id int userID = CommonClass.OperateUsers.getUserID(); //措施的名字 string measurename = measureLimit.SelectedItem.Text; STBC.BLL.ST_CONSTRCONDIT constrconditB = new STBC.BLL.ST_CONSTRCONDIT(); STBC.Model.ST_CONSTRCONDIT constrconditM = new STBC.Model.ST_CONSTRCONDIT(); for (int i = 0; i < lsLimitName.Count; i++) { //查找到每行因子对应的因子id STBC.BLL.ST_FACTDIR factdirB = new STBC.BLL.ST_FACTDIR(); DataSet ds2 = factdirB.GetList("Name='" + lsLimitName[i].ToString() + "'"); DataTable dt2 = ds2.Tables[0]; int factid = int.Parse(dt2.Rows[0]["ID"].ToString()); //获取到单位,比如平方米等等 TextBox txtUnit21 = (TextBox)LimcondGrid.Rows[i].FindControl("txtUnit2"); DropDownList ddlFactType1 = (DropDownList)LimcondGrid.Rows[i].FindControl("ddlFactType"); //如果是数值类型 if (ddlFactType1.SelectedItem.Text == "数值类型") { //获取到底是>,<,=类型 DropDownList ddlContType1 = (DropDownList)LimcondGrid.Rows[i].FindControl("ddlContType"); //获取限制条件的文本 TextBox txtLimitC1 = (TextBox)LimcondGrid.Rows[i].FindControl("txtLimitC"); constrconditM.FACTID = factid; constrconditM.FACTTYPE = ddlFactType1.SelectedItem.Text; constrconditM.MEASNAME = measurename; constrconditM.SYMBOLTYPE = ddlContType1.SelectedItem.Text; constrconditM.USERID = userID; constrconditM.UNIT = txtUnit21.Text.ToString().Trim(); constrconditM.LIMCONDIT = txtLimitC1.Text.ToString().Trim(); //插入到数据库里面 if (!constrconditB.Exists(userID, factid, measurename)) { constrconditB.Add(constrconditM); } else { constrconditB.Update(constrconditM); } } //否则 else { //获取in类型 DropDownList ddlIntype1 = (DropDownList)LimcondGrid.Rows[i].FindControl("ddlIntype"); TextBox txtLimitC1 = (TextBox)LimcondGrid.Rows[i].FindControl("txtLimitC"); constrconditM.FACTID = factid; constrconditM.FACTTYPE = ddlFactType1.SelectedItem.Text; constrconditM.MEASNAME = measurename; constrconditM.SYMBOLTYPE = ddlIntype1.SelectedItem.Text; constrconditM.USERID = userID; constrconditM.UNIT = txtUnit21.Text.ToString().Trim(); constrconditM.LIMCONDIT = txtLimitC1.Text.ToString().Trim(); //插入到数据库里面 if (!constrconditB.Exists(userID, factid, measurename)) { constrconditB.Add(constrconditM); } else { constrconditB.Update(constrconditM); } } if (i == lsLimitName.Count - 1) { Response.Write("<script>alert('限制条件已经创建了!');</script>"); } } }