Example #1
0
 public FHistory()
 {
     InitializeComponent();
     selectflag = new bool[5];
     T = new decimal[5];
     context = new DbTigerEntities();
 }
        private void ButtonDelClick(object sender, EventArgs e)
        {
            if (!_validForm) return;
            var currenuser = textBox_Unitid.Text;
            if (currenuser != "")
            {
                try
                {
                    using (var context = new DbTigerEntities())
                    {
                        try
                        {
                            var unit = context.unions
                                .First(i => i.UnitId == currenuser);
                            context.unions.Remove(unit);
                            context.SaveChanges();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.InnerException.ToString());
                        }

                    }
                }
                catch (Exception)
                {
                    //MessageBox.Show(ex.InnerException.ToString());
                }
            }
            MessageBox.Show(Resources.FNodeManager_button_Del_Click_);
            LoadData();
        }
        private void button_Del_Click(object sender, EventArgs e)
        {
            string currenuser =textBox_name.Text ;
             if (currenuser != "")
             {
                 try
                 {
                     using (var context = new DbTigerEntities())
                     {
                         try
                         {
                             logininfor logino = context.logininfors
                                                    .First(i => i.username == currenuser);
                             context.logininfors.Remove(logino);
                             context.SaveChanges();
                         }
                         catch (Exception ex)
                         {
                             MessageBox.Show(ex.InnerException.ToString());
                         }

                     }
                 }
                 catch (Exception)
                 {
                     //MessageBox.Show(ex.InnerException.ToString());
                 }
             }
             MessageBox.Show("该用户删除成功!");
             LoadData();
        }
        private void button_ADD_Click(object sender, EventArgs e)
        {
            if ((textBox_name.Text != "") && (textBox_password.Text != ""))
            {
                using (var context = new DbTigerEntities())
                {
                    try
                    {
                        DateTime now = DateTime.Now;
                        //DateTimeFormatInfo format = CultureInfo.CreateSpecificCulture("en-US").DateTimeFormat;
                        //format.DateSeparator = "-";
                        //format.ShortDatePattern = @"yyyy/MM/dd/hh/mm/ss";
                        logininfor logininforo = new logininfor
                        {
                            username = textBox_name.Text,
                            password = textBox_password.Text,
                            role = (short)comboBox_role.SelectedIndex
                        };
                        context.logininfors.Add(logininforo);
                        context.SaveChanges();
                        MessageBox.Show("该用户添加成功!");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.InnerException.ToString());
                    }

                }
            }

            LoadData();
        }
        private void ButtonAddClick(object sender, EventArgs e)
        {
            if (_validForm)
            {
                if ((textBox_Alias.Text != "") && (textBox_Unitid.Text != ""))
                {
                    using (var context = new DbTigerEntities())
                    {
                        try
                        {
                            var now = DateTime.Now;
                            //DateTimeFormatInfo format = CultureInfo.CreateSpecificCulture("en-US").DateTimeFormat;
                            //format.DateSeparator = "-";
                            //format.ShortDatePattern = @"yyyy/MM/dd/hh/mm/ss";
                            var unit = new union
                            {
                                UnitId = textBox_Unitid.Text,
                                alias = textBox_Alias.Text,
                                Aera_IrradiatedSum = float.Parse(textBox_AreaIrr.Text),
                                Flow_CollectorSys = float.Parse(textBox_Flow_CollectorSys.Text),
                                Flow_HeatUsing = float.Parse(textBox_Flow_HeatUsing.Text),
                                Auxiliary_power = float.Parse(textBox_Auxiliary_power.Text),
                                Volumn_HeatingBox = float.Parse(textBox_VolumHeat.Text),
                                Sum_SystemHeat = float.Parse(textBox_SystemHeat.Text),
                            };
                            context.unions.Add(unit);
                            context.SaveChanges();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.InnerException.ToString());
                        }

                    }
                }

                MessageBox.Show(Resources.FNodeManager_button_ADD_Click_);
                LoadData();
            }
        }
