Пример #1
0
    public void PlanCreate(decimal[,] place, string perid)
    {
        int count = 0;

        for (int i = 0; i < place.Length / 2; i++)
        {
            int rate = (int)(((dfend.SelectedDate - dfbegin.SelectedDate).Days + 1) / place[i, 1]);
            //rate = rate == 0 ? 1 : rate;
            DateTime begin = dfbegin.SelectedDate;
            DateTime end   = dfend.SelectedDate;
            int      make  = 0;
            for (; (begin <= end && make < place[i, 1]); begin = begin.AddDays(rate))//begin.AddDays(rate) <= end
            {
                DBSCMDataContext dc1 = new DBSCMDataContext();
                Moveplan         mp1 = new Moveplan
                {
                    Personid  = perid,
                    Placeid   = place[i, 0],
                    Starttime = begin,
                    Endtime   = begin > end ? end : (begin.AddDays(rate) > end ? end : begin.AddDays(rate - 1)),
                    Movestate = "未走动",
                    Maindept  = SessionBox.GetUserSession().DeptNumber
                };
                dc1.Moveplan.InsertOnSubmit(mp1);
                dc1.SubmitChanges();
                count++;
                make++;
            }
        }
        Ext.Msg.Alert("提示", "添加完成,共计添加" + count.ToString() + "条计划!").Show();
    }
Пример #2
0
    public void PlanCopy()
    {
        var mp = dc.Moveplan.Where(p => p.Starttime >= System.DateTime.Today.AddMonths(-1).AddDays(1 - System.DateTime.Today.Day) &&
                                   p.Starttime <= System.DateTime.Today.AddDays(-System.DateTime.Today.Day) &&
                                   p.Maindept == SessionBox.GetUserSession().DeptNumber
                                   );

        foreach (var r in mp)
        {
            Moveplan mp1 = new Moveplan
            {
                Personid  = r.Personid,
                Placeid   = r.Placeid,
                Starttime = r.Starttime.Value.AddMonths(1),
                Endtime   = r.Endtime.Value.AddMonths(1),
                Movestate = "未走动",
                Maindept  = r.Maindept
            };
            dc.Moveplan.InsertOnSubmit(mp1);
            dc.SubmitChanges();
        }
        Ext.Msg.Alert("提示", "复制完成,共计添加" + mp.Count().ToString() + "条计划!").Show();
        storeload();
    }