private void GetUpdatedData()
        {
            // 如果标记为删除的就不需要再更新了
            List <int> listUpdatedRows = new List <int>();

            for (int i = 0; i < m_listEditedRows.Count; ++i)
            {
                if (!m_listMaskedDeletedRows.Contains(m_listEditedRows[i]))
                {
                    // 如果不在删除列中,则需要更新
                    listUpdatedRows.Add(m_listEditedRows[i]);
                }
            }
            // 获取更新过的数据
            for (int i = 0; i < listUpdatedRows.Count; ++i)
            {
                CEntitySoilData soildata = new CEntitySoilData();
                //    voltage.VoltageID = long.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_VoltageID].Value.ToString());
                try
                {
                    soildata.StationID   = m_strStaionId;
                    soildata.DataTime    = DateTime.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_TimeCollected].Value.ToString());
                    soildata.reciveTime  = DateTime.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_ReciveTime].Value.ToString());
                    soildata.DVoltage    = Decimal.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_Voltage].Value.ToString());
                    soildata.MessageType = CEnumHelper.UIStrToMesssageType(base.Rows[listUpdatedRows[i]].Cells[CS_MsgType].Value.ToString());
                    soildata.ChannelType = CEnumHelper.UIStrToChannelType(base.Rows[listUpdatedRows[i]].Cells[CS_ChannelType].Value.ToString());
                    soildata.Voltage10   = float.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_V10].Value.ToString());
                    soildata.Moisture10  = float.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_M10].Value.ToString());

                    soildata.Voltage20  = float.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_V20].Value.ToString());
                    soildata.Moisture20 = float.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_M20].Value.ToString());

                    soildata.Voltage40  = float.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_V40].Value.ToString());
                    soildata.Moisture40 = float.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_M40].Value.ToString());

                    //  soildata.Voltage60 = float.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_V60].Value.ToString());
                    // soildata.Voltage60 = float.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_V60].Value.ToString());
                }
#pragma warning disable CS0168 // 声明了变量“e”,但从未使用过
                catch (Exception e)
