예제 #1
0
 internal static bool Update(CustomAppointment customAppointment)
 {
     try
     {
         String sql = "update custom_appointment set start_time = '" + customAppointment.StartTime + "'"
                      + ",end_time='" + customAppointment.EndTime + "'";
         if (!String.IsNullOrEmpty(customAppointment.OwnerId))
         {
             sql += ",owner_id='" + customAppointment.OwnerId + "'";
         }
         if (!String.IsNullOrEmpty(customAppointment.Description))
         {
             sql += ",description='" + customAppointment.Description + "'";
         }
         if (!String.IsNullOrEmpty(customAppointment.TaskTemplateId))
         {
             sql += ",task_template_id='" + customAppointment.TaskTemplateId + "'";
         }
         sql += ",label='" + customAppointment.Label + "'"
                + ",plan_id='" + customAppointment.PlanId + "'"
                + ",percent_complete='" + customAppointment.PercentComplete + "'"
                + " where task_id = '" + customAppointment.TaskId + "'; ";
         DBUtil.ExecuteSQL(sql);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
예제 #2
0
 /// <summary>
 /// 生成任务和工作强度
 /// </summary>
 /// <param name="customAppointment"></param>
 /// <returns></returns>
 internal static bool InsertAndTaskWorkIntensity(CustomAppointment customAppointment)
 {
     try
     {
         String sql = "insert into custom_appointment (task_id,status,parent_task_id,plan_id,start_time,end_time,subject,owner_id,percent_complete,task_template_id,description,create_date,delegate_id,task_level,label)"
                      + " values('"
                      + customAppointment.TaskId
                      + "','1"
                      + "','" + customAppointment.ParentTaskId
                      + "','" + customAppointment.PlanId
                      + "', '" + customAppointment.StartTime
                      + "', '" + customAppointment.EndTime
                      + "', '" + customAppointment.Subject
                      + "', '" + customAppointment.OwnerId
                      + "', '" + customAppointment.PercentComplete
                      + "', '" + customAppointment.TaskTemplateId
                      + "', '" + customAppointment.Description
                      + "', now()"
                      + ", '" + customAppointment.DelegateId
                      + "', '" + customAppointment.TaskLevel
                      + "','" + customAppointment.Label + "'); ";
         DBUtil.ExecuteSQL(sql);
         //  更新其他状态
         insertTaskWorkIntensity(customAppointment);
         updateTaskDelegate(customAppointment);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
예제 #3
0
        public async Task <bool> SaveAppointmentAsync(CustomAppointment a)
        {
            if (CalendarToUse == null)
            {
                await GetCalendarAsync();
            }
            var A = new Appointment
            {
                AllDay     = a.AllDay,
                Details    = a.Details,
                Reminder   = a.Reminder,
                RoamingId  = a.RoamingId,
                StartTime  = a.StartTime,
                Subject    = a.Subject,
                BusyStatus = AppointmentBusyStatus.Free
            };

            try
            {
                await CalendarToUse.SaveAppointmentAsync(A);
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }
예제 #4
0
        /// <summary>
        /// 通过任务信息初始化任务预览
        /// </summary>
        /// <param name="customAppointment"></param>
        /// <param name="empId"></param>
        /// <param name="isOwner">是否负责人</param>
        public Frm我指派的任务预览(Frm任务S frm, CustomAppointment customAppointment, String delegateId)
        {
            InitializeComponent();
            this.customAppointment = customAppointment;
            this.delegateId        = delegateId;

            //  补充参与者信息
            CustomAppointmentService.buildAssignee(customAppointment);
            CustomAppointmentService.taskRead(customAppointment);
            this.frm = frm;
            this.frm.RefrashGridcontrol();

            this.initViewData();    //  初始化视图的值

            this.getTaskAchievement();
            this.getTaskWorkIntensity();    //  工作强度

            //  任务分解一览
            this.treeListTask.DataSource = CustomAppointmentService.getAllById(customAppointment.TaskId);
            this.gridControl2.DataSource = this.GetDataTable();

            //  业务委托人
            //显示的数据
            this.comboBoxDelegate.DisplayMember = "Name"; //name为类A的字段名
            //隐藏的数据(对于多个数据,可以用逗号隔开。例:id,name)
            this.comboBoxDelegate.ValueMember = "Id";     //id为类A的字段名(对于隐藏对个数据,把数据放到一个字段用逗号隔开)
            this.comboBoxDelegate.DataSource  = EmpService.findAll();
        }
예제 #5
0
        private void gridView1_DoubleClick(object sender, EventArgs e)
        {
            int               handle            = this.gridView1.FocusedRowHandle;
            DataRow           drhandle          = this.gridView1.GetDataRow(handle);
            CustomAppointment customAppointment = CustomAppointmentService.getById(drhandle["task_id"].ToString());

            new Frm我创建的任务预览(customAppointment, customAppointment.OwnerId, false).ShowDialog();
        }
예제 #6
0
 private void schedulerControl1_Click(object sender, EventArgs e)
 {
     if (schedulerControl1.SelectedAppointments.Count > 0)
     {
         Appointment appointment = schedulerControl1.SelectedAppointments[schedulerControl1.SelectedAppointments.Count - 1];
         this.taskId            = (String)appointment.Id;
         this.customAppointment = new CustomAppointment(appointment, this.planId, true);
     }
 }
예제 #7
0
    public static void DeleteCustomAppointment(CustomAppointment deletedCustomAppointment)
    {
        List <CustomAppointment> CustomAppointments = GetCustomAppointmentsList();

        CustomAppointment currentCustomAppointment = CustomAppointments.FirstOrDefault(c => c.Id.Equals(deletedCustomAppointment.Id));

        if (currentCustomAppointment != null)
        {
            CustomAppointments.Remove(currentCustomAppointment);
        }
    }
예제 #8
0
    public static object InsertCustomAppointment(CustomAppointment newCustomAppointment)
    {
        List <CustomAppointment> CustomAppointments = GetCustomAppointmentsList();

        int lastCustomAppointmentID = CustomAppointments.Count == 0 ? 0 : CustomAppointments.OrderBy(c => c.Id).Last().Id;

        newCustomAppointment.Id = lastCustomAppointmentID + 1;

        CustomAppointments.Add(newCustomAppointment);
        return(newCustomAppointment.Id);
    }
예제 #9
0
        private void barButtonItem1_ItemClick(object sender, ItemClickEventArgs e)
        {
            //  校验
            if (DateTime.Compare(this.edtEndDate.DateTime.Date, this.edtStartDate.DateTime.Date) < 0)
            {
                MessageBox.Show("结束时间早于开始时间!");
                return;
            }
            if (this.barTaskTemplate.EditValue == null)
            {
                MessageBox.Show("任务模板不能为空!");
                return;
            }
            if (String.IsNullOrEmpty(this.tbSubject.Text))
            {
                MessageBox.Show("任务名称不能为空!");
                return;
            }
            if (this.comboBoxEmp.SelectedValue == null)
            {
                MessageBox.Show("负责人不能为空!");
                return;
            }
            if (this.barEditItem3.EditValue == null)
            {
                MessageBox.Show("难度系数不能为空!");
                return;
            }
            String   ParentTaskId    = System.Guid.NewGuid().ToString("N");
            String   PlanId          = System.Guid.NewGuid().ToString("N");
            DateTime StartTime       = this.edtStartDate.DateTime.Date;
            DateTime EndTime         = this.edtEndDate.DateTime.Date;
            String   Subject         = this.tbSubject.Text;
            String   OwnerId         = this.comboBoxEmp.SelectedValue.ToString();
            int      PercentComplete = 0;
            String   delegate_id     = this.comboBoxDelegate.SelectedValue.ToString(); //  业务委托人
            String   TaskLevel       = this.barEditItem任务级别.EditValue.ToString();
            String   Description     = this.tbDescription.Text;
            int      Label           = 1;

            CustomAppointment customAppointment = new CustomAppointment(ParentTaskId, PlanId, StartTime, EndTime, Subject, OwnerId, PercentComplete, this.taskTemplateId, Description, Label, 1, this.appointmentModel.TaskWorkIntensity, delegate_id, TaskLevel);

            if (CustomAppointmentService.InsertAndTaskWorkIntensity(customAppointment))
            {
                this.form.RefrashGridcontrol();
                this.Close();
            }
            else
            {
                MessageBox.Show("保存失败");
            }
        }
예제 #10
0
        /// <summary>
        /// 补充参与者信息
        /// </summary>
        /// <param name="planId"></param>
        /// <param name="showAll"></param>
        /// <returns></returns>
        internal static void buildAssignee(CustomAppointment customAppointment)
        {
            String        sql      = "select emp_id from custom_appointment_assignee where task_id='" + customAppointment.TaskId + "'; ";
            DataTable     dt       = DBUtil.ExecuteDataTable(sql);
            List <String> assignee = new List <String>();

            foreach (DataRow dr in dt.Rows)
            {
                assignee.Add(dr["emp_id"].ToString());
            }

            customAppointment.Assignee = assignee;
        }
예제 #11
0
        /// <summary>
        /// 更新任务委托人
        /// </summary>
        /// <param name="customAppointment"></param>
        internal static void updateTaskDelegate(CustomAppointment customAppointment)
        {
            String sql = "update custom_appointment_delegate set current = false where task_id='" + customAppointment.TaskId + "';";

            DBUtil.ExecuteSQL(sql);
            //  分配委托人
            sql = "insert into custom_appointment_delegate"
                  + " (id, task_id, delegate_id, create_date, current)"
                  + " values('" + System.Guid.NewGuid().ToString("N") + "', '" + customAppointment.TaskId + "', '" + customAppointment.DelegateId + "', now(), true); ";
            DBUtil.ExecuteSQL(sql);
            sql = "update custom_appointment set delegate_id = '" + customAppointment.DelegateId + "' where task_id='" + customAppointment.TaskId + "';";
            DBUtil.ExecuteSQL(sql);
        }
예제 #12
0
    public static List <CustomAppointment> GetAppointments(List <CustomResource> resources)
    {
        List <CustomAppointment> appointments = new List <CustomAppointment>();

        foreach (CustomResource item in resources)
        {
            string subjPrefix = item.Name + "'s ";
            appointments.Add(CustomAppointment.CreateCustomAppointment(subjPrefix + "meeting", item.ResID, 2, 5, lastInsertedID++));
            appointments.Add(CustomAppointment.CreateCustomAppointment(subjPrefix + "travel", item.ResID, 3, 6, lastInsertedID++));
            appointments.Add(CustomAppointment.CreateCustomAppointment(subjPrefix + "phone call", item.ResID, 0, 10, lastInsertedID++));
        }
        return(appointments);
    }
예제 #13
0
        void tileView_EditFormShowing(object sender, DevExpress.XtraGrid.Views.Grid.EditFormShowingEventArgs e)
        {
            TaskRecord taskRecord = (TaskRecord)tileView.GetRow(e.RowHandle);

            if (taskRecord.Id > 0 && taskRecord.Id < this.customAppointments.Count())
            {
                CustomAppointment customAppointment = this.customAppointments[taskRecord.Id];
                new Frm我创建的任务预览(customAppointment, this.currentEmpId, false).ShowDialog();
            }

            e.Allow = false;

            //e.Allow = !IsEmptyItem(e.RowHandle);
        }
예제 #14
0
    public static void RemoveAppointments(CustomAppointment[] appts)
    {
        if (appts.Length == 0)
        {
            return;
        }

        List <CustomAppointment> appointmnets = HttpContext.Current.Session["AppointmentsList"] as List <CustomAppointment>;

        for (int i = 0; i < appts.Length; i++)
        {
            CustomAppointment sourceObject = appointmnets.First <CustomAppointment>(apt => apt.ID == appts[i].ID);
            appointmnets.Remove(sourceObject);
        }
    }
예제 #15
0
        public static void CorrectReminderInfo(CustomAppointment appt)
        {
            if (appt.ReminderInfo != "" && appt.TimeBeforeStart != "")
            {
                ReminderInfoCollection reminders = new ReminderInfoCollection();
                ReminderInfoCollectionXmlPersistenceHelper.ObjectFromXml(reminders, appt.ReminderInfo);

                for (int i = 0; i < reminders.Count; i++)
                {
                    reminders[i].TimeBeforeStart = TimeSpan.Parse(appt.TimeBeforeStart);
                    reminders[i].AlertTime       = appt.StartTime.Subtract(reminders[i].TimeBeforeStart);
                }
                ReminderInfoCollectionXmlPersistenceHelper helper = new ReminderInfoCollectionXmlPersistenceHelper(reminders);
                appt.ReminderInfo = helper.ToXml();
            }
        }
예제 #16
0
        /// <summary>
        /// 更新方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Storage_AppointmentChanged(object sender, PersistentObjectsEventArgs e)
        {
            if (this.currentBreakDown)
            {
                Appointment       apt = e.Objects[0] as Appointment;
                CustomAppointment customAppointment = new CustomAppointment(apt, this.planId, false);

                //  更新数据
                bool success = CustomAppointmentService.Update(customAppointment);
            }
            else
            {
                //  不是当前部门不能编辑任务
                MessageBox.Show("只能编辑当前部门的任务");
            }
            //e.Cancel = !success;
        }
예제 #17
0
        /// <summary>
        /// 插入事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Storage_AppointmentInserting(object sender, PersistentObjectCancelEventArgs e)
        {
            Appointment       apt = e.Object as Appointment;
            CustomAppointment customAppointment;

            if (this.canWBS)
            {
                //  任务分解模式
                customAppointment = new CustomAppointment(apt, this.planId, taskId);
            }
            else
            {
                //  新插入模式
                customAppointment = new CustomAppointment(apt, this.planId, true);
            }

            bool success = true;    //  插入成功

            if (String.IsNullOrEmpty(customAppointment.Subject))
            {
                MessageBox.Show("标题不能为空!");
                success = false;
            }
            if (String.IsNullOrEmpty(customAppointment.OwnerId))
            {
                MessageBox.Show("负责人不能为空!");
                success = false;
            }

            if (success)
            {
                success = CustomAppointmentService.Insert(customAppointment);   //  插入数据库
            }
            e.Cancel = !success;

            if (success)
            {
                this.customAppointment = customAppointment; //  给当前任务赋值
                this.taskId            = this.customAppointment.TaskId;

                this.CustomEventList         = CustomAppointmentService.getByPlanId(this.planId, this.showAll); //  根据计划id查询
                this.treeListTask.DataSource = this.CustomEventList;
                this.treeListTask.ExpandAll();
            }
        }
예제 #18
0
        /// <summary>
        /// 去重
        /// </summary>
        private static void removeDuplicate(CustomAppointment customAppointment, BindingList <CustomAppointment> customAppointments)
        {
            Boolean duplicated = false;

            foreach (CustomAppointment orgCustomAppointment in customAppointments)
            {
                if (customAppointment.TaskId.Equals(orgCustomAppointment.TaskId))
                {
                    //  重复
                    duplicated = true;
                    break;
                }
            }
            if (!duplicated)
            {
                customAppointments.Add(customAppointment);
            }
        }
예제 #19
0
    public static void UpdateCustomAppointment(CustomAppointment updatedCustomAppointment)
    {
        List <CustomAppointment> CustomAppointments = GetCustomAppointmentsList();

        CustomAppointment currentCustomAppointment = CustomAppointments.FirstOrDefault(c => c.Id.Equals(updatedCustomAppointment.Id));

        currentCustomAppointment.AllDay         = updatedCustomAppointment.AllDay;
        currentCustomAppointment.Description    = updatedCustomAppointment.Description;
        currentCustomAppointment.EndTime        = updatedCustomAppointment.EndTime;
        currentCustomAppointment.EventType      = updatedCustomAppointment.EventType;
        currentCustomAppointment.Label          = updatedCustomAppointment.Label;
        currentCustomAppointment.Location       = updatedCustomAppointment.Location;
        currentCustomAppointment.RecurrenceInfo = updatedCustomAppointment.RecurrenceInfo;
        currentCustomAppointment.ReminderInfo   = updatedCustomAppointment.ReminderInfo;
        currentCustomAppointment.ResourceId     = updatedCustomAppointment.ResourceId;
        currentCustomAppointment.StartTime      = updatedCustomAppointment.StartTime;
        currentCustomAppointment.Status         = updatedCustomAppointment.Status;
        currentCustomAppointment.Subject        = updatedCustomAppointment.Subject;
    }
예제 #20
0
        public static void UpdateAppointments(CustomAppointment[] appts)
        {
            if (appts.Length == 0)
            {
                return;
            }

            List <CustomAppointment> appointmnets = System.Web.HttpContext.Current.Session["AppointmentsList"] as List <CustomAppointment>;

            for (int i = 0; i < appts.Length; i++)
            {
                CustomAppointment sourceObject = appointmnets.First <CustomAppointment>(apt => apt.ID == appts[i].ID);
                appts[i].ID = sourceObject.ID;
                appointmnets.Remove(sourceObject);

                CorrectReminderInfo(appts[i]);
                appointmnets.Add(appts[i]);
            }
        }
예제 #21
0
 internal static bool insertTaskWorkIntensity(CustomAppointment customAppointment)
 {
     try
     {
         String sql = "insert into custom_appointment_work_intensity "
                      + " (task_id, difficulty_degree, work_load, work_intensity, emp_id)"
                      + " values('" + customAppointment.TaskId + "'"
                      + "         , '" + (int)customAppointment.TaskWorkIntensity.DifficultyDegree + "'"
                      + "         , '" + customAppointment.TaskWorkIntensity.WorkLoad + "'"
                      + "         , '" + customAppointment.TaskWorkIntensity.WorkIntensity + "'"
                      + "         , '" + customAppointment.OwnerId + "'); ";
         DBUtil.ExecuteSQL(sql);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
예제 #22
0
        private void OnGridMouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left || DragStartArea.Contains(e.Location))
            {
                return;
            }
            GridHitInfo hitInfo = View.CalcHitInfo(e.X + DragStartArea.Width / 2,
                                                   e.Y + DragStartArea.Height / 2);

            DragStartArea = Rectangle.Empty;
            if (!hitInfo.InRow)
            {
                return;
            }
            CustomAppointment appointment = (CustomAppointment)Storage.CreateAppointment(AppointmentType.Normal);

            appointment.ObjectForInsert = View.GetRow(hitInfo.RowHandle);
            appointment.Subject         = View.GetRowCellDisplayText(hitInfo.RowHandle, colSubject);
            Grid.DoDragDrop(new SchedulerDragData(appointment), DragDropEffects.All);
        }
예제 #23
0
        /// <summary>
        /// 生成assignment
        /// </summary>
        /// <param name="customAppointment"></param>
        /// <returns></returns>
        internal static bool insertCustomAppointmentAssignee(CustomAppointment customAppointment)
        {
            try
            {
                foreach (String empId in customAppointment.Assignee)
                {
                    String sql = "insert into custom_appointment_assignee"
                                 + " (id,status,task_id, emp_id)"
                                 + " values('" + System.Guid.NewGuid().ToString("N") + "'"
                                 + "         , '" + (int)EnumAssignment.未完成 + "'"
                                 + "         , '" + customAppointment.TaskId + "'"
                                 + "         , '" + empId + "'); ";
                    DBUtil.ExecuteSQL(sql);
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #24
0
        private Boolean isOwner;                     //  是否负责人

        /// <summary>
        /// 通过任务信息初始化任务预览
        /// </summary>
        /// <param name="customAppointment"></param>
        /// <param name="empId"></param>
        /// <param name="isOwner">是否负责人</param>
        public Frm我创建的任务预览(CustomAppointment customAppointment, String empId, Boolean isOwner)
        {
            InitializeComponent();
            this.customAppointment = customAppointment;
            this.isOwner           = isOwner;
            this.empId             = empId;

            //  补充参与者信息
            CustomAppointmentService.buildAssignee(customAppointment);

            this.initViewData();    //  初始化视图的值

            if (this.customAppointment.OwnerId.Equals(empId))
            {
                //  负责人视图
                this.负责人视图();
            }
            else
            {
                //  参与者视图,可以上传成果物
                this.参与者视图();
            }
            this.getTaskAchievement();
            this.getTaskWorkIntensity();    //  工作强度

            //  任务分解一览
            this.treeListTask.DataSource = CustomAppointmentService.getAllById(customAppointment.TaskId);
            this.gridControl2.DataSource = this.GetDataTable();

            //  业务委托人
            //显示的数据
            this.comboBoxDelegate.DisplayMember = "Name"; //name为类A的字段名
            //隐藏的数据(对于多个数据,可以用逗号隔开。例:id,name)
            this.comboBoxDelegate.ValueMember = "Id";     //id为类A的字段名(对于隐藏对个数据,把数据放到一个字段用逗号隔开)
            this.comboBoxDelegate.DataSource  = EmpService.findAll();
        }
예제 #25
0
        // Transform the given rental orders to custom appointments ready to be bound to the scheduler
        public ObservableCollection <CustomAppointment> LoadAppointments(IEnumerable <Reservations> rentalOrders)
        {
            IEnumerable <Chambres>         cars = GlobalData.model.Chambres.Where(c => c.Etat != "SUPPRIMER");
            IEnumerable <ReservationTypes> cats = GlobalData.model.ReservationTypes.Where(c => c.Etat != "SUPPRIMER");
            IEnumerable <TimeMarkers>      tm   = GlobalData.model.TimeMarkers;

            ObservableCollection <CustomAppointment> appointments = new ObservableCollection <CustomAppointment>();

            if (rentalOrders != null)
            {
                foreach (Reservations order in rentalOrders)
                {
                    try
                    {
                        CustomAppointment app        = new CustomAppointment();
                        Chambres          cham       = cars.First(x => x.ID == order.idChambre);
                        ReservationTypes  category   = cats.First(x => x.ID == order.idReservationType);
                        TimeMarkers       timemarker = tm.First(x => x.TimeMarkerName == order.EtatOperation);
                        app.UniqueId      = order.ID.ToString();
                        app.ReservationID = order.ID;
                        app.ChambreID     = order.idChambre.ToString();
                        app.Start         = order.DateArrive.Value;
                        app.End           = order.DateDepart.Value;
                        app.Category      = category;
                        app.TimeMarker    = timemarker;
                        app.Chambre       = "Chambres : " + cham.Numero;

                        //app.TypeChambreID = cham.TypeChambre.ToString();

                        if (order.ReservationTypes.ReservationType == "PASSAGE")
                        {
                            app.Subject = order.ReservationTypes.ReservationType;
                            int nbr = -order.DateArrive.Value.Subtract(order.DateDepart.Value).Hours;
                            app.NbreHeure = "" + nbr + " Hr";
                        }
                        else if (order.ReservationTypes.ReservationType == "MAINTENANCE")
                        {
                            app.Subject   = order.ReservationTypes.ReservationType;
                            app.NbreHeure = "" + order.NbreNuit + " Nuit";
                        }
                        else
                        {
                            app.Subject   = order.Clients.Noms;
                            app.NbreHeure = "" + order.NbreNuit + " Nuit";
                        }


                        if (order.Etat == "RESERVER")
                        {
                            ReservationTypes Dcategory = cats.First(x => x.CategoryName == "RESERVATION");
                            Dcategory.ReservationEtat = order.Etat;
                            app.Category = Dcategory;
                        }

                        if (order.Etat == "DUE OUT")
                        {
                            ReservationTypes Dcategory = cats.First(x => x.CategoryName == "DUE OUT");
                            Dcategory.ReservationEtat = order.Etat;
                            app.Category = Dcategory;
                        }

                        //category.ReservationEtat = order.Etat;
                        app.Etat = order.Etat;
                        //app.Localite = order.Localite;
                        appointments.Add(app);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            return(appointments);
        }
예제 #26
0
 public Task <bool> SaveAppointmentAsync(CustomAppointment a)
 {
     throw new NotImplementedException();
 }
예제 #27
0
        /// <summary>
        /// 已读
        /// </summary>
        /// <param name="planId"></param>
        /// <param name="showAll"></param>
        /// <returns></returns>
        internal static void taskRead(CustomAppointment customAppointment)
        {
            String sql = "update custom_appointment set status = '2' where task_id='" + customAppointment.TaskId + "'; ";

            DBUtil.ExecuteSQL(sql);
        }