Beispiel #1
0
        public ProjectDetails getProjectDetail(int projIdx)
        {
            ProjectDetails project = new ProjectDetails();

            string  strSql = string.Format("select * from projects where id={0}", projIdx);
            DataSet ds     = SQLiteHelper.ExecuteDataSet(STR_CONNECTION, strSql, null);

            project.Project = code.DecodeOneProjectByDb(ds.Tables[0].Rows[0]);

            strSql = string.Format("select * from componentView where projIdx={0}", projIdx);
            DataSet dscomps = SQLiteHelper.ExecuteDataSet(STR_CONNECTION, strSql, null);

            strSql = string.Format("select * from lineFoot where footType={0}", (int)enumComponentType.NormalComponent);
            DataSet dsFoots = SQLiteHelper.ExecuteDataSet(STR_CONNECTION, strSql, null);

            project.elementList = code.DecodeElementsByDb(dscomps, dsFoots, false);

            strSql = string.Format("select * from lineLink where project={0}", projIdx);
            DataSet dsLines = SQLiteHelper.ExecuteDataSet(STR_CONNECTION, strSql, null);

            project.linesList = code.DecodeElementLineByDb(dsLines);

            strSql = string.Format("select * from netPoints where projIdx={0}", projIdx);
            DataSet dsPoints = SQLiteHelper.ExecuteDataSet(STR_CONNECTION, strSql, null);

            project.pointsList = code.DecodeNetPointsByDb(dsPoints);

            project.footsList = this.GetPinsInfo(projIdx, -1);

            return(project);
        }
Beispiel #2
0
        public int InsertNewProject(ProjectDetails project)
        {
            ProjectInfo baseInfo = project.Project;
            string      strSql   = string.Format(@"insert into projects (name,createtime,updatetime,chips,desc,x0,y0) 
                                                values ('{0}','{1}','{2}','{3}','{4}',{5},{6});select last_insert_rowid();",
                                                 baseInfo.Name, baseInfo.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), baseInfo.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss"), baseInfo.Chips, baseInfo.Description, baseInfo.OriginX, baseInfo.OriginY);
            object objIdx  = SQLiteHelper.ExecuteScalar(STR_CONNECTION, strSql);
            int    projIdx = Convert.ToInt32(objIdx);

            if (projIdx <= 0)
            {
                return(projIdx);
            }

            if (project.elementList.Count > 0)
            {
                strSql = string.Empty;
                foreach (ElementInfo item in project.elementList)
                {
                    strSql += string.Format(@"insert into componentView (projIdx,component,name,locX,locY,width,height,backColor,backImage,innerIdx,type) 
                                        values ({0},{1},'{2}',{3},{4},{5},{6},{7},'{8}',{9},{10});",
                                            projIdx, item.Component, item.Name, item.Location.X, item.Location.Y, item.Size.Width, item.Size.Height, item.BackColor.ToArgb(), item.BackImage, item.InnerIdx, (int)item.FootType);
                }
                objIdx = SQLiteHelper.ExecuteNonQuery(STR_CONNECTION, strSql);
                if (Convert.ToInt32(objIdx) != project.elementList.Count)
                {
                    return(-1);
                }
            }

            if (project.linesList.Count > 0)
            {
                strSql = string.Empty;
                foreach (ElementLine item in project.linesList)
                {
                    strSql += string.Format(@"insert into lineLink (project,name,oneFoot,otherFoot,locX,locY,locOtherX,locOtherY,color,oneElement,otherElement) 
                                        values ({0},'{1}',{2},{3},{4},{5},{6},{7},'{8}',{9},{10});",
                                            projIdx, item.Name, item.oneFoot, item.otherFoot, item.LocX, item.LocY, item.LocOtherX, item.LocOtherY, item.Color.ToArgb(), item.oneElement, item.otherElement);
                }
                objIdx = SQLiteHelper.ExecuteNonQuery(STR_CONNECTION, strSql);
                if (Convert.ToInt32(objIdx) != project.linesList.Count)
                {
                    return(-1);
                }
            }

            if (project.footsList.Count > 0)
            {
                strSql = string.Empty;
                foreach (LineFootView lineItem in project.footsList)
                {
                    strSql += string.Format("insert into lineFootView (projIdx,component,innerIdx,name,pinsType,footIdx,innerId) values ({0},{1},{2},'{3}',{4},{5},{6});",
                                            projIdx, lineItem.Component, lineItem.Element, lineItem.PinsName, (int)lineItem.PinsType, lineItem.Foot, lineItem.InnerID);
                }
                objIdx = SQLiteHelper.ExecuteNonQuery(STR_CONNECTION, strSql);
                if (Convert.ToInt32(objIdx) != project.footsList.Count)
                {
                    return(-1);
                }
            }

            if (project.pointsList.Count > 0)
            {
                strSql = string.Empty;
                foreach (NetPoint pointItem in project.pointsList)
                {
                    strSql += string.Format("insert into netPoints (projIdx,x,y,status) values ({0},{1},{2},{3});",
                                            projIdx, pointItem.X, pointItem.Y, (int)pointItem.Type);
                }
                objIdx = SQLiteHelper.ExecuteNonQuery(STR_CONNECTION, strSql);
                if (Convert.ToInt32(objIdx) != project.pointsList.Count)
                {
                    return(-1);
                }
            }

            return(projIdx);
        }