#pragma warning restore CS0168 // 声明了变量“e”,但从未使用过
                {
                    this.Hide();
                    MessageBox.Show("请输入正确的墒情数据!");
                    this.Show();
                }
                // soildata.Moisture10 = Decimal.Parse();
                m_listUpdated.Add(soildata);
            }
            // 获取删除过的数据
            for (int i = 0; i < base.m_listMaskedDeletedRows.Count; ++i)
            {
                //     m_listDeleteVoltage.Add(long.Parse(base.Rows[m_listMaskedDeletedRows[i]].Cells[CS_VoltageID].Value.ToString()));
                m_listDeleteSoilDatas_StationId.Add(base.Rows[m_listMaskedDeletedRows[i]].Cells[CS_StationID].Value.ToString());
                m_listDeleteSoilDatas_StationDate.Add(base.Rows[m_listMaskedDeletedRows[i]].Cells[CS_TimeCollected].Value.ToString());
            }
            m_listEditedRows.Clear();        //清空此次记录
            m_listMaskedDeletedRows.Clear(); //清空标记为删除的记录
        }
        // 生成更新过的数据列表
        private void GetUpdatedData()
        {
            // 如果标记为删除的就不需要再更新了
            List <int> listUpdatedRows = new List <int>();

            for (int i = 0; i < m_listEditedRows.Count; ++i)
            {
                if (!m_listMaskedDeletedRows.Contains(m_listEditedRows[i]))
                {
                    // 如果不在删除列中,则需要更新
                    listUpdatedRows.Add(m_listEditedRows[i]);
                }
            }
            // 获取更新过的数据
            for (int i = 0; i < listUpdatedRows.Count; ++i)
            {
                CEntityWater water = new CEntityWater();
                //  water.WaterID = long.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_WaterID].Value.ToString());
                water.StationID    = m_strStaionId;
                water.TimeCollect  = DateTime.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_TimeCollected].Value.ToString());
                water.TimeRecieved = DateTime.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_TimeReceived].Value.ToString());
                water.WaterStage   = Decimal.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_WaterStage].Value.ToString());
                if (!base.Rows[listUpdatedRows[i]].Cells[CS_WaterFlow].Value.ToString().Equals(""))
                {
                    water.WaterFlow = Decimal.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_WaterFlow].Value.ToString());
                }
                else
                {
                    water.WaterFlow = null;
                }
                // 数据状态
                string tmpDataState = base.Rows[listUpdatedRows[i]].Cells[CS_DataState].Value.ToString();
                if (tmpDataState.Equals(CS_DataState_Normal))
                {
                    water.state = 1;
                }
                else if (tmpDataState.Equals(CS_DataState_AbNormal))
                {
                    water.state = 0;
                }
                water.MessageType = CEnumHelper.UIStrToMesssageType(base.Rows[listUpdatedRows[i]].Cells[CS_MsgType].Value.ToString());
                water.ChannelType = CEnumHelper.UIStrToChannelType(base.Rows[listUpdatedRows[i]].Cells
                                                                   [CS_ChannelType].Value.ToString());
                m_listUpdated.Add(water);
            }
            // 获取删除过的数据
            for (int i = 0; i < base.m_listMaskedDeletedRows.Count; ++i)
            {
                // m_listDeleteWaters.Add(long.Parse(base.Rows[m_listMaskedDeletedRows[i]].Cells[CS_WaterID].Value.ToString()));

                m_listDeleteWaters_StationId.Add(base.Rows[m_listMaskedDeletedRows[i]].Cells[CS_StationID].Value.ToString());
                m_listDeleteWaters_StationDate.Add(base.Rows[m_listMaskedDeletedRows[i]].Cells[CS_TimeCollected].Value.ToString());
            }
            m_listEditedRows.Clear();        //清空此次记录
            m_listMaskedDeletedRows.Clear(); //清空标记为删除的记录
        }
