/// <summary>
        /// Handles the OnAppointmentInsert event of the rScheduler control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Telerik.Web.UI.AppointmentInsertEventArgs"/> instance containing the event data.</param>
        protected void rScheduler_OnAppointmentInsert(object sender, AppointmentInsertEventArgs e)
        {
            if (e.Appointment.Start >= Task.StartDate && e.Appointment.End <= Task.EndDate)
            {
                var taskDurationMap = new TaskDurationMap
                {
                    ID = Guid.NewGuid(),
                    SectionDateStart      = e.Appointment.Start,
                    SectionDateEnd        = e.Appointment.End,
                    ActualDurationHours   = (e.Appointment.End - e.Appointment.Start).Hours,
                    ActualDurationMinutes = (e.Appointment.End - e.Appointment.Start).Minutes,
                    Comment = e.Appointment.Subject
                };
                if (!string.IsNullOrEmpty(e.Appointment.Attributes["ResponsibleID"]))
                {
                    taskDurationMap.ResponsibleID = Guid.Parse(e.Appointment.Attributes["ResponsibleID"]);
                }

                ((List <TaskDurationMap>)ViewState["TaskDurations"]).Add(taskDurationMap);
            }
            else
            {
                if (!Page.ClientScript.IsStartupScriptRegistered("InsertAlert"))
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "InsertAlert", "alert('Указан не правильный промежуток');", true);
                }
            }

            BindData();
        }
        /// <summary>
        /// Handles the OnAppointmentInsert event of the rScheduler control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Telerik.Web.UI.AppointmentInsertEventArgs"/> instance containing the event data.</param>
        protected void rScheduler_OnAppointmentInsert(object sender, AppointmentInsertEventArgs e)
        {
            var actualTime = ((List <TaskDurationMap>)ViewState["TaskDurations"]).Sum(tdp => tdp.ActualDurationHours * 60 + tdp.ActualDurationMinutes);

            actualTime = actualTime + (e.Appointment.End - e.Appointment.Start).Hours + (e.Appointment.End - e.Appointment.Start).Minutes;

            if (actualTime <= (Task.PlanDurationHours * 60 + Task.PlanDurationMinutes))
            {
                var taskDurationMap = new TaskDurationMap
                {
                    ID = Guid.NewGuid(),
                    SectionDateStart      = e.Appointment.Start,
                    SectionDateEnd        = e.Appointment.End,
                    ActualDurationHours   = (e.Appointment.End - e.Appointment.Start).Hours,
                    ActualDurationMinutes = (e.Appointment.End - e.Appointment.Start).Minutes,
                    Comment       = e.Appointment.Subject,
                    ResponsibleID = CurrentUser.Instance.ContactID
                };

                ((List <TaskDurationMap>)ViewState["TaskDurations"]).Add(taskDurationMap);
            }
            else
            {
                if (!Page.ClientScript.IsStartupScriptRegistered("InsertAlert"))
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "InsertAlert", "alert('Указан не правильный промежуток');", true);
                }
            }

            BindData();
        }
Example #3
0
    protected void EventScheduler_AppointmentInsert(object sender, AppointmentInsertEventArgs e)
    {
        if (Session["User"] != null)
        {
            var aptStartTime = e.Appointment.Start.TimeOfDay;
            var aptEndTime   = e.Appointment.End.TimeOfDay;
            var resource     = e.Appointment.Resources.GetResourceByType("Room");

            // Check if blocked timeslot
            Utility.GetHours(resource.Text, out _resStartTime, out _resEndTime);
            if (Utility.IsBlockedTimeSlot(aptStartTime, aptEndTime, _resStartTime, _resEndTime))
            {
                e.Cancel = true;
                ShowErrorMessage("Creating events in blocked timeslot is not allowed.");
            }

            // Check if there is alreay an appointment
            if (Utility.ExceedsLimit(e.Appointment, EventScheduler))
            {
                e.Cancel = true;
                ShowErrorMessage("Creating events in occupied timeslot is not allowed.");
            }
        }
        else
        {
            e.Cancel = true;
            ShowErrorMessage("Only logged in user can create events.");
        }
    }
