Пример #1
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            try
            {
            if (isvalidate())
            {
     //           DateTime dsStart = new DateTime(int.Parse(dtpStartDate.Value.Value.Year.ToString()), int.Parse(dtpStartDate.Value.Value.Month.ToString()), int.Parse(dtpStartDate.Value.Value.Day.ToString()), int.Parse(cmbstarttimeh.Text), int.Parse(cmbstarttimem.Text), 0);
    //            DateTime dsEnd = new DateTime(int.Parse(dtpendate.Value.Value.Year.ToString()), int.Parse(dtpendate.Value.Value.Month.ToString()), int.Parse(dtpendate.Value.Value.Day.ToString()), int.Parse(cmbendtimeh.Text), int.Parse(cmbendtimem.Text), 0);
                ClsCalender objCal = new ClsCalender();

                
                    objCal.ID = -1;
                    objCal.ConfTitle = txtWhat.Text;
                    //  MessageBox.Show(dtpStartDate.Text);
                    string tmpDate = dtpStartDate.Text;
                    string[] splittmpDate = tmpDate.Split('/');
                    tmpDate = splittmpDate[1] + "/" + splittmpDate[0] + "/" + splittmpDate[2];
                    objCal.StartDateTime = DateTime.Parse(tmpDate + " " + cmbstarttimeh.Text + ":" + cmbstarttimem.Text + " " + cmbstartap.Text);
                    //   objCal.StartDateTime = dsStart;
                    DateTime dsStart = objCal.StartDateTime;
                    tmpDate = dtpendate.Text;
                    splittmpDate = tmpDate.Split('/');
                    tmpDate = splittmpDate[1] + "/" + splittmpDate[0] + "/" + splittmpDate[2];
                    objCal.EndDateTime = DateTime.Parse(tmpDate + " " + cmbendtimeh.Text + ":" + cmbendtimem.Text + " " + cmbendtimeap.Text);
                    DateTime dsEnd = objCal.EndDateTime;
                    //       objCal.EndDateTime = dsEnd;
                    DataTable dtMeetingBetween = ClsCalender.getMeetingsBetween(userID, dsStart, dsEnd).Tables[0];

                    if (dtMeetingBetween.Rows.Count == 0)
                    {

                        if (chkallday.IsChecked == true)
                        {
                            objCal.IsAllDay = true;
                        }
                        else
                            objCal.IsAllDay = false;

                        objCal.RepeatType = cmbrepeats.Text;
                        objCal.HostId = userID;
                        objCal.ConferenceLocation = txtwhere.Text;
                        objCal.ConferenceDetail = txtdescription.Text;
                        //objCal.Country = cmbCountryTimeZone.SelectedValue.ToString().Trim();
                        objCal.Timezone = cmbTimeZone.SelectedValue.ToString().Trim();
                        objCal.ModifiedBy = userID;
                        objCal.CreatedBy = userID;
                        objCal.IsDeleted = false;
                        //                objCal.TimeBeforeConf = cmbremindertime.Text;
                        //                objCal.ReminderType = cmbremindertype.Text;

                        if (rbndefault.IsChecked == true)
                        {
                            //objCal.ReminderType = "Default";
                            objCal.ConferenceType = "Default";
                            MCType = "Default";
                        }

                        else if (rbnprivate.IsChecked == true)
                        {
                            //objCal.ReminderType = "Private";
                            objCal.ConferenceType = "Private";
                            MCType = "Private";

                        }
                        else if (rbnpublic.IsChecked == true)
                        {
                            //objCal.ReminderType = "Public";
                            objCal.ConferenceType = "Public";
                            MCType = "Public";
                        }

                        objCal.ConfResponse = "Yes";

                        confID = objCal.Save();
                        string myDisplayName = ClsCalender.getUserInfo(userID);
                        string myEmail = ClsCalender.getUserInfoEmail(userID);
                        objCal.GuestName = myDisplayName;
                        objCal.Email = myEmail;
                        objCal.SaveGuest(confID);
                        ClsCalender.setEmailStatusOfConferenceGuest(myDisplayName, myEmail, "Organized");
                        ClsCalender.addConferenceUsers(confID, userID);
                        ClsCalender.updateConferenceUsers(confID, userID, "Yes");
                        sendInvitesToAll();
                        MessageBox.Show("Event Created Successfully");

                        //txtWhat.Text = "";
                        //dtpStartDate.Value = null;
                        //cmbstarttimeh.SelectedIndex = 0;
                        //cmbstarttimem.SelectedIndex = 0;
                        //cmbstartap.SelectedIndex = 0;
                        //dtpendate.Value = null;
                        //cmbendtimeh.SelectedIndex = 0;
                        //cmbendtimem.SelectedIndex = 0;
                        //cmbendtimeap.SelectedIndex = 0;
                        //cmbrepeats.SelectedIndex = 0;
                        //txtwhere.Text = "";
                        //txtdescription.Text = "";
                        ////                cmbremindertype.SelectedIndex = 0;
                        ////                cmbremindertime.SelectedIndex = 0;
                        //rbnprivate.IsChecked = true;
                        //txtUserName.Text = "";
                        //txtEmail.Text = "";
                        //lstInvitedUserList.Items.Clear();
                        //lstExistingUserList.Items.Clear();
                        //AddExistingUsers();

                        ((ctlCalContainer)this.Tag).objAddEvent.Visibility = Visibility.Collapsed;
                        ((ctlCalContainer)this.Tag).objConfCalander.Visibility = Visibility.Visible;
                        ((ctlCalContainer)this.Tag).objAddEvent = null;
                        ((Grid)this.Parent).Children.Remove(this);
                }
                else
                {
                    int countRows = dtMeetingBetween.Rows.Count;
                    string msg = "";
                    int i =0;
                    foreach (DataRow drMeetingBetween in dtMeetingBetween.Rows)
                    {
                        DateTime ds = DateTime.Parse(drMeetingBetween["StartDateTime"].ToString());
                        DateTime de = DateTime.Parse(drMeetingBetween["EndDateTime"].ToString());

                        string[] startDateTimeSplit = ds.ToString().Split(' ');
                        string[] endDateTimeSplit = de.ToString().Split(' ');
                        string confTitle = drMeetingBetween["ConfTitle"].ToString();

                        string[] stSplit = startDateTimeSplit[1].Split(':');
                        string[] etSplit = endDateTimeSplit[1].Split(':');

                        startDateTimeSplit[1] = stSplit[0] + ":" + stSplit[1];
                        endDateTimeSplit[1] = etSplit[0] + ":" + etSplit[1];

                        if(startDateTimeSplit[0].Equals(endDateTimeSplit[0]))
                        {
                            msg += ++i + ". " + confTitle +"        " + startDateTimeSplit[0] + "  -  " + startDateTimeSplit[1]+" "+startDateTimeSplit[2]+" To "+endDateTimeSplit[1]+" "+endDateTimeSplit[2] +"\n"; 
                        }
                        else
                            msg += ++i + ". " + confTitle +"        " + startDateTimeSplit[0] + "  -  " + startDateTimeSplit[1]+" "+startDateTimeSplit[2]+" To "+ startDateTimeSplit[0] + "  -  " +endDateTimeSplit[1]+" "+endDateTimeSplit[2] +"\n"; 

                    }

                    MessageBox.Show(countRows + " Meetings between the selected time already exist. Please select different time. \n\n"+msg);
                }
            }
            }
            catch (Exception exp)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "button1_Click()", "ctlAddEvent.xaml.cs");
            }


        }
        //public static StringBuilder CreateTressInfo()
        //{
        //    StringBuilder sb = new StringBuilder();
        //    sb.Append("User Is : " + VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName);
        //    sb.AppendLine();
        //    sb.Append("Peer Type is : " + VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType.ToString());
        //    sb.AppendLine();
        //    sb.Append("User's SuperNode is : " + VMuktiAPI.VMuktiInfo.CurrentPeer.SuperNodeIP);
        //    sb.AppendLine();
        //    sb.Append("User's Machine Ip Address : " + VMuktiAPI.GetIPAddress.ClsGetIP4Address.GetIP4Address());
        //    sb.AppendLine();
        //    sb.AppendLine("----------------------------------------------------------------------------------------");
        //    return sb;
        //}

        public ctlEditEventReadOnly()
        {
            InitializeComponent();


            System.Data.DataSet dsUserInfo = ClsCalender.getConferenceDetails(GlobalVariables.ConferenceID);
            confID = GlobalVariables.ConferenceID;
            DataTable table = dsUserInfo.Tables[0];
            DataRow   dr    = table.Rows[0];

            txtWhat.Content      = dr["ConfTitle"].ToString();
            txtStartDate.Content = dr["StartDateTime"].ToString();
            txtEndDate.Content   = dr["EndDateTime"].ToString();
            txtAllDay.Content    = dr["IsAllDay"].ToString();

            txtCreatedBy.Content  = ClsCalender.getUserInfo(Int64.Parse((dr["CreatedBy"].ToString())));
            txtTimezone.Content   = dr["Timezone"].ToString();
            txtRepeatType.Content = dr["RepeatType"].ToString();
            txtwhere.Content      = dr["ConferenceLocation"].ToString();

            txtdescription.AppendText(dr["ConferenceDetail"].ToString());
            txtdescription.IsReadOnly = true;
            //           txtReminderType.Content = dr["ReminderType"].ToString();


            System.Data.DataSet dsConferenceReminder = ClsCalender.getConferenceReminder(GlobalVariables.ConferenceID);

            DataRow drConferenceReminder = dsConferenceReminder.Tables[0].Rows[0];
            //            txtReminderTime.Content = drConferenceReminder["TimeBeforeConf"].ToString();

            string conferenceType = dr["ConferenceType"].ToString();

            if (conferenceType.Equals("Default"))
            {
                txtPrivacy.Content = "Default";
            }
            else if (conferenceType.Equals("Public"))
            {
                txtPrivacy.Content = "Public";
            }
            else if (conferenceType.Equals("Private"))
            {
                txtPrivacy.Content = "Private";
            }

            DataSet dsUsers = ClsCalender.getConferenceUsers(GlobalVariables.ConferenceID);
            int     countUsersAttendingConference = 0;

            foreach (DataRow drUsers in dsUsers.Tables[0].Rows)
            {
                try
                {
                    string response = drUsers["Attendence"].ToString().Trim();
                    if (response.Equals("Yes"))
                    {
                        countUsersAttendingConference++;
                    }
                    else if (response.Equals("MayBe"))
                    {
                        countUsersAttendingConference++;
                    }
                }
                catch (Exception ex)
                {
                    VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "ctlEditEventReadOnly()", "ctlEditEventReadOnly.xaml.cs");
                }
            }

            txtGuestsNo.Content = countUsersAttendingConference.ToString();
        }