public static Event CreateEvent(Proposal proposal)
 {
     Event e = new Event();
     e.CreatorId = proposal.CreatorId;
     e.ProposalId = proposal.Id;
     e.CreateTime = DateTime.Now;
     e.GuestLimit = GetEventCapacity(proposal.Content);
     e.HostOrg = GetHostOrg(proposal.Content);
     e.HostName = GetContactName(proposal.Content);
     e.HostEmail = GetContactEmail(proposal.Content);
     e.HostPhone = GetContactPhone(proposal.Content);
     e.EventName = GetEventName(proposal.Content);
     e.StartTime = GetEventStartTime(proposal.Content);
     e.EndTime = GetEventEndTime(proposal.Content);
     e.RegDeadline = GetRegDeadline(proposal.Content);
     e.Location = GetEventLocation(proposal.Content);
     e.Descr = GetEventDesc(proposal.Content);
     e.MeetLocation = GetMeetingLocation(proposal.Content);
     e.MeetTime = GetMeetingTime(proposal.Content);
     e.Transportation = GetTrasportation(proposal.Content);
     e.RequestDrivers = GetRequestDrivers(proposal.Content);
     e.Costs = GetCost(proposal.Content);
     e.Equipment = GetEquipment(proposal.Content);
     e.Food = GetFood(proposal.Content);
     e.Other = GetOther(proposal.Content);
     return e;
 }
Esempio n. 2
0
 /// <summary>
 /// Make an Event object from form inputs.
 /// </summary>
 /// <returns>An event object.</returns>
 private Event MakeEvent()
 {
     Event e = new Event();
     e.CreatorId = ((DataModels.User)Session[Const.User]).Uid;
     e.CreateTime = DateTime.Now;
     e.GuestLimit = ParseGuestLimit();
     e.HostOrg = string.IsNullOrEmpty(HostOrg.Text.Trim()) ? null : HostOrg.Text.Trim();
     e.HostName = HostName.Text.Trim();
     e.HostEmail = HostEmail.Text.Trim();
     e.HostPhone = FormatHelper.ParsePhoneNum(HostPhone.Text);
     e.EventName = EventName.Text.Trim();
     e.StartTime = DateTime.Parse(StartTimeCtr.Text);
     e.EndTime = DateTime.Parse(EndTimeCtr.Text);
     e.RegDeadline = DateTime.Parse(RegDeadlineCtr.Text);
     e.Location = Location.Text.Trim();
     e.Descr = Desc.Text.Trim();
     e.MeetLocation = MeetLocation.Text.Trim();
     e.MeetTime = DateTime.Parse(MeetTime.Text);
     e.Transportation = Transport.Text.Trim();
     e.RequestDrivers = RequestDrivers.Checked;
     e.Costs = string.IsNullOrEmpty(Costs.Text.Trim()) ? null : Costs.Text.Trim();
     e.Equipment = string.IsNullOrEmpty(Equipment.Text.Trim()) ? null : Equipment.Text.Trim();
     e.Food = string.IsNullOrEmpty(Food.Text.Trim()) ? null : Food.Text.Trim();
     e.Other = string.IsNullOrEmpty(Other.Text.Trim()) ? null : Other.Text.Trim();
     return e;
 }
Esempio n. 3
0
 public static int Insert(int creatorId, Event _event, string tempate)
 {
     return Insert(creatorId, _event.EventName,
         MakeProposalHtmlContent(_event, tempate));
 }