Example #4
0
        protected void radcalendar_AppointmentInsert(object sender, AppointmentInsertEventArgs e)
        {
            int _eid = 0;

            _eid = e.Appointment.ID != null?Convert.ToInt32(e.Appointment.ID.ToString()) : 0;

            if (_eid == 0)
            {
                //ach.UpdateActivity(ref _eid, e.Appointment.Subject, Convert.ToInt32(e.Appointment.Attributes["VenueID"].ToString()), e.Appointment.Description, e.Appointment.Start, e.Appointment.End, Convert.ToInt32(e.Appointment.Attributes["EventTypeID"].ToString()), "ADD", e.Appointment.RecurrenceRule);
            }
            bL.Schedule.Appointments.Add(new telerik_scheduler_sandbox.dL.Schedule.AppointmentInfo(e.Appointment));
            this.radcalendar.Rebind();
        }
        protected void RadScheduler1_AppointmentInsert(object sender, AppointmentInsertEventArgs e)
        {
            //OldInsertMethod(sender, e); Checks whether the same affiliation has a planned visit in the same day or not
            //this is RadFilterDoesNotContainFilterExpression not make sense since an affiliation id is a line-based
            // if we do need to do this, we have to check a physician id rather than affiliation id and also there will be a problem
            //which is we save an appointment in a first saturday which is an assumed date, so a system must accept this date otherwise it is a conflict
            try
            {
                if (DateTime.Now.Day > int.Parse(Session["AllowedDaysForPlanning"].ToString()))
                {
                    //Label1.Text = "You can not change a plan after a seventh day in month";
                    //e.Cancel = true;
                }
                if (e.Appointment.Start < DateTime.Parse(Session["StartDate"].ToString()) || e.Appointment.Start > DateTime.Parse(Session["EndDate"].ToString())) //Dimmed to allow a rep to plan to the next month
                {
                    Label1.Text = "Date Range Is Wrong, it must be for the current cycle or the next cycle";
                    //RegisterScript();
                    //MessageBox.Show("Date Range Is Wrong, It Must Be Within a Current Cycle", "Overlapped Appointment", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
                    e.Cancel = true;
                }
                e.Appointment.Attributes["LastModified"] = DateTime.Now.ToString();
                e.Appointment.Attributes["Annotations"]  = "Appointment";

                appointmentsDS.InsertParameters["EmployeeID"].DefaultValue = Session["EmployeeID"].ToString();
                appointmentsDS.InsertParameters["LineID"].DefaultValue     = Session["LineID"].ToString();
                appointmentsDS.InsertParameters["BrickID"].DefaultValue    = e.Appointment.Resources.GetResourceByType("Bricks").Key.ToString();
                appointmentsDS.InsertParameters["CycleID"].DefaultValue    = Session["CycleID"].ToString();// ddlCycles.SelectedValue;
            }
            catch (Exception ex)
            {
                Label1.Text = ex.Message;
                //RegisterScript();
                //MessageBox.Show("Date Range Is Wrong, It Must Be Within a Current Cycle", "Overlapped Appointment", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
                e.Cancel = true;
            }
        }
 protected void InstructionalPlanScheduler_AppointmentInsert(object sender, AppointmentInsertEventArgs e)
 {
     Appointment appt = e.Appointment;
     _selectedPlan.AddCalendarEvent(appt.Start, appt.End, appt.Subject, newEventTargetType, newEventTargetID);
 }
Example #7
0
 protected void RadScheduler1_AppointmentInsert(object sender, AppointmentInsertEventArgs e)
 {
     e.Appointment.Attributes.Add("VolID", "6CD40064-CF05-4B55-93C0-6E4D7F9CCE34");
     e.Appointment.Attributes.Add("AddrID", "1");
 }
