示例#1
0
        /// <summary>
        /// 首先要找到原油信息表,没有原油信息表 则没必要继续下去
        /// </summary>
        /// <param name="oilA"></param>
        /// <param name="ds"></param>
        /// <param name="oilInfoItemCode"></param>
        /// <returns></returns>
        private static OilInfoEntity findOilInfoTalbe(DataSet ds, List <string> oilInfoItemCode)
        {
            OilInfoEntity oilA = new OilInfoEntity();

            #region 找到原油信息表

            string itemCode = string.Empty;

            foreach (DataTable table in ds.Tables)
            {
                int[] firstCode = new int[2] {
                    -1, -1
                };
                for (int r_num = 0; r_num < table.Rows.Count; r_num++)
                {
                    for (int c_num = 0; c_num < table.Columns.Count; c_num++)
                    {
                        string cellContent = table.Rows[r_num][c_num].ToString();
                        cellContent = Units.ToDBC(cellContent);//单元格内容

                        if (!cellContent.Equals("CLA") && oilInfoItemCode.Contains(cellContent))
                        {
                            //原油信息表 第一个代码
                            firstCode[0] = r_num;
                            firstCode[1] = c_num;

                            for (int i = firstCode[0]; i < table.Rows.Count; i++)
                            {
                                itemCode = table.Rows[i][firstCode[1]].ToString().Trim();
                                itemCode = Units.ToDBC(itemCode);
                                string value = table.Rows[i][firstCode[1] + 1].ToString().Trim();
                                value = Units.ToDBC(value);
                                OilBll.oilInfoAddItem(ref oilA, itemCode, value);
                            }
                            oilA.ID = OilBll.saveInfo(oilA);

                            if (oilA.ID == -1)
                            {
                                return(oilA);
                            }
                        }
                        if (firstCode[0] != -1)
                        {
                            break;
                        }
                    }
                    if (firstCode[0] != -1)
                    {
                        break;
                    }
                }
                if (firstCode[0] != -1)
                {
                    break;
                }
            }
            #endregion

            return(oilA);
        }