Esempio n. 4
0
 public static string MakeProposalHtmlContent(Event ev, string template)
 {
     StringBuilder result = new StringBuilder(template);
     result.Replace("[EventName]", ev.EventName);
     result.Replace("[HostOrg]", GetString(ev.HostOrg));
     result.Replace("[ContactName]", ev.HostName);
     result.Replace("[ContactPhone]", FormatPhoneNum(ev.HostPhone));
     result.Replace("[ContactEmail]", ev.HostEmail);
     result.Replace("[EventDescription]", ev.Descr);
     result.Replace("[StartTime]", ev.StartTime.ToString("g"));
     result.Replace("[EndTime]", ev.EndTime.ToString("g"));
     result.Replace("[MeetTime]", ev.MeetTime.ToString("g"));
     result.Replace("[MeetingLocation]", ev.MeetLocation);
     result.Replace("[EventLocation]", ev.Location);
     result.Replace("[Transporation]", ev.Transportation);
     result.Replace("[RequestDrivers]", ev.RequestDrivers ? "Yes" : "No");
     result.Replace("[Equipment]", GetString(ev.Equipment));
     result.Replace("[Food]", GetString(ev.Food));
     result.Replace("[Cost]", GetString(ev.Costs));
     result.Replace("[Other]", GetString(ev.Other));
     result.Replace("[EventCapacity]", GetEventCapacityString(ev.GuestLimit));
     result.Replace("[RegDeadline]", ev.RegDeadline.ToString("g"));
     return result.ToString();
 }
Esempio n. 5
0
        /// <summary>
        /// Inserts a new Event into the database.
        /// </summary>
        /// <param name="e">The event to be inserted.</param>
        /// <returns>The number of rows affected from this operation.</returns>
        public static int Insert(Event e)
        {
            string queryStr =
                "INSERT INTO Events (creatorId, proposalId, createTime, guestLimit, hostOrg, " +
                "hostName, hostEmail, hostPhone, eventName, startTime, endTime, regDeadline, " +
                "location, descr, meetLocation, meetTime, transportation, requestDrivers, " +
                "costs, equipment, food, other, approved) " +
                "VALUES (@creatorId, @proposalId, @createTime, @guestLimit, @hostOrg, @hostName, " +
                "@hostEmail, @hostPhone, @eventName, @startTime, @endTime, @regDeadline, " +
                "@location, @descr, @meetLocation, @meetTime, @transportation, " +
                "@requestDrivers, @costs, @equipment, @food, @other, @approved)";

            using (SqlConnection con = new SqlConnection(Config.SqlConStr))
            {
                SqlCommand command = new SqlCommand(queryStr, con);
                command.Parameters.Add(new SqlParameter("creatorId", e.CreatorId));
                command.Parameters.Add(new SqlParameter("proposalId", e.ProposalId));
                command.Parameters.Add(new SqlParameter("createTime", DateTime.Now));
                command.Parameters.Add(e.GuestLimit == Event.EventCapacityUnlimited ?
                   new SqlParameter("guestLimit", DBNull.Value) :
                   new SqlParameter("guestLimit", e.GuestLimit));
                command.Parameters.Add(new SqlParameter("hostOrg", GetNullableValue(e.HostOrg)));
                command.Parameters.Add(new SqlParameter("hostName", e.HostName));
                command.Parameters.Add(new SqlParameter("hostEmail", e.HostEmail));
                command.Parameters.Add(new SqlParameter("hostPhone", e.HostPhone));
                command.Parameters.Add(new SqlParameter("eventName", e.EventName));
                command.Parameters.Add(new SqlParameter("startTime", e.StartTime));
                command.Parameters.Add(new SqlParameter("endTime", e.EndTime));
                command.Parameters.Add(new SqlParameter("regDeadline", e.RegDeadline));
                command.Parameters.Add(new SqlParameter("location", e.Location));
                command.Parameters.Add(new SqlParameter("descr", e.Descr));
                command.Parameters.Add(new SqlParameter("meetLocation", e.MeetLocation));
                command.Parameters.Add(new SqlParameter("meetTime", e.MeetTime));
                command.Parameters.Add(new SqlParameter("transportation", e.Transportation));
                command.Parameters.Add(new SqlParameter("requestDrivers", e.RequestDrivers));
                command.Parameters.Add(new SqlParameter("costs", GetNullableValue(e.Costs)));
                command.Parameters.Add(new SqlParameter("equipment", GetNullableValue(e.Equipment)));
                command.Parameters.Add(new SqlParameter("food", GetNullableValue(e.Food)));
                command.Parameters.Add(new SqlParameter("other", GetNullableValue(e.Other)));
                command.Parameters.Add(new SqlParameter("approved", true));
                con.Open();
                return command.ExecuteNonQuery();
            }
        }