예제 #3
0
 /// <summary>
 /// 根据界面的数据,生成添加的实体类
 /// </summary>
 private void GenerateAdddedDate()
 {
     if (chk_Rain.CheckState == CheckState.Checked)
     {
         // 新建雨量记录
         m_entityRain              = new CEntityRain();
         m_entityRain.StationID    = m_currentStation.StationID;
         m_entityRain.TimeCollect  = dtp_CollectTime.Value;
         m_entityRain.TimeRecieved = dtp_TimeReceived.Value;
         m_entityRain.MessageType  = CEnumHelper.UIStrToMesssageType(cmb_DataType.Text);
         m_entityRain.ChannelType  = CEnumHelper.UIStrToChannelType(cmb_ChannelType.Text);
         //m_entityRain.PeriodRain = number_PeriodRain.Value;
         //m_entityRain.DayRain = number_DayRain.Value;
         m_entityRain.TotalRain = number_TotalRain.Value;
         m_entityRain.BState    = 1;//默认是正常的
     }
     if (chk_Water.CheckState == CheckState.Checked)
     {
         // 新建水位记录
         m_entityWater              = new CEntityWater();
         m_entityWater.StationID    = m_currentStation.StationID;
         m_entityWater.TimeCollect  = dtp_CollectTime.Value;
         m_entityWater.TimeRecieved = dtp_TimeReceived.Value;
         m_entityWater.MessageType  = CEnumHelper.UIStrToMesssageType(cmb_DataType.Text);
         m_entityWater.ChannelType  = CEnumHelper.UIStrToChannelType(cmb_ChannelType.Text);
         m_entityWater.WaterStage   = number_WaterStage.Value;
         m_entityWater.WaterFlow    = number_WaterFlow.Value;
         m_entityWater.state        = 1;
     }
     if (chk_Voltage.CheckState == CheckState.Checked)
     {
         // 新建电压记录
         m_entityVoltage              = new CEntityVoltage();
         m_entityVoltage.StationID    = m_currentStation.StationID;
         m_entityVoltage.TimeCollect  = dtp_CollectTime.Value;
         m_entityVoltage.TimeRecieved = dtp_TimeReceived.Value;
         m_entityVoltage.MessageType  = CEnumHelper.UIStrToMesssageType(cmb_DataType.Text);
         m_entityVoltage.ChannelType  = CEnumHelper.UIStrToChannelType(cmb_ChannelType.Text);
         m_entityVoltage.Voltage      = number_Voltage.Value;
         m_entityVoltage.state        = 1;
     }
 }
        // 生成更新过的数据列表
        private void GetUpdatedData()
        {
            // 如果标记为删除的就不需要再更新了
            List <int> listUpdatedRows = new List <int>();

            for (int i = 0; i < m_listEditedRows.Count; ++i)
            {
                if (!m_listMaskedDeletedRows.Contains(m_listEditedRows[i]))
                {
                    // 如果不在删除列中,则需要更新
                    listUpdatedRows.Add(m_listEditedRows[i]);
                }
            }

            // 获取更新过的数据
            for (int i = 0; i < listUpdatedRows.Count; ++i)
            {
                CEntityRain rain = new CEntityRain();
                rain.StationID    = m_strStaionId;
                rain.TimeCollect  = DateTime.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_TimeCollected].Value.ToString());
                rain.TimeRecieved = DateTime.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_TimeReceived].Value.ToString());
                if (!base.Rows[listUpdatedRows[i]].Cells[CS_DayRain].Value.ToString().Equals(""))
                {
                    rain.DayRain = Decimal.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_DayRain].Value.ToString());
                }
                else
                {
                    rain.DayRain = null;
                }
                if (!base.Rows[listUpdatedRows[i]].Cells[CS_PeriodRain].Value.ToString().Equals(""))
                {
                    rain.PeriodRain = Decimal.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_PeriodRain].Value.ToString());
                }
                else
                {
                    rain.PeriodRain = null;
                }
                rain.TotalRain   = Decimal.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_TotalRain].Value.ToString());
                rain.MessageType = CEnumHelper.UIStrToMesssageType(base.Rows[listUpdatedRows[i]].Cells[CS_MsgType].Value.ToString());
                rain.ChannelType = CEnumHelper.UIStrToChannelType(base.Rows[listUpdatedRows[i]].Cells[CS_ChannelType].Value.ToString());
                // 数据状态
                string tmpDataState = base.Rows[listUpdatedRows[i]].Cells[CS_DataState].Value.ToString();
                if (tmpDataState.Equals(CS_DataState_Normal))
                {
                    rain.BState = 1;
                }
                else if (tmpDataState.Equals(CS_DataState_AbNormal))
                {
                    rain.BState = 0;
                }
                else if (tmpDataState.Equals(CS_DataState_Warning))
                {
                    rain.BState = 2;
                }
                //   rain.RainID = long.Parse(base.Rows[listUpdatedRows[i]].Cells[CS_RainID].Value.ToString());
                m_listUpdated.Add(rain);
            }
            // 获取删除过的数据
            for (int i = 0; i < base.m_listMaskedDeletedRows.Count; ++i)
            {
                //m_listDeleteRains.Add(long.Parse(base.Rows[m_listMaskedDeletedRows[i]].Cells[CS_RainID].Value.ToString()));

                m_listDeleteRains_StationId.Add(base.Rows[m_listMaskedDeletedRows[i]].Cells[CS_StationID].Value.ToString());
                m_listDeleteRains_StationDate.Add(base.Rows[m_listMaskedDeletedRows[i]].Cells[CS_TimeCollected].Value.ToString());
            }
            // 清空编辑过的数据
            m_listEditedRows.Clear();
            m_listMaskedDeletedRows.Clear();   //清空此次记录
        }