Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="deviceid"></param>
        /// <returns></returns>
        static public DeviceClass CreateDevice(int deviceid)
        {
            DeviceClass c   = null;
            DataTable   tbl = DeviceDBI.GetDeviceDataTable(deviceid);

            if (tbl.Rows.Count > 0)
            {
                c = CreateDevice(tbl.Rows[0]);
            }
            return(c);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        static public DeviceCollection CreateDeviceCollection()
        {
            DeviceCollection dc  = new DeviceCollection();
            DataTable        tbl = DeviceDBI.GetDeviceDataView();

            foreach (DataRow row in tbl.Rows)
            {
                DeviceClass c = CreateDevice(row);
                dc.Add(c);
            }
            return(dc);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取年报表数据
        /// </summary>
        /// <param name="year"></param>
        /// <param name="device"></param>
        /// <param name="de">数据标识</param>
        /// <returns></returns>
        static public DataTable ExecuteYearDataTable(int year, DeviceClass device, DataEnum de)
        {
            if (device == null)
            {
                throw new ArgumentNullException("station");
            }

            int      deviceid = device.DeviceID;
            DateTime b        = new DateTime(year, 1, 1);
            DateTime e        = new DateTime(year + 1, 1, 1);
            string   s        = string.Format(
                "select * from tblDitchDataDay where deviceid = {0} and dt >= '{1}' and dt < '{2}' order by dt",
                deviceid, b, e);

            DataTable tbl       = DBI.GetDBI().ExecuteDataTable(s);
            DataTable destTable = CreateDestDataTable();

            //
            //
            foreach (DataRow row in tbl.Rows)
            {
                DateTime dt         = Convert.ToDateTime(row["dt"]);
                int      month      = dt.Month;
                int      day        = dt.Day;
                string   columnName = GetColumnName(de);
                int      value      = Convert.ToInt32(row[columnName]);

                int rowIndex = day - 1;
                // riqi 1 2 3 4 5 ... 12
                //
                int     colIndex = month;
                DataRow destRow  = destTable.Rows[rowIndex];
                destRow[colIndex] = value;
            }

            switch (de)
            {
            case DataEnum.WL:
            case DataEnum.Flux:
                DataTableHelper.AddAvgRow(destTable, 1, new object[] { "平均" });
                break;

            case DataEnum.Amount:
                DataTableHelper.AddSumRow(destTable, 1, new object[] { "合计" });
                break;

            default:
                break;
            }
            return(destTable);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="stationID"></param>
        /// <returns></returns>
        static public DeviceCollection CreateDeviceCollectionByStationID(int stationID)
        {
            DeviceCollection dc = new DeviceCollection();
            //int[] devicdIDs = DeviceDBI.GetDeviceIDsByStationID(stationID);
            //string s = SqlHelper.MakeInQueryCondition(devicdIDs);
            DataTable tbl = DeviceDBI.GetDeviceDataTableByStationID(stationID);

            foreach (DataRow row in tbl.Rows)
            {
                DeviceClass d = CreateDevice(row);
                dc.Add(d);
            }
            return(dc);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 获取年报表数据
        /// </summary>
        /// <param name="year"></param>
        /// <param name="device"></param>
        /// <param name="de">数据标识</param>
        /// <returns></returns>
        public static DataTable ExecuteYearDataTable(int year, DeviceClass device, DataEnum de)
        {
            if (device == null)
            {
                throw new ArgumentNullException("station");
            }

            int deviceid = device.DeviceID;
            DateTime b = new DateTime(year, 1, 1);
            DateTime e = new DateTime(year + 1, 1, 1);
            string s = string.Format(
                "select * from tblDitchDataDay where deviceid = {0} and dt >= '{1}' and dt < '{2}' order by dt",
                deviceid, b, e);

            DataTable tbl = DBI.GetDBI().ExecuteDataTable(s);
            DataTable destTable = CreateDestDataTable();
            //
            //
            foreach (DataRow row in tbl.Rows)
            {
                DateTime dt = Convert.ToDateTime(row["dt"]);
                int month = dt.Month;
                int day = dt.Day;
                string columnName = GetColumnName(de);
                int value = Convert.ToInt32(row[columnName ]);

                int rowIndex = day - 1;
                // riqi 1 2 3 4 5 ... 12
                //
                int colIndex = month;
                DataRow destRow = destTable.Rows[rowIndex];
                destRow[colIndex] = value;
            }

            switch (de)
            {
                case DataEnum.WL :
                case DataEnum.Flux :
                    DataTableHelper.AddAvgRow(destTable, 1, new object[] { "平均" });
                    break;
                case DataEnum.Amount :
                    DataTableHelper.AddSumRow(destTable, 1, new object[] { "合计" });
                    break;

                default:
                    break;
            }
            return destTable;
        }
Ejemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dataRow"></param>
        /// <returns></returns>
        private static DeviceClass CreateDevice(DataRow dataRow)
        {
            DeviceClass c = new DeviceClass();

            int    deviceID   = Convert.ToInt32(dataRow["DeviceID"]);
            string deviceKind = dataRow["DeviceKind"].ToString();
            string deviceType = dataRow["deviceType"].ToString();
            string remark     = dataRow["Remark"].ToString();


            c.DeviceID     = deviceID;
            c.DeviceKind   = deviceKind;
            c.DeviceType   = deviceType;
            c.DeviceRemark = remark;

            return(c);
        }
Ejemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="inOrOutTableName"></param>
        /// <param name="waterUserId"></param>
        /// <returns></returns>
        private static DeviceCollection CreateDeviceCollection(string inOrOutTableName, int waterUserId)
        {
            DeviceCollection ds = new DeviceCollection();
            string           s  = string.Format(
                @"select * from tblDevice 
                    where deleted = 0 and 
                        deviceid in (select deviceid from {0} where waterUserID = {1})",
                inOrOutTableName, waterUserId);

            DataTable tbl = DBI.GetDBI().ExecuteDataTable(s);

            foreach (DataRow row in tbl.Rows)
            {
                DeviceClass d = CreateDevice(row);
                ds.Add(d);
            }
            return(ds);
        }
Ejemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        static public FormulaCollection Create(DeviceClass device)
        {
            if (device == null)
            {
                throw new ArgumentNullException("device");
            }

            FormulaCollection fc  = new FormulaCollection();
            DataTable         tbl = FormulaDBI.GetDataTable(device.DeviceID);

            foreach (DataRow row in tbl.Rows)
            {
                Formula f = Create(row);
                f.Device = device;
                fc.Add(f);
            }
            return(fc);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dataRow"></param>
        /// <returns></returns>
        private static DeviceClass CreateDevice(DataRow dataRow)
        {
            DeviceClass c = new DeviceClass();

            int deviceID = Convert.ToInt32 (dataRow["DeviceID"]);
            string deviceKind = dataRow["DeviceKind"].ToString();
            string deviceType = dataRow["deviceType"].ToString();
            string remark = dataRow["Remark"].ToString();

            c.DeviceID = deviceID;
            c.DeviceKind = deviceKind;
            c.DeviceType = deviceType;
            c.DeviceRemark = remark;

            return c;
        }
Ejemplo n.º 10
0
 ///// <summary>
 ///// 
 ///// </summary>
 ///// <param name="d"></param>
 //private void AddTestFormula(DeviceClass d)
 //{
 //    for (int i = 0; i < 5; i++)
 //    {
 //        Formula f = new Formula();
 //        f.Begin = DateTime.Now;
 //        f.End = DateTime.Now;
 //        f.FormulaString = "1+1+2-4";
 //        d.FormulaCollection.Add(f);
 //    }
 //}
 /// <summary>
 /// 
 /// </summary>
 /// <param name="device"></param>
 private void BindFormula(DeviceClass device)
 {
     H.DataSource = device.FormulaCollection;
     H.Bind();
 }
Ejemplo n.º 11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="device"></param>
 private void BindAlarm(DeviceClass device)
 {
     if (device.DeviceAlarm != null)
     {
         if (device.DeviceAlarm.HasHighLimit)
         {
             this.txtAlarmHighLimit.Text = device.DeviceAlarm.HighLimit.ToString();
         }
     }
 }