Exemplo n.º 1
0
 public CommandResult Save(TASheetGroup info)
 {
     string id = null;
     ITASheetProvider provider = ProviderFactory.Create<ITASheetProvider>(_RepoUri);
     IUnitWork unitWork = ProviderFactory.Create<IUnitWork>(_RepoUri);
     if (!string.IsNullOrEmpty(info.SheetID))
     {
         TASheetSearchCondition con = new TASheetSearchCondition();
         con.SheetID = info.SheetID;
         List<TASheet> items = provider.GetItems(con).QueryObjects;
         foreach (TASheet item in items)
         {
             provider.Delete(item);
         }
         id = info.SheetID;
     }
     else
     {
         id = ProviderFactory.Create<IStringIDCreater>(_RepoUri).CreateID("SH", 4, "TASheet");
         if (string.IsNullOrEmpty(id)) return new CommandResult(ResultCode.Fail, "创建ID失败");
         info.SheetID = id;
     }
     if (info.Items != null && info.Items.Count > 0) info.Items.ForEach(it => it.SheetID = id);
     List<TASheet> sheets = TASheetGroup.UnGroup(info);
     foreach (TASheet sheet in sheets)
     {
         provider.Insert(sheet, unitWork);
     }
     return unitWork.Commit();
 }
Exemplo n.º 2
0
        public static List <TASheet> UnGroup(TASheetGroup group)
        {
            List <TASheet> items = null;

            if (group.Staff != null && group.Staff.Count > 0)
            {
                items = new List <TASheet>();
                foreach (Staff staff in group.Staff)
                {
                    TASheet item = new TASheet()
                    {
                        SheetID    = group.SheetID,
                        SheetType  = group.SheetType,
                        CreateDate = group.CreateDate,
                        StartDate  = group.StartDate,
                        EndDate    = group.EndDate,
                        Items      = group.Items,
                        CategoryID = group.Category,
                        StaffID    = staff.ID,
                        StaffName  = staff.Name,
                        Header     = group.Header,
                        Manager    = group.Manager,
                        HR         = group.HR,
                        Memo       = group.Memo,
                    };
                    items.Add(item);
                }
            }
            return(items);
        }
Exemplo n.º 3
0
 public static List<TASheet> UnGroup(TASheetGroup group)
 {
     List<TASheet> items = null;
     if (group.Staff != null && group.Staff.Count > 0)
     {
         items = new List<TASheet>();
         foreach (Staff staff in group.Staff)
         {
             TASheet item = new TASheet()
               {
                   SheetID = group.SheetID,
                   SheetType = group.SheetType,
                   CreateDate = group.CreateDate,
                   StartDate = group.StartDate,
                   EndDate = group.EndDate,
                   Items = group.Items,
                   CategoryID = group.Category,
                   StaffID = staff.ID,
                   StaffName = staff.Name,
                   Header = group.Header,
                   Manager = group.Manager,
                   HR = group.HR,
                   Memo = group.Memo,
               };
             items.Add(item);
         }
     }
     return items;
 }
Exemplo n.º 4
0
 public static List<TASheetGroup> Group(List<TASheet> sheets)
 {
     List<TASheetGroup> items = null;
     if (sheets != null && sheets.Count > 0)
     {
         foreach (TASheet sheet in sheets)
         {
             if (items == null) items = new List<TASheetGroup>();
             TASheetGroup item = items.SingleOrDefault(it => it.SheetID == sheet.SheetID);
             if (item == null)
             {
                 item = new TASheetGroup()
                 {
                     SheetID = sheet.SheetID,
                     SheetType = sheet.SheetType,
                     CreateDate = sheet.CreateDate,
                     StartDate = sheet.StartDate,
                     EndDate = sheet.EndDate,
                     Items = sheet.Items,
                     Category = sheet.CategoryID,
                     Header = sheet.Header,
                     Manager = sheet.Manager,
                     HR = sheet.HR,
                     Memo = sheet.Memo,
                     Staff = new List<Staff>()
                 };
                 items.Add(item);
             }
             item.Staff.Add(new Staff() { ID = sheet.StaffID, Name = sheet.StaffName });
         }
     }
     return items;
 }
