Exemplo n.º 1
0
 public static List <PF> LoadPfs()
 {
     using (jhbEntities ctx = new jhbEntities())
     {
         return((from g in ctx.PFs orderby g.派发编号 descending select g).ToList());
     }
 }
Exemplo n.º 2
0
        private void wt_update()  // 插入时候更新记录
        {
            using (jhbEntities ctx = new jhbEntities())
            {
                var x    = (from g in ctx.WTs where g.问题编号 == Rec_info.问题编号 select g).First();
                var enty = ctx.Entry(x).Entity;
                enty.备注   = Rec_info.备注;
                enty.存在问题 = Rec_info.存在问题.Trim();
                enty.发现时间 = Rec_info.发现时间.Value.Date;
                if (Rec_info.检查人 != null)
                {
                    enty.检查人 = Rec_info.检查人.Trim();
                }

                if (Rec_info.受理单位 != null)
                {
                    enty.受理单位 = Rec_info.受理单位.Trim();
                }
                enty.天窗需求     = Rec_info.天窗需求;
                enty.销记       = Rec_info.销记;
                enty.严重程度     = Rec_info.严重程度;
                enty.lastEdit = TodayBincode;
                enty.OpTrack  = "UP";
                //Console.WriteLine("更新---");
                ctx.SaveChangesAsync();
                //ctx.SaveChanges();
            }
        }
Exemplo n.º 3
0
 public static List <TZD> LoadTzds()
 {
     using (jhbEntities ctx = new jhbEntities())
     {
         return((from g in ctx.TZDs orderby g.流水号 descending select g).ToList());
     }
 }
Exemplo n.º 4
0
        private void mainGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            WT     x      = (WT)mainGrid.SelectedValue;
            string pfSate = string.Empty;

            if (x != null)
            {
                using (jhbEntities ctx = new jhbEntities())
                {
                    List <PF> pfInfo = (from g in ctx.PFs
                                        where g.问题编号 == x.问题编号
                                        orderby g.派发日期 descending
                                        select g).ToList();
                    if (pfInfo.Count() > 0)
                    {
                        PF singlePf = (from g in pfInfo select g).First();
                        g_var.Bar.OtherTip =
                            string.Format("{0}#记录最后一次派发日期:{1}({2})   共派发过{3}次!",
                                          singlePf.问题编号,
                                          singlePf.派发日期.Value.ToString("yyyy年M月d日"),
                                          myFuc.IsthisWeek(singlePf.派发日期.Value),
                                          pfInfo.Count()
                                          );
                    }
                    else
                    {
                        g_var.Bar.OtherTip = "未派发!";
                    }
                }
            }
        }
Exemplo n.º 5
0
 private void set_main_rec_mode(string zn, bool flag) // 输入时 排列主窗显示
 {
     using (jhbEntities ctx = new jhbEntities())
     {
         var x = from g in ctx.WTs where g.站名 == zn && g.销记 == flag orderby g.问题编号 descending select g;
         mainGrid.ItemsSource = x.ToList();
     }
 }
Exemplo n.º 6
0
 public wtReInfo() //构造函数
 {
     using (jhbEntities ctx = new jhbEntities())
     {
         _str_checker = (from j in ctx.WTs select j.检查人).Distinct().ToList();
         _str_eqName  = (from j in ctx.WTs select j.设备名称).Distinct().ToList();
         _str_unit    = (from j in ctx.WTs select j.受理单位).Distinct().ToList();
     }
 }