Example #8
0
        //scheduler events
        public void VaaScheduler_AppointmentInsert(object sender, AppointmentInsertEventArgs e)
        {
            try
            {
                string assignedTo;
                if (e.Appointment.Subject == String.Empty)
                {
                    e.Cancel = true;
                }
                else
                {
                    List <string> users = new List <string>();

                    foreach (Resource user in e.Appointment.Resources.GetResourcesByType("User"))
                    {
                        users.Add(user.Key.ToString());
                    }
                    if (users.Count > 0)
                    {
                        assignedTo = string.Join(", ", users.ToArray());
                    }
                    else
                    {
                        assignedTo = users.ToString();
                    }

                    Resource  color     = e.Appointment.Resources.GetResourceByType("Colors");
                    Schedules schedules = new Schedules()
                    {
                        Subject            = e.Appointment.Subject,
                        Start              = e.Appointment.Start,
                        End                = e.Appointment.End,
                        UserID             = assignedTo,
                        RecurrenceRule     = e.Appointment.RecurrenceRule,
                        RecurrenceParentID = Convert.ToInt16(e.Appointment.RecurrenceParentID),
                        Description        = e.Appointment.Description,
                        Remainder          = Convert.ToString(e.Appointment.Reminders),
                        Completed          = false,
                        ColorID            = Convert.ToInt16(color.Key)
                    };
                    var newScheduleID = _scheduleManagement.CreateNewSchedule(schedules);

                    //send email notification
                    if (newScheduleID != 0)
                    {
                        var schedule = _scheduleManagement.GetScheduleById(Convert.ToInt16(newScheduleID));

                        if (schedule != null)
                        {
                            var userIds = schedule.UserID;

                            if (userIds != null)
                            {
                                var usersArray = userIds.Split(new char[] { ',' });

                                for (int i = 0; i < usersArray.Length; i++)
                                {
                                    var user = _accountManagement.GetUserById(Convert.ToInt32(usersArray[i].Trim()));

                                    var email         = user.Username;
                                    var firstname     = user.FirstName;
                                    var subject       = schedule.Subject;
                                    var description   = schedule.Description;
                                    var startdatetime = Convert.ToString(schedule.Start);
                                    var enddatetime   = Convert.ToString(schedule.End);

                                    EmailHelper.SendAppointmentNotification(email, firstname, subject, description, startdatetime, enddatetime);
                                }
                            }
                        }
                    }
                }
                BindSchedules();
            }
            catch (Exception ex)
            {
                //write to Elma
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }
 protected void RadScheduler1_AppointmentInsert(object sender, AppointmentInsertEventArgs e)
 {
     ScriptManager.RegisterStartupScript(this, this.GetType(), "", "toastr.success('Event Saved', 'Success');", true);
 }
Example #10
0
 protected void RadScheduler1_AppointmentInsert(object sender, AppointmentInsertEventArgs e)
 {
     e.Cancel = true;
 }
Example #11
0
        protected void RadScheduler1_AppointmentInsert(object sender, AppointmentInsertEventArgs e)
        {
            string subject = e.Appointment.Subject.Trim();
            string s       = e.Appointment.Description;

            if (subject != "")
            {
                string UserID = (string)Session["UserID"].ToString();

                //string UserID = "27276";
                string CongTy = "LTY";
                //string abc = e.Appointment.ToolTip;
                string   St        = "";
                DateTime StartDate = e.Appointment.Start;
                string   ngaythang = DateTime.Parse(StartDate.ToShortDateString()).ToString("dd/MM/yyyy");
                string   gio       = DateTime.Parse(StartDate.ToLongTimeString()).ToString("HH");
                string   phut      = DateTime.Parse(StartDate.ToLongDateString()).ToString("mm:ss");
                int      hour      = int.Parse(gio.ToString()) + 1;
                if (hour > 7)
                {
                    St = "PM";
                }
                else
                {
                    St = "AM";
                }
                string jobid = "";
                string Sub   = "";
                string ngay  = ngaythang + " " + hour.ToString() + ":" + phut + " " + St;
                // DateTime EndDate = e.Appointment.End;
                DateTime  EndDate = DateTime.Parse(ngay.ToString());
                DataTable dt3     = dalProjects.TimTenJob(CongTy, UserID, subject);
                if (dt3.Rows.Count > 0)
                {
                    jobid = dt3.Rows[0]["jobid"].ToString();
                    Sub   = dt3.Rows[0]["jobname"].ToString();
                    DateTime StartDate1;
                    DateTime EndDate1;

                    try
                    {
                        string p = dt3.Rows[0]["jobpercent"].ToString();
                        jobpercent = decimal.Parse(p);
                    }
                    catch
                    {
                        jobpercent = 0;
                    }
                    string ngaybatdau  = DateTime.Parse(dt3.Rows[0]["edates"].ToString()).ToString("dd/MM/yyyy");
                    string ngayketthuc = DateTime.Parse(dt3.Rows[0]["edatee"].ToString()).ToString("dd/MM/yyyy");
                    if (ngaybatdau != ngayketthuc)
                    {
                        string datS = ngaybatdau + " " + gio + ":" + phut + " " + St;
                        string datE = ngayketthuc + " " + gio + ":" + phut + " " + St;
                        StartDate1 = DateTime.Parse(datS.ToString());
                        EndDate1   = DateTime.Parse(datE.ToString());
                        //
                    }
                    else
                    {
                        string datS = ngaybatdau + " " + gio + ":" + phut + " " + St;
                        string datE = ngayketthuc + " " + hour.ToString() + ":" + phut + " " + St;
                        StartDate1 = DateTime.Parse(datS.ToString());
                        EndDate1   = DateTime.Parse(datE.ToString());
                    }
                    dal.ThemLichRutGon1(CongTy, UserID, StartDate, EndDate, Sub, jobid, jobpercent);
                }
                else
                {
                    jobid = "A";
                    dal.ThemLichRutGon1(CongTy, UserID, StartDate, EndDate, subject, jobid, jobpercent);
                }
                #region Cai Nay chua dung den
                //DataTable dt = dalSystem.TimSystemTheoTen(CongTy, UserID, subject);
                //if (dt.Rows.Count > 0)
                //{
                //    DateTime StartDate1 ;
                //    DateTime EndDate1;
                //    string ngaybatdau = DateTime.Parse(dt.Rows[0]["edates"].ToString()).ToString("dd/MM/yyyy");
                //    string ngayketthuc = DateTime.Parse(dt.Rows[0]["edatee"].ToString()).ToString("dd/MM/yyyy");
                //    if (ngaybatdau != ngayketthuc)
                //    {
                //        string datS = ngaybatdau + " " + gio + ":" + phut + " " + St;
                //        string datE = ngayketthuc + " " + gio + ":" + phut + " " + St;
                //        StartDate1 = DateTime.Parse(datS.ToString());
                //        EndDate1 = DateTime.Parse(datE.ToString());

                //    }
                //    else
                //    {
                //        string datS = ngaybatdau + " " + gio + ":" + phut + " " + St;
                //        string datE = ngayketthuc + " " + hour.ToString() + ":" + phut + " " + St;
                //        StartDate1 = DateTime.Parse(datS.ToString());
                //        EndDate1 = DateTime.Parse(datE.ToString());
                //    }
                //    dal.ThemLichRutGon(CongTy, UserID, StartDate1, EndDate1, subject);
                //}
                //else
                //{
                //    DataTable dt2 = dalProjectm.TimTenSubsystem(CongTy, UserID, subject);
                //    if (dt2.Rows.Count > 0)
                //    {
                //        DateTime StartDate1;
                //        DateTime EndDate1;
                //        string ngaybatdau = DateTime.Parse(dt2.Rows[0]["edates"].ToString()).ToString("dd/MM/yyyy");
                //        string ngayketthuc = DateTime.Parse(dt2.Rows[0]["edatee"].ToString()).ToString("dd/MM/yyyy");
                //        if (ngaybatdau != ngayketthuc)
                //        {
                //            string datS = ngaybatdau + " " + gio + ":" + phut + " " + St;
                //            string datE = ngayketthuc + " " + gio + ":" + phut + " " + St;
                //            StartDate1 = DateTime.Parse(datS.ToString());
                //            EndDate1 = DateTime.Parse(datE.ToString());

                //        }
                //        else
                //        {
                //            string datS = ngaybatdau + " " + gio + ":" + phut + " " + St;
                //            string datE = ngayketthuc + " " + hour.ToString() + ":" + phut + " " + St;
                //            StartDate1 = DateTime.Parse(datS.ToString());
                //            EndDate1 = DateTime.Parse(datE.ToString());
                //        }
                //        dal.ThemLichRutGon(CongTy, UserID, StartDate1, EndDate1, subject);
                //    }
                //    else
                //    {

                //    }
                //}
                #endregion

                /////////// Cach ra
                // string St = "";
                // DateTime StartDate = e.Appointment.Start;
                //string ngaythang = DateTime.Parse(StartDate.ToShortDateString()).ToString("dd/MM/yyyy");
                //string gio = DateTime.Parse(StartDate.ToLongTimeString()).ToString("HH");
                //string phut = DateTime.Parse(StartDate.ToLongDateString()).ToString("mm:ss");
                //int hour = int.Parse(gio.ToString()) + 1;
                //if (hour > 7)
                //{
                //    St = "PM";
                //}
                //else
                //{
                //    St = "AM";
                //}
                // string ngay = ngaythang +" "+ hour.ToString() +":"+phut +" "+St;
                //// DateTime EndDate = e.Appointment.End;
                //DateTime EndDate = DateTime.Parse(ngay.ToString());
                // dal.ThemLichRutGon(CongTy, UserID, StartDate, EndDate, subject);
            }
            RaScheduler_Load1();
        }
        protected void RadScheduler1_AppointmentInsert(object sender, AppointmentInsertEventArgs e)
        {
            if (e.Appointment.Start < DateTime.Parse(Session["StartDateFromAdmin"].ToString()) || e.Appointment.Start > DateTime.Parse(Session["EndDateFromAdmin"].ToString()))
            {
                Label1.Text = "Date Range Is Wrong, It Must Be Within a Current Cycle";
                //RegisterScript();
                //MessageBox.Show("Date Range Is Wrong, It Must Be Within a Current Cycle", "Overlapped Appointment", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
                e.Cancel = true;
            }
            e.Appointment.Attributes["LastModified"] = DateTime.Now.ToString();
            e.Appointment.Attributes["Annotations"]  = "Appointment";

            con         = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["AmounCrmConnectionString"].ToString());
            affiliation = new SqlParameter();
            //entity = new SqlParameter();
            //physician = new SqlParameter();
            syear             = new SqlParameter();
            smonth            = new SqlParameter();
            sday              = new SqlParameter();
            curPlannedVisitID = new SqlParameter();

            cmd = new SqlCommand();

            cmd.Parameters.Add("affiliation", SqlDbType.Int);
            //cmd.Parameters.Add("entity", SqlDbType.Int);
            //cmd.Parameters.Add("physician", SqlDbType.Int);
            cmd.Parameters.Add("syear", SqlDbType.Int);
            cmd.Parameters.Add("smonth", SqlDbType.Int);
            cmd.Parameters.Add("sday", SqlDbType.Int);
            cmd.Parameters.Add("curPlannedVisitID", SqlDbType.Int);
            cmd.Parameters.Add("curPlannedRepID", SqlDbType.Int);

            cmd.Parameters["affiliation"].Value = e.Appointment.Resources.GetResourceByType("Affiliation").Key.ToString();
            //cmd.Parameters["entity"].Value = e.Appointment.Resources.GetResourceByType("Entity").Key.ToString();
            //cmd.Parameters["physician"].Value = e.Appointment.Resources.GetResourceByType("Physician").Key.ToString();
            cmd.Parameters["syear"].Value             = e.Appointment.Start.Year;
            cmd.Parameters["smonth"].Value            = e.Appointment.Start.Month;
            cmd.Parameters["sday"].Value              = e.Appointment.Start.Day;
            cmd.Parameters["curPlannedVisitID"].Value = 0;
            cmd.Parameters["curPlannedRepID"].Value   = int.Parse(ddlReps.SelectedValue);

            cmd.CommandText = "SELECT COUNT(*) FROM Appointments WHERE ( AffiliationID = " + cmd.Parameters["affiliation"].Value +
                              " AND YEAR([StartDate]) = " + cmd.Parameters["syear"].Value +
                              " AND MONTH([StartDate]) = " + cmd.Parameters["smonth"].Value +
                              " AND Day([StartDate]) = " + cmd.Parameters["sday"].Value +
                              " AND [AppointmentID] <> " + cmd.Parameters["curPlannedVisitID"].Value +
                              " AND [EmployeeID] <> " + cmd.Parameters["curPlannedRepID"].Value +
                              " )";
            //cmd.CommandText = "SELECT COUNT(*) FROM Appointments WHERE ( PhysicianID = " + cmd.Parameters["physician"].Value +
            //    " AND EntityID = " + cmd.Parameters["entity"].Value +
            //    " AND YEAR([StartDate]) = " + cmd.Parameters["syear"].Value +
            //    " AND MONTH([StartDate]) = " + cmd.Parameters["smonth"].Value +
            //    " AND Day([StartDate]) = " + cmd.Parameters["sday"].Value +
            //    " AND [AppointmentID] <> " + cmd.Parameters["curPlannedVisitID"].Value +
            //    " )";

            //cmd.CommandText = "SELECT COUNT(*) FROM Appointments WHERE ( UserID = " + cmd.Parameters[1].Value + " AND RoomID = " + cmd.Parameters[0].Value + ")";
            cmd.Connection = con;
            con.Open();

            plannedPhVisits = 0;
            dr = cmd.ExecuteReader();
            if (dr.HasRows == true)
            {
                while (dr.Read())
                {
                    plannedPhVisits = int.Parse(dr[0].ToString());
                }
            }
            if (plannedPhVisits == 0)
            {
                appointmentsDS.InsertParameters["EmployeeID"].DefaultValue = ddlReps.SelectedValue;
                appointmentsDS.InsertParameters["LineID"].DefaultValue     = ddlLines.SelectedValue;
                appointmentsDS.InsertParameters["AreaID"].DefaultValue     = Session["RepAreaIDFromAdmin"].ToString();
                appointmentsDS.InsertParameters["CycleID"].DefaultValue    = Session["CycleIDFromAdmin"].ToString();// ddlCycles.SelectedValue;
            }
            else
            {
                e.Appointment.Description = "One of Amoun Team will visit this physician in this day";
                Label1.Text = "One of Amoun Team will visit this physician in this day";
                //RegisterScript();
                Label1.Text = "Overlapped Appointment" + "<br />" + "One of Amoun Team has a visit to this physician in this day";
                e.Cancel    = true;
            }
            con.Close();
        }