Exemplo n.º 5
0
 public CommandResult Delete(TASheetGroup info)
 {
     TASheetSearchCondition con = new TASheetSearchCondition();
     con.SheetID = info.SheetID;
     ITASheetProvider provider = ProviderFactory.Create<ITASheetProvider>(_RepoUri);
     IUnitWork unitWork = ProviderFactory.Create<IUnitWork>(_RepoUri);
     List<TASheet> items = provider.GetItems(con).QueryObjects;
     foreach (TASheet item in items)
     {
         provider.Delete(item);
     }
     return unitWork.Commit();
 }
Exemplo n.º 6
0
        public static List <TASheetGroup> Group(List <TASheet> sheets)
        {
            List <TASheetGroup> items = null;

            if (sheets != null && sheets.Count > 0)
            {
                foreach (TASheet sheet in sheets)
                {
                    if (items == null)
                    {
                        items = new List <TASheetGroup>();
                    }
                    TASheetGroup item = items.SingleOrDefault(it => it.SheetID == sheet.SheetID);
                    if (item == null)
                    {
                        item = new TASheetGroup()
                        {
                            SheetID    = sheet.SheetID,
                            SheetType  = sheet.SheetType,
                            CreateDate = sheet.CreateDate,
                            StartDate  = sheet.StartDate,
                            EndDate    = sheet.EndDate,
                            Items      = sheet.Items,
                            Category   = sheet.CategoryID,
                            Header     = sheet.Header,
                            Manager    = sheet.Manager,
                            HR         = sheet.HR,
                            Memo       = sheet.Memo,
                            Staff      = new List <Staff>()
                        };
                        items.Add(item);
                    }
                    item.Staff.Add(new Staff()
                    {
                        ID = sheet.StaffID, Name = sheet.StaffName
                    });
                }
            }
            return(items);
        }
 protected override object GetItemFromInput()
 {
     TASheetGroup item = UpdatingItem as TASheetGroup;
     if (item == null)
     {
         item = new TASheetGroup();
         item.SheetType = SheetType;
         item.CreateDate = DateTime.Now;
     }
     item.StartDate = dtStartDate.Value;
     item.EndDate = dtEndDate.Value;
     if (item.Items == null) item.Items = new List<TASheetItem>();
     item.Items.Clear();
     if (chkTime1.Checked)
     {
         TASheetItem ti = new TASheetItem();
         ti.ID = Guid.NewGuid();
         ti.StartTime = new MyTime((int)txtStartHour1.Value, (int)txtStartMinute1.Value, 0);
         ti.NextDay = chkNextDay1.Checked;
         ti.EndTime = new MyTime((int)txtEndHour1.Value, (int)txtEndMinute1.Value, 0);
         ti.Duration = txtDuration1.Value;
         item.Items.Add(ti);
     }
     if (chkTime2.Checked)
     {
         TASheetItem ti = new TASheetItem();
         ti.ID = Guid.NewGuid();
         ti.StartTime = new MyTime((int)txtStartHour2.Value, (int)txtStartMinute2.Value, 0);
         ti.NextDay = chkNextDay2.Checked;
         ti.EndTime = new MyTime((int)txtEndHour2.Value, (int)txtEndMinute2.Value, 0);
         ti.Duration = txtDuration2.Value;
         item.Items.Add(ti);
     }
     if (chkTime3.Checked)
     {
         TASheetItem ti = new TASheetItem();
         ti.ID = Guid.NewGuid();
         ti.StartTime = new MyTime((int)txtStartHour3.Value, (int)txtStartMinute3.Value, 0);
         ti.NextDay = chkNextDay3.Checked;
         ti.EndTime = new MyTime((int)txtEndHour3.Value, (int)txtEndMinute3.Value, 0);
         ti.Duration = txtDuration3.Value;
         item.Items.Add(ti);
     }
     item.Category = GetCategory();
     item.Memo = txtMemo.Text;
     item.Header = txtHeader.Text;
     item.Manager = txtManager.Text;
     if (item.Staff == null) item.Staff = new List<Staff>();
     item.Staff.Clear();
     foreach (TreeNode node in treeView1.Nodes)
     {
         item.Staff.Add(node.Tag as Staff);
     }
     return item;
 }