Exemplo n.º 7
0
 public void  setListInfo(string zhName) //指定站名过滤 文本搜索.
 {
     using (jhbEntities ctx = new jhbEntities())
     {
         _str_checker = (from j in ctx.WTs where j.站名 == zhName select j.检查人).Distinct().ToList();
         _str_eqName  = (from j in ctx.WTs where j.站名 == zhName select j.设备名称).Distinct().ToList();
         _str_unit    = (from j in ctx.WTs where j.站名 == zhName select j.受理单位).Distinct().ToList();
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// 传入 唯一索引 及 记录名
        /// </summary>

        public static void del_rec(Int64 id, string table_name)
        {
            if (MessageBox.Show("确定删除本条记录?", "警告!", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No) == MessageBoxResult.No)
            {
                return;
            }
            using (jhbEntities ctx = new jhbEntities())
            {
                switch (table_name)
                {
                case "wt":
                    var e1 = (from g in ctx.WTs where g.问题编号 == id select g).First();
                    ctx.WTs.Remove(e1);
                    ctx.SaveChanges();
                    break;

                case "pf":
                    var e2 = (from g in ctx.PFs where g.派发编号 == id select g).First();
                    //删除派发, 记录站名,派发日期,存在问题  转去删除以派发日期为条件的tzd里面的 存在问题.
                    var enTzd = (from g in ctx.TZDs
                                 where g.派单日期.Value == e2.派发日期.Value && g.站名 == e2.站名
                                 orderby g.流水号 descending
                                 select g).First();

                    string tmp_wtdetail = enTzd.记录.Replace("\n" + "^" + e2.设备名称 + ": " + e2.存在问题, "");



                    if (tmp_wtdetail.Replace("\n", string.Empty) == string.Empty || tmp_wtdetail == null)
                    {
                        ctx.TZDs.Remove(enTzd);
                    }
                    else
                    {
                        ctx.Entry(enTzd).Entity.记录 = tmp_wtdetail;
                    }

                    ctx.PFs.Remove(e2);
                    ctx.SaveChanges();
                    break;

                case "tzd":
                    var e3 = (from g in ctx.TZDs where g.流水号 == id select g).First();
                    //根据tzd里面的站名和派单日期. 删除派发的记录项目.
                    var enPf = from g in ctx.PFs
                               where g.站名 == e3.站名 && g.派发日期.Value == e3.派单日期.Value && g.受理单位 == e3.受理单位
                               select g;
                    foreach (var item in enPf)
                    {
                        ctx.PFs.Remove(item);
                    }
                    ctx.TZDs.Remove(e3);
                    ctx.SaveChanges();
                    break;
                }
            }
        }
Exemplo n.º 9
0
 public static List <WT> LoadWts()
 {
     using (jhbEntities ctx = new jhbEntities())
     {
         List <WT> tmp = (from g in ctx.WTs orderby g.问题编号 descending select g).ToList();
         g_var.Bar.Total = tmp.Count();
         return(tmp);
     }
 }
Exemplo n.º 10
0
        private void showAll_Loaded(object sender, RoutedEventArgs e)
        {
            using (jhbEntities ctx = new jhbEntities())
            {
                wts  = (from g in ctx.WTs orderby g.站名 select g).ToList();
                pfs  = (from g in ctx.PFs orderby g.站名 select g).ToList();
                tzds = (from g in ctx.TZDs orderby g.站名 select g).ToList();

                showAll.ItemsSource = wts;
            }
        }
Exemplo n.º 11
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            using (jhbEntities ctx = new jhbEntities())
            {
                all_pf           = ctx.PFs.ToList();
                pfZn.ItemsSource = (from g in all_pf select g.站名).Distinct().ToList();
                znList           = all_pf;
                s_list           = all_pf;
                e_list           = all_pf;
                tmp_list         = all_pf;

                showSelectPfGrid.ItemsSource = all_pf;
            }
        }
Exemplo n.º 12
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (x2.Text == null || x2.Text == string.Empty)
            {
                Valid_Ani va = new Valid_Ani();
                Ani_x2.BeginAnimation(SolidColorBrush.ColorProperty, va.color_Ani);
                return;
            }
            if (x3.Text == null || x2.Text == string.Empty)
            {
                Valid_Ani vb = new Valid_Ani();
                Ani_x3.BeginAnimation(SolidColorBrush.ColorProperty, vb.color_Ani);
                return;
            }
            if (x4.SelectedDate == null || x4.Text == string.Empty)
            {
                Valid_Ani vc = new Valid_Ani();
                Ani_x4.BeginAnimation(SolidColorBrush.ColorProperty, vc.color_Ani);
                return;
            }
            using (jhbEntities ctx = new jhbEntities())
            {
                var wt = (from g in ctx.WTs where g.站名 == _zn && g.问题编号 == _wtid select g).Single();
                ctx.Entry(wt).Entity.销记时间     = x4.SelectedDate.Value.Date;
                ctx.Entry(wt).Entity.完成情况     = x1.Text;
                ctx.Entry(wt).Entity.整治情况     = x2.Text;
                ctx.Entry(wt).Entity.整治负责人    = x3.Text;
                ctx.Entry(wt).Entity.lastEdit = myFuc.getNowDateHashcode();
                ctx.Entry(wt).Entity.销记       = true;

                ctx.Entry(wt).Entity.OpTrack = "X";
                g_var.g_xj_flag = true; //窗口返回...
                g_var.g_chg_wt  = ctx.Entry(wt).Entity;


                var pf = from g in ctx.PFs where g.站名 == _zn && g.问题编号 == _wtid select g;
                foreach (var pfitem in pf)
                {
                    ctx.Entry(pfitem).Entity.ver1 = x4.SelectedDate.Value.Date.ToString("M月d日"); //销记时间
                    ctx.Entry(pfitem).Entity.ver2 = x1.Text;                                     //完成情况
                    ctx.Entry(pfitem).Entity.ver3 = x2.Text;                                     //整治情况
                    ctx.Entry(pfitem).Entity.var4 = x3.Text;                                     //负责人
                }

                ctx.SaveChanges();
            }
            this.Close();
        }
