zoukankan      html  css  js  c++  java
  • 在同一个数据库表中添加不同的数据(笛卡尔积)

           /// <summary>
            /// 添加检测项目
            /// </summary>
            private void PbitemCodeSubmit()
            {
                string msg = "0";
                string[] oldPBItems = Request.Form["ipt_pbitemcode"].Split(',');
                string strWhere = string.Format("BioTestPlanHeaderID={0}", Request.Form["ipt_biotestplanheaderid"]);
                List<Model.BioTestPlanBody> bioTestPlanBodyModelList = bioTestPlanBodyBll.GetModelList(strWhere);//根据检测计划ID查询学生检测信息
                strWhere = string.Format("BioTestPlanHeaderID={0}", Request.Form["ipt_biotestplanheaderid"]);
                DataSet dsPBItem = dhBll.GetList("V_PBItemOfBioTestPlanBody", "*", "", strWhere);
                strWhere = string.Format("BioTestPlanHeaderID={0}", Request.Form["ipt_biotestplanheaderid"]);
                DataSet dsAthlete = dhBll.GetList("V_AthleteStudentBYBioTestPlanBody", "*", "", strWhere);
                List<string> newPBItemList = oldPBItems.ToList<string>();
                foreach (DataRow itemRow in dsPBItem.Tables[0].Rows)
                {
                    if (!newPBItemList.Contains(itemRow["PBItemCode"].ToString()))
                    {
                        newPBItemList.Add(itemRow["PBItemCode"].ToString());
                        break;
                    }
                }
                if (dsAthlete.Tables[0].Rows.Count > 0)
                {
                    for (int num = 0; num < newPBItemList.Count; num++)
                    {
                        foreach (DataRow itemRow in dsAthlete.Tables[0].Rows)
                        {
                            Model.BioTestPlanBody bioTestPlanModel = new Model.BioTestPlanBody();
                            bioTestPlanModel.BioTestPlanHeaderID = Convert.ToInt32(Request.Form["ipt_biotestplanheaderid"]);
                            bioTestPlanModel.AthleteStudentID = Convert.ToInt32(itemRow["AthleteStudentID"].ToString());
                            bioTestPlanModel.PBItemCode = newPBItemList[num];
                            bioTestPlanBodyBll.Add(bioTestPlanModel);
                        }
                    }
                }
                else
                {
                    for (int num = 0; num < newPBItemList.Count; num++)
                    {
                        Model.BioTestPlanBody bioTestPlanModel = new Model.BioTestPlanBody();
                        bioTestPlanModel.BioTestPlanHeaderID = Convert.ToInt32(Request.Form["ipt_biotestplanheaderid"]);
                        bioTestPlanModel.PBItemCode = newPBItemList[num];
                        bioTestPlanBodyBll.Add(bioTestPlanModel);
                    }
                }
                foreach (Model.BioTestPlanBody itemModel in bioTestPlanBodyModelList)
                {
                    bioTestPlanBodyBll.Delete(itemModel.BioTestPlanBodyID);
                }
                WebCommon.WriteMsg(msg);
            }

  • 相关阅读:
    【转】staruml用户手册目录【中文翻译版】
    [转]“菜”鸟理解.NET Framework(CLI,CLS,CTS,CLR,FCL,BCL)
    [转]程序员面试题精选100题(51)顺时针打印矩阵
    [转] 程序员面试题精选100题(35)找出两个链表的第一个公共结点
    [转] 深入探索.NET框架内部了解CLR如何创建运行时对象
    海量数据处理的几种方法总结 .
    分析函数总结
    PLSQL实现排序(冒泡、选择、快速)
    oracle 分析函数2
    创建表分区的总结
  • 原文地址:https://www.cnblogs.com/IT1517/p/4956045.html
Copyright © 2011-2022 走看看