Ejemplo n.º 1
0
        public SystemRequirementAnalysisBLL(string billID)
        {
            SystemRequirementAnalysisEntity = new V_SystemRequirementAnalysisEntity();
            SystemRequirementAnalysisEntity.ResetForSearch();

            SystemRequirementAnalysisBodyEntity = new SystemRequirementAnalysisBodyEntity();
            SystemRequirementAnalysisBodyEntity.ResetForSearch();

            if (!string.IsNullOrEmpty(billID))
            {
                SystemAnalysisID = billID;
                SystemRequirementAnalysisEntity.SystemAnalysisID     = billID;
                SystemRequirementAnalysisBodyEntity.SystemAnalysisID = billID;
                if (string.IsNullOrEmpty(SystemRequirementAnalysisEntity.SystemAnalysisID))
                {
                    SystemRequirementAnalysisEntity.SystemAnalysisID     = "-1";
                    SystemRequirementAnalysisBodyEntity.SystemAnalysisID = "-1";
                }
                //新建的情况下,副表没外键,会导致无条件查询,所以一定要给一个不存在的值
                //如果有两个主键,更新前两个主键都要赋值,如果是查询,则无所谓了
                SystemRequirementAnalysisEntity.PageSize     = 0;
                SystemRequirementAnalysisBodyEntity.PageSize = 0;
                SystemRequireDB = SystemRequirementAnalysisEntity.GetTable(true);
                SystemRequirementAnalysisBodyEntityList = SystemRequirementAnalysisBodyEntity.ToList <SystemRequirementAnalysisBodyEntity>();
                if (SystemRequirementAnalysisBodyEntityList.Count() <= 0)
                {
                    //暂时注释 ProjectPlanningDetailEntity ProjectPlanningDetail = new ProjectPlanningDetailEntity();
                    SystemRequirementAnalysisBodyEntity.SystemAnalysisID = SystemRequirementAnalysisEntity.SystemAnalysisID;
                    SystemRequirementAnalysisBodyEntityList.Add(SystemRequirementAnalysisBodyEntity);
                }
            }
        }