Exemplo n.º 13
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     using (jhbEntities ctx = new jhbEntities())
     {
         List <string> unit_info = (from g in ctx.WTs where g.站名 == _Zn select g.受理单位).Distinct().ToList();
         List <string> fix_info  = (from g in ctx.WTs where g.站名 == _Zn select g.整改方案).Distinct().ToList();
         pdUnit.ItemsSource  = unit_info.TakeWhile <string>(r => r != string.Empty);
         PlanFix.ItemsSource = fix_info.TakeWhile <string>(r => r != string.Empty);
         //根据编号(唯一)返回一条记录.
         _wt          = (from g in ctx.WTs where g.问题编号 == _Id select g).First();
         pdUnit.Text  = _wt.受理单位;
         PlanFix.Text = _wt.整改方案;
         run_1.Text   = string.Format("设备名称:   {0}", _wt.设备名称);
         run_2.Text   = string.Format("存在问题:   {0}", _wt.存在问题);
         run_3.Text   = string.Format("受理单位:   {0}", _wt.受理单位);
     }
 }
Exemplo n.º 14
0
        private void GridUpdate(string tableName)  // 读数据库, 刷新相应的表
        {
            switch (tableName)
            {
            case "wt":
                mainGrid.ItemsSource = null;
                using (jhbEntities ctx1 = new jhbEntities())
                {
                    AllWT = (from g in ctx1.WTs
                             orderby g.发现时间 descending
                             select g).ToList();
                    mainGrid.ItemsSource = AllWT.Where(i => i.销记 == false).ToList();
                }
                break;

            case "pf":
                pfDetial.ItemsSource = null;
                using (jhbEntities ctx2 = new jhbEntities())
                {
                    AllPF = (from g in ctx2.PFs
                             orderby g.派发日期 descending
                             select g).ToList();
                    pfDetial.ItemsSource = AllPF;
                }
                break;

            case "tzd":
                TzdDetial.ItemsSource = null;
                using (jhbEntities ctx3 = new jhbEntities())
                {
                    AllTZD = (from g in ctx3.TZDs
                              orderby g.派单日期 descending
                              select g).ToList();
                    TzdDetial.ItemsSource = AllTZD;
                }
                break;
            }
            List <DateTime?> pfDt = (from g in AllPF orderby g.派发日期 descending select g.派发日期).Distinct().ToList();

            this.pfSelect.ItemsSource = pfDt;
            List <DateTime?> tzdDt = (from g in AllTZD orderby g.派单日期 descending select g.派单日期).Distinct().ToList();

            this.tzdSelect.ItemsSource = tzdDt;
        }
Exemplo n.º 15
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     using (jhbEntities ctx = new jhbEntities())
     {
         var pfs = from g in ctx.PFs where g.问题编号 == _indx orderby g.派发编号 descending select g;
         cnt.Text = string.Format("派发次数:  {0}", pfs.Count());
         foreach (var item in pfs)
         {
             string tmpTx = string.Format("通知日期:{0}   计划处理日期:{1}    受理单位:  {2}",
                                          item.派发日期.Value.ToString("yyyy年M月d日"),
                                          item.计划时间.Value.ToString("yyyy年M月d日"),
                                          item.受理单位
                                          );
             Run       r  = new Run(tmpTx);
             Paragraph p  = new Paragraph(r);
             ListItem  ls = new ListItem(p);
             Lst.ListItems.Add(ls);
         }
     }
 }