Example #6
0
        //********************************************
        //退出
        //********************************************
        private void FMainClosing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            //new StringBuilder(500);
            if (MessageBox.Show(Resources.FMain_FMainClosing_, Resources.FMain_中心参数设置ToolStripMenuItemClick_提示, MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
            {
                //MLog.InfoFormat("Application Stop logging  at {0}", DateTime.Now);
                //MLog.InfoFormat("________________________________");
                //如果服务正在启动,调用开发包函数使所有DTU下线并关闭服务
                if (ServStart == 1)
                {
                   ToolStripMenuItemStopService.PerformClick();
                }
                //减少数据绑定的绑定对象
                Global.Osystem.RemoveObserver(this);

                //遍历所有list元素
                foreach (var item in Global.DtuList)
                {
                    using (var context = new DbTigerEntities())
                    {
                        try
                        {
                            var c = context.unions.First(i => i.UnitId == item.Key);
                            c.Sum_SystemHeat = Global.SatisticList[item.Key].SystemHeat;//记录每个DTU本次数据到数据库
                            context.SaveChanges();

                        }
                        catch (Exception)
                        {

                        }
                    }
                }
                e.Cancel = false;
            }
            else
                e.Cancel = true;
            Environment.Exit(0);
        }
Example #7
0
        private static void StoreDtuState2Db()
        {
            using (var context = new DbTigerEntities())
            {
                //遍历所有list元素
                foreach (var item in Global.DtuList)
                {
                    try
                    {
                        //DateTime now = DateTime.Now;
                        //DateTimeFormatInfo format = CultureInfo.CreateSpecificCulture("en-US").DateTimeFormat;
                        //format.DateSeparator = "-";
                        //format.ShortDatePattern = @"yyyy/MM/dd/hh/mm/ss";

                        var unitstate = new unitstate
                        {
                            UnitId = item.Key,
                            DateTime_RecvDate = item.Value.RecvDate,//产生数据时时间
                            Temp_HeatingBox = item.Value.Field1[(ushort)(Field1No.TempHeatingBox)],
                            Temp_CollectorBox = item.Value.Field1[(ushort)(Field1No.TempCollectorBox)],
                            Temp_CollectorIn = item.Value.Field1[(ushort)(Field1No.TempCollectorIn)],
                            Temp_CollectorOut = item.Value.Field1[(ushort)(Field1No.TempCollectorOut)],
                            Temp_Ambient = item.Value.Field1[(ushort)(Field1No.TempAmbient)],
                            Humidity_Ambient = item.Value.Field1[(ushort)(Field1No.HumidityAmbient)],
                            Amount_Irradiated = item.Value.Field1[(ushort)(Field1No.AmountIrradiated)],
                            Amount_IrradiatedSum = item.Value.Field1[(ushort)(Field1No.AmountIrradiatedSum)],
                            Speed_Wind = item.Value.Field1[(ushort)(Field1No.SpeedWind)],
                        };
                        context.unitstates.Add(unitstate);
                        context.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.InnerException.ToString());
                    }

                }
            }
        }
Example #8
0
        private static void ComputeEveryStatistic()
        {
            var stopWatch = new Stopwatch();
            stopWatch.Start();
            using (var context = new DbTigerEntities())
            {
                //遍历所有list元素
                foreach (var item in Global.DtuList)
                {
                    try
                    {
                        var single = new singleunitstatistic
                        {
                            UnitId = item.Key,
                            DateTime_Statics = item.Value.RecvDate,//产生数据时时间
                            //c*m*delta(T)
                            System_heat = (Global.ParameterList[item.Key].SystemHeat)+
                            (Global.ParameterList[item.Key].DeltaTime)*(Global.DtuList[item.Key].Field1[(ushort)Field1No.FlowCollectorSys]),

                        };
                        Global.SatisticList[item.Key].SystemHeat = single.System_heat;//保存统计数据到全局状态表
                        context.singleunitstatistics.Add(single);
                        context.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.InnerException.ToString());
                    }

                }

            }
            stopWatch.Stop();
        }
 private void LoadData()
 {
     using (var ctx = new DbTigerEntities())
     {
         dataGridView1.DataSource = ctx.unions.ToList();
     }
 }
Example #10
0
        private void ButtonModifyClick(object sender, EventArgs e)
        {
            if (_validForm)
            {
                using (var context = new DbTigerEntities())
                {
                    try
                    {
                        var c = context.unions.First(i => i.UnitId == textBox_Unitid.Text);
                        c.alias = textBox_Alias.Text;
                        c.Aera_IrradiatedSum = float.Parse(textBox_AreaIrr.Text);
                        c.Flow_CollectorSys = float.Parse(textBox_Flow_CollectorSys.Text);
                        c.Flow_HeatUsing = float.Parse(textBox_Flow_HeatUsing.Text);
                        c.Auxiliary_power = float.Parse(textBox_Auxiliary_power.Text);
                        c.Volumn_HeatingBox = float.Parse(textBox_VolumHeat.Text);
                        context.SaveChanges();

                    }
                    catch (Exception)
                    {

                    }
                    finally
                    {
                        Global.ParameterList[(textBox_Unitid.Text)].UpateParameterObject(textBox_Unitid.Text,
                                                                                         float.Parse(textBox_AreaIrr.Text),
                                                                                         float.Parse(textBox_Auxiliary_power.Text),
                                                                                         float.Parse(textBox_Flow_CollectorSys.Text),
                                                                                         float.Parse(textBox_Flow_HeatUsing.Text),
                                                                                         float.Parse(textBox_VolumHeat.Text));

                    }

                }
                MessageBox.Show(Resources.FNodeManager_button_Modify_Click_);
                LoadData();
            }
        }
Example #11
0
        private void button_ModifyRole_Click(object sender, EventArgs e)
        {
            using (var context = new DbTigerEntities())
            {
                try
                {
                    logininfor c = context.logininfors
                                   .First(i => i.username == textBox_name.Text);
                    c.role =(short)comboBox_role.SelectedIndex;
                    context.SaveChanges();
                }
                catch (Exception)
                {

                }

            }
            MessageBox.Show("该用户权限修改成功!");
            LoadData();
        }
Example #12
0
        private void button_Modify_Click(object sender, EventArgs e)
        {
            using (var context = new DbTigerEntities())
             {
                  try
                  {
                     logininfor c = context.logininfors
                                    .First(i => i.username == textBox_name.Text);
                        c.password = textBox_password.Text;
                        context.SaveChanges();
                    }
                     catch (Exception)
                    {

                    }

             }
             MessageBox.Show("该用户密码修改成功!");
             LoadData();
        }