Ejemplo n.º 2
0
        public bool Update()
        {
            bool result = false;

            //如要被获取则控件必须具有name属性

            try
            {
                DateTime getTime = DateTime.Now;
                int      index   = 0;
                #region 从表单页面获取数据
                SystemRequirementAnalysisEntity.GenerateObjectFromRequest("");
                #endregion
                if (SystemRequirementAnalysisEntity.ID > 0)
                {
                    SystemRequirementAnalysisEntity.ID = null;
                    SystemRequirementAnalysisEntity.IsGenerateObject = true;
                }
                else
                {
                    SystemRequirementAnalysisEntity.IsGenerateObject = false;
                }

                List <EntityBase> listUpdate = new List <EntityBase>();
                listUpdate.Add(SystemRequirementAnalysisEntity);
                //开始事务更新,需要主表在最前面
                result = SystemRequirementAnalysisEntity.db.CommitTran(listUpdate.ToArray());
                this.SystemAnalysisID = SystemRequirementAnalysisEntity.SystemAnalysisID;


                //SystemRequirementAnalysisBodyEntity SystemRequirementAnalysisBodyEntityUD = new SystemRequirementAnalysisBodyEntity();
                List <EntityBase> listUpdate2 = new List <EntityBase>();

                SystemRequirementAnalysisBodyEntity SystemRequirementAnalysisBodyEntityDel = new SystemRequirementAnalysisBodyEntity();
                SystemRequirementAnalysisBodyEntityDel.ResetForSearch();
                SystemRequirementAnalysisBodyEntityDel.SystemAnalysisID = this.SystemAnalysisID;
                SystemRequirementAnalysisBodyEntityDel.PageSize         = 0;
                SystemRequirementAnalysisBodyEntityDel.GetTable(true);
                List <SystemRequirementAnalysisBodyEntity> SystemRequirementAnalysisBodyEntityDelList = SystemRequirementAnalysisBodyEntityDel.ToList <SystemRequirementAnalysisBodyEntity>();
                SystemRequirementAnalysisBodyEntity        entity;
                foreach (var i in SystemRequirementAnalysisBodyEntityDelList)
                {
                    entity = new SystemRequirementAnalysisBodyEntity();

                    entity.ID = i.ID;
                    entity.SystemAnalysisID = this.SystemAnalysisID;
                    entity.Delete();
                }

                foreach (var key in HttpContext.Current.Request.Form.AllKeys)
                {
                    //if (key.StartsWith("atxt") && key.EndsWith("rowNo"))
                    //{
                    //    index = int.Parse(key.Replace("atxt", "").Replace("rowNo", ""));
                    //    SystemRequirementAnalysisBodyEntity SystemRequirementAnalysisBodyEntityUD2 = new SystemRequirementAnalysisBodyEntity();
                    //    SystemRequirementAnalysisBodyEntityUD2.GenerateObjectFromRequest("atxt" + index);
                    //    SystemRequirementAnalysisBodyEntityUD2.SystemAnalysisID = this.SystemAnalysisID;

                    //    if (SystemRequirementAnalysisBodyEntityUD2.ID > 0)
                    //    {
                    //        SystemRequirementAnalysisBodyEntityUD2.IsGenerateObject = true;//这是更新,指定主键存在的意义之二,根据主键来更新与保存数据()唯一确定一条记录
                    //    }
                    //    else
                    //    {

                    //        SystemRequirementAnalysisBodyEntityUD2.IsGenerateObject = false;//这是插入
                    //    }
                    //    listUpdate.Add(SystemRequirementAnalysisBodyEntityUD2);
                    //}
                    if (key.StartsWith("atxt") && key.EndsWith("rowNo"))
                    {
                        index = int.Parse(key.Replace("atxt", "").Replace("rowNo", ""));

                        SystemRequirementAnalysisBodyEntity SystemRequirementAnalysisBodyEntityUD2 = new SystemRequirementAnalysisBodyEntity();

                        SystemRequirementAnalysisBodyEntityUD2.GenerateObjectFromRequest("atxt" + index);
                        SystemRequirementAnalysisBodyEntityUD2.SystemAnalysisID = this.SystemAnalysisID;
                        //if (!string.IsNullOrEmpty(SystemRequirementAnalysisBodyEntityUD2.RowState))//添加时,RowState为空!
                        //{//编辑
                        //    if (SystemRequirementAnalysisBodyEntityUD2.RowState == "delete")//删除
                        //    {
                        //        SystemRequirementAnalysisBodyEntityUD2.Delete();
                        //    }
                        //    else
                        //    {
                        //        SystemRequirementAnalysisBodyEntityUD2.IsGenerateObject = true;
                        //    }
                        //}
                        //else
                        //{
                        //    SystemRequirementAnalysisBodyEntityUD2.ID = -1;


                        //}
                        //if (SystemRequirementAnalysisBodyEntityUD2.RowState != "delete")
                        //{ }
                        SystemRequirementAnalysisBodyEntityUD2.IsGenerateObject = false;
                        SystemRequirementAnalysisBodyEntityUD2.RowState         = "add";
                        SystemRequirementAnalysisBodyEntityUD2.ModifyDate       = getTime;
                        //listUpdate2.Add(SystemRequirementAnalysisBodyEntityUD2);
                        SystemRequirementAnalysisBodyEntityUD2.Add();
                    }
                }

                //string delReviewMans = HttpContext.Current.Request.Form["DelID"];//获取窗体数据集合
                //if (!string.IsNullOrEmpty(delReviewMans))
                //{
                //    string[] delReviewManList = delReviewMans.Split(',');
                //    SystemRequirementAnalysisBodyEntity entity;
                //    foreach (string delReviewMan in delReviewManList)
                //    {
                //        entity = new SystemRequirementAnalysisBodyEntity();
                //        entity.ID = Convert.ToInt32(delReviewMan);
                //        entity.Delete();
                //    }
                //}//用时间来当标识,看是否被保存,将当前时间赋值给一个变量以防止变化
                //result = SystemRequirementAnalysisBodyEntityUD.db.CommitTran(listUpdate2.ToArray());
                result = true;
            }
            catch
            {
                result = false;
            }

            return(result);
        }