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);
            }

  • 相关阅读:
    【shell脚本】系统硬件信息数据库收集(普通版和导入Excel版)auto_system_collect.sh
    【linux命令】sz、rz命令安装及使用
    【shell脚本】全备份和增量备份Linux系统脚本auto_bak_system.sh
    【shell脚本】截取恶意端口ip,禁止远程登录22端口auto_deny_ip.sh
    【shell脚本】自动生成网卡文件主要内容auto_network_scripts.sh
    java 多个数 组合成不同的组
    linux jdk配置
    ubuntu sh脚本激活conda 虚拟环境
    liunx mysql数据库目录迁移
    liunx 定时任务执行java程序配置流程
  • 原文地址:https://www.cnblogs.com/IT1517/p/4956045.html
Copyright © 2011-2022 走看看