private void OpenMalfunctionRegister(CollectSchedule schedule)
 {
     if (schedule.CollectTime != null && Malfunction == null && MessageBox.Show(this, "回収完了しています。故障機を登録しますか?", "ハードウェア管理", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         FormMalfunctionRegister.Instance.Relation = DBAccessor.Instance.GetRelation(schedule);
         FormMalfunctionRegister.Instance.Show();
     }
 }
Ejemplo n.º 2
0
        public Relation GetRelation(CollectSchedule schedule)
        {
            var r1 = (from a in Relations
                      where a.RelationCode == schedule.RelationCode
                      select a).FirstOrDefault();

            return(r1);
        }
Ejemplo n.º 3
0
        public Reserve GetReserve(CollectSchedule schedule)
        {
            var r1 = (from a in Relations
                      where a.RelationCode == schedule.RelationCode
                      select a).FirstOrDefault();

            if (r1 == null)
            {
                return(null);
            }

            var r2 = (from b in Reserves
                      where b.ReserveCode == r1.ReserveCode
                      select b).FirstOrDefault();

            return(r2);
        }
Ejemplo n.º 4
0
        public Malfunction GetMalfunction(CollectSchedule schedule)
        {
            var r1 = (from a in Relations
                      where a.RelationCode == schedule.RelationCode
                      select a).FirstOrDefault();

            if (r1 == null)
            {
                return(null);
            }

            var r2 = (from b in Malfunctions
                      where b.MalfunctionCode == r1.MalfunctionCode
                      select b).FirstOrDefault();

            return(r2);
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (cbxType.SelectedValue is int cbxtype && cbxState.SelectedValue is int cbxstate && cbxShop.SelectedValue is int cbxshop)
            {
                if (cbxshop == 0)
                {
                    MessageBox.Show(this, "店舗は必ず選択してください。", "ハードウェア管理");
                    return;
                }

                if (Relation == null)
                {
                    var rel = new Relation();
                    rel.RelationCode    = DBAccessor.Instance.MaxUniqueNumber <DBObject.Relation>() + 1;
                    rel.ReserveCode     = Reserve?.ReserveCode;
                    rel.MalfunctionCode = Malfunction?.MalfunctionCode;

                    DBAccessor.Instance.Relations = DBAccessor.Instance.UpsertJson <Relation, DBObject.Relation>(rel);

                    Relation = rel;

                    var cms = new CollectSchedule();
                    cms.CollectScheduleCode = DBAccessor.Instance.MaxUniqueNumber <DBObject.CollectSchedule>() + 1;
                    cms.RelationCode        = rel.RelationCode;
                    cms.ItemTypeCode        = cbxtype;
                    cms.ItemStateCode       = cbxstate;
                    cms.ShopCode            = cbxshop;
                    cms.CollectScheduleTime = dtpScheduleTime.Value.Date;
                    cms.CollectTime         = cbCollected.Checked ? dtpCollectedTime.Value.Date : (DateTime?)null;
                    cms.InsertTime          = DateTime.Now;
                    cms.UpdateTime          = DateTime.Now;

                    DBAccessor.Instance.CollectSchedules =
                        DBAccessor.Instance.UpsertJson <CollectSchedule, DBObject.CollectSchedule>(cms);

                    MessageBox.Show(this, "登録しました", "ハードウェア管理");
                    OpenMalfunctionRegister(cms);
                    this.Visible = false;
                }
                else
                {
                    Relation.ReserveCode     = Reserve?.ReserveCode;
                    Relation.MalfunctionCode = Malfunction?.MalfunctionCode;

                    DBAccessor.Instance.Relations =
                        DBAccessor.Instance.UpsertJson <Relation, DBObject.Relation>(Relation);

                    var cs = (from a in DBAccessor.Instance.CollectSchedules
                              where a.RelationCode == Relation.RelationCode
                              select a).FirstOrDefault();

                    cs.ItemTypeCode        = cbxtype;
                    cs.ItemStateCode       = cbxstate;
                    cs.ShopCode            = cbxshop;
                    cs.CollectScheduleTime = dtpScheduleTime.Value.Date;
                    cs.CollectTime         = cbCollected.Checked ? dtpCollectedTime.Value.Date : (DateTime?)null;
                    cs.UpdateTime          = DateTime.Now;

                    DBAccessor.Instance.CollectSchedules =
                        DBAccessor.Instance.UpsertJson <CollectSchedule, DBObject.CollectSchedule>(cs);

                    MessageBox.Show(this, "登録しました", "ハードウェア管理");
                    OpenMalfunctionRegister(cs);
                    this.Visible = false;
                }
            }
        }