Exemplo n.º 16
0
        private void wt_insert_new()  //插入新记录
        {
            using (jhbEntities ctx = new jhbEntities())
            {
                WT wt_in = new WT();
                wt_in.站名   = Rec_info.站名.Trim();
                wt_in.设备名称 = Rec_info.设备名称.Trim();
                wt_in.存在问题 = Rec_info.存在问题;
                wt_in.发现时间 = Rec_info.发现时间.Value.Date;
                if (Rec_info.检查人 != null)
                {
                    wt_in.检查人 = Rec_info.检查人.Trim();
                }
                else
                {
                    wt_in.检查人 = string.Empty;
                }

                wt_in.天窗需求 = Rec_info.天窗需求;
                wt_in.严重程度 = Rec_info.严重程度;
                if (Rec_info.受理单位 != null)
                {
                    wt_in.受理单位 = Rec_info.受理单位.Trim();
                }
                else
                {
                    wt_in.设备名称 = string.Empty;
                }
                wt_in.备注       = Rec_info.备注;
                wt_in.销记       = false;
                wt_in.lastEdit = myFuc.getNowDateHashcode();
                wt_in.OpTrack  = "NE";
                ctx.WTs.Add(wt_in);
                ctx.SaveChangesAsync();
                //Console.WriteLine("----插入新记录");
                //ctx.SaveChanges();
            }
        }
Exemplo n.º 17
0
        public static WT g_chg_wt    = new WT(); // 改变的行记录. 用于刷新
        public static void tableValid()
        {
            using (jhbEntities ctx = new jhbEntities())
            {
                Bar.Total = ctx.WTs.Count();

                foreach (var item in ctx.WTs)
                {
                    DateTime dtLast = DateTime.FromBinary(item.lastEdit.Value);
                    DateTime dtNow  = DateTime.FromBinary(myFuc.getNowDateHashcode());
                    int      days   = myFuc.diffDays(dtLast, dtNow);
                    if (Math.Abs(days) > 30)
                    {
                        item.OpTrack = "•••";
                    }
                    else
                    {
                        item.OpTrack = days.ToString();
                    }
                }
                ctx.SaveChanges();
            }
        }
Exemplo n.º 18
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            using (jhbEntities ctx = new jhbEntities())
            {
                _wt = (from g in ctx.WTs
                       where g.问题编号 == _wtid && g.站名 == _zn
                       select g).Single();
                try
                {
                    var tmp_pf = (from g in ctx.PFs
                                  where g.问题编号 == _wtid
                                  orderby g.派发编号 descending
                                  select g);
                    if (tmp_pf.Count() > 0)
                    {
                        _pf = tmp_pf.First();
                    }
                    else
                    {
                        _pf = null;
                    }
                }
                catch (Exception err)
                {
                    Console.WriteLine(err.Message);
                }


                var man = (from g in ctx.WTs
                           where g.站名 == _zn
                           select g.整治负责人).Distinct();
                //Replace("\r", string.Empty).Replace("\n", string.Empty)
                var state = (from g in ctx.WTs where g.站名 == _zn select g.整治情况).Distinct();
                foreach (var ix in man)
                {
                    if (ix != null)
                    {
                        string tx = ix.Replace("\r", string.Empty).Replace("\n", string.Empty);
                        if (tx != string.Empty)
                        {
                            x3man.Add(tx);
                        }
                    }
                }
                foreach (var iy in state)
                {
                    if (iy != null)
                    {
                        string ty = iy.Replace("\r", string.Empty).Replace("\n", string.Empty);
                        if (ty != string.Empty)
                        {
                            x2state.Add(ty);
                        }
                    }
                }
                x3.ItemsSource = x3man.Distinct();
                x2.ItemsSource = x2state.Distinct();
                wtTip.Content  = string.Format("{0}站 => {1}: {2}", _wt.站名, _wt.设备名称, _wt.存在问题);
                if (_pf == null)
                {
                    pfTip.Content = "没有派发信息!";
                }
                else
                {
                    pfTip.Content = string.Format("[{0}]通知 [{1}] 处理.", _pf.派发日期.Value.ToString("yyyy年M月d日"), _pf.受理单位);
                }
            }
        }
