Ejemplo n.º 1
0
        private int AddNewInterInfo()
        {
            int resCount = 0;

            if (this.radGridView1.RowCount < 1)
            {
                MessageBox.Show("没有可以提交的数据!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(0);
            }
            if (!CheckValid())
            {
                return(0);
            }
            int beforeInsertCount = plugLibraryDetailManager.GetRowCount();
            int excuteCount       = 0;
            //submit data
            int iRow = 1;
            int id   = 0;
            List <InterfaceInfoLibrary> libList = new List <InterfaceInfoLibrary>();

            foreach (var rowInfo in this.radGridView1.Rows)
            {
                var plugNo        = rowInfo.Cells[1].Value.ToString();
                var pinName       = rowInfo.Cells[2].Value.ToString();
                var testMethod    = rowInfo.Cells[3].Value.ToString();
                var stitchNo      = rowInfo.Cells[4].Value.ToString();
                var IsAddNewRow   = rowInfo.Cells[7].Value;
                var remark        = "";
                var connectorName = "";
                if (rowInfo.Cells[6].Value != null)
                {
                    remark = rowInfo.Cells[6].Value.ToString();
                }
                if (rowInfo.Cells[5].Value != null)
                {
                    connectorName = rowInfo.Cells[5].Value.ToString();
                }

                #region TPlugLibraryDetail
                InterfaceInfoLibrary plugLibraryDetail = new InterfaceInfoLibrary();
                plugLibraryDetail.ID               = CableTestManager.Common.TablePrimaryKey.InsertInterfaceLibPID() + id;
                plugLibraryDetail.InterfaceNo      = plugNo;
                plugLibraryDetail.ContactPointName = pinName;
                if (testMethod == TWO_WIRE_METHOD)
                {
                    plugLibraryDetail.MeasureMethod = "2";
                }
                else if (testMethod == FOUR_WIRE_METHOD)
                {
                    plugLibraryDetail.MeasureMethod = "4";
                }
                plugLibraryDetail.SwitchStandStitchNo = stitchNo;
                plugLibraryDetail.Remark        = remark;
                plugLibraryDetail.Operator      = LocalLogin.currentUserName;
                plugLibraryDetail.ConnectorName = connectorName;
                plugLibraryDetail.ContactPoint  = iRow.ToString();
                #endregion

                //新增数据
                if (IsAddNewRow != null)
                {
                    //if (IsCanInsertOrUpdate(false, -1, plugNo, pinName, stitchNo) == InterfaceExTipEnum.InterfacePoint_NotExistAndStitch_NoExist)
                    //{
                    //plugLibraryDetailManager.Insert(plugLibraryDetail);
                    libList.Add(plugLibraryDetail);
                    iRow++;
                    id++;
                    //}
                }
            }

            resCount = plugLibraryDetailManager.Insert(libList);
            return(resCount);
        }