Exemplo n.º 19
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (!pf_input_valid())
            {
                return;
            }
            //--------------- 验证完成后, 需要把日期格式统一转成约定格式

            //快照 输入字段
            DateTime?pd_dt   = pdDate.SelectedDate.Value.Date;
            DateTime?plan_dt = planDate.SelectedDate.Value.Date;

            //---------------
            using (jhbEntities ctx = new jhbEntities())
            {
                var en_wt   = (from g in ctx.WTs where g.问题编号 == _Id select g).Single(); //唯一记录., 记录编号检索
                var enty_wt = ctx.Entry(en_wt).Entity;
                enty_wt.lastEdit = myFuc.getNowDateHashcode();
                enty_wt.受理单位     = pdUnit.Text;
                enty_wt.整改方案     = PlanFix.Text;
                enty_wt.OpTrack  = "PF";
                enty_wt.rev1     = pd_dt.Value.ToString("yyyy年M月d日"); //记录最后一次派发日期.
                //--------------- 生成派发表.  同一天, 同站名, 同设备问题, 同受理单位 视为更新!  g.派发日期.Value - pd_dt.Value)
                var en_pf = from g in ctx.PFs
                            where g.站名 == _Zn && g.问题编号 == _Id && g.派发日期 == pd_dt
                            select g;

                switch (en_pf.Count())
                {
                case 0:     //新生
                    PF nPf = new PF();
                    nPf.lastEdit = myFuc.getNowDateHashcode();
                    nPf.存在问题     = _wt.存在问题;
                    nPf.计划时间     = plan_dt; //planDate.Text.ToString("yyyy-M-d")
                    nPf.派发日期     = pd_dt;   // this.pdDate.Text;
                    nPf.设备名称     = _wt.设备名称;
                    nPf.受理单位     = pdUnit.Text;
                    nPf.天窗需求     = _wt.天窗需求;
                    nPf.问题编号     = _Id;
                    nPf.站名       = _Zn;
                    nPf.保留2      = PlanFix.Text;
                    ctx.PFs.Add(nPf);
                    // int x = await ctx.SaveChangesAsync();
                    //ctx.SaveChanges();

                    break;

                case 1:                                                // 更新
                    var pf_entry_row = en_pf.Single();                 //实体
                    var entry        = ctx.Entry(pf_entry_row).Entity; // 入口
                    entry.lastEdit = myFuc.getNowDateHashcode();
                    entry.存在问题     = _wt.存在问题;
                    entry.计划时间     = plan_dt;  //planDate.Text.ToString("yyyy-M-d")

                    entry.设备名称 = _wt.设备名称;
                    entry.受理单位 = pdUnit.Text;
                    entry.天窗需求 = _wt.天窗需求;
                    entry.保留2  = PlanFix.Text;
                    //ctx.SaveChanges();

                    break;
                }


                //---------- 生成通知单表 -- 根据日期,站名,受理单位三个记录条件找到记录, 更新记录字段..
                var en_tzd = from g in ctx.TZDs
                             where g.派单日期 == pd_dt && g.站名 == _Zn && g.受理单位 == pdUnit.Text
                             select g;
                switch (en_tzd.Count())
                {
                case 0:
                    // 插入新通知单
                    TZD new_tzd = new TZD();
                    new_tzd.派单日期     = pd_dt;
                    new_tzd.记录       = "\n" + "^" + _wt.设备名称 + ": " + _wt.存在问题 + " (" + plan_dt.Value.ToString("M月d日") + ")";
                    new_tzd.lastEdit = myFuc.getNowDateHashcode();
                    new_tzd.受理单位     = pdUnit.Text;
                    new_tzd.站名       = _Zn;

                    ctx.TZDs.Add(new_tzd);

                    //ctx.SaveChanges();
                    break;

                case 1:
                    //更新通知单
                    var    tzd_enty_row = en_tzd.Single();
                    string oldRec       = tzd_enty_row.记录;
                    if (oldRec.Contains(_wt.设备名称 + ": " + _wt.存在问题) == false)
                    {
                        ctx.Entry(tzd_enty_row).Entity.记录       = oldRec + "\n" + "^" + _wt.设备名称 + ": " + _wt.存在问题;
                        ctx.Entry(tzd_enty_row).Entity.lastEdit = myFuc.getNowDateHashcode();
                        ctx.SaveChangesAsync();
                    }
                    break;

                default:
                    Console.WriteLine("跑飞了....");
                    break;
                }
                ctx.SaveChangesAsync();
                //ctx.SaveChanges();

                g_var.g_chg_wt = enty_wt;
            }
            g_var.g_pf_flag = true;
            this.Close();
        }