Example #1
0
        public static void ChangeUserName(string oldusername, string newusername, int workorders, int activities)
        {
            WOLinqClassesDataContext db = new WOLinqClassesDataContext();
            if (workorders > 0)
            {

                var wo = db.Workorders.Where(u => u.submitted_by == oldusername).ToList();
                wo.ForEach(w => w.submitted_by = newusername);
                db.SubmitChanges();
            }
            if (activities > 0)
            {
                var act = db.LogActivities.Where(u => u.username == oldusername).ToList();
                act.ForEach(a => a.username = newusername);
                db.SubmitChanges();
            }
        }
Example #2
0
        /// <summary>
        /// Submit the form!
        /// </summary>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            btnSubmit.Enabled = false; // prevent double submission

            // from the information provided, create us a due date to store
            DateTime? duedate;
            if (ddAdType.SelectedValue.Equals("1"))
            {
                String strDate =  DateTime.Now.Year + "/" + ddAiringMonth.SelectedValue + "/01";
                duedate = strDate.ConvertToDate();
                if (duedate.HasValue && duedate < DateTime.Now)
                    duedate = duedate.Value.AddYears(1);
            }
            else
                duedate = (DateTime)txtStartAiringDate.Text.ConvertToDate();

            // submit!
            using (WOLinqClassesDataContext db = new WOLinqClassesDataContext())
            {
                // skip the approval process for designers and coordinators
                bool IsUserDesigner = Users.IsUserDesigner();
                bool NeedsApproval = !IsUserDesigner && !Users.IsUserCoordinator();
                Workorder w = new Workorder();
                w.submitted_date = DateTime.Now;
                w.submitted_by = Function.GetUserName();
                w.wotype = 3;
                w.duedate = duedate;
                w.ProgramManager = int.Parse(ddCoordinators.SelectedValue);
                w.title = "Radio Ad";
                w.status = NeedsApproval ? 1 : 2;
                db.Workorders.InsertOnSubmit(w);

                WorkOrdersRadio r = new WorkOrdersRadio();
                r.Workorder = w;
                r.AdType = int.Parse(ddAdType.SelectedValue);
                r.AiringMonth = ddAiringMonth.SelectedIndex > 0 ? int.Parse(ddAiringMonth.SelectedValue) : (int?)null;
                r.RadioStation = ddRadioStation.SelectedIndex > 0 ? int.Parse(ddRadioStation.SelectedValue) : (int?)null;
                r.RadioStationOther = txtRadioStationOther.Text;
                r.LengthOfAd = ddLengthOfAd.SelectedIndex > 0 ? int.Parse(ddLengthOfAd.SelectedValue) : (int?)null;
                r.StartAiringDate = txtStartAiringDate.Text.ConvertToDate();
                r.EndAiringDate = txtEndAiringDate.Text.ConvertToDate();
                r.Budget = txtBudget.Text;
                r.RecordingOptions = ddRecordingOptions.SelectedIndex > 0 ? int.Parse(ddRecordingOptions.SelectedValue) : (int?)null;
                r.Notes = txtNotes.Text;
                db.WorkOrdersRadios.InsertOnSubmit(r);
                db.SubmitChanges();
                int ID = w.ID;
                // upload attached files
                WO.UploadFiles(w.ID, AttachedFiles.UploadedFiles);
                // log the activity
                WO.LogAction(ID, "Work order created");
                // send notificaiton if needed
                WO.SendNewWONotification(ID, NeedsApproval, IsUserDesigner);
                // complete!
                Response.Redirect("~/MyWorkOrders.aspx?success=true&ID=" + ID + "&type=" + w.wotype);
            }
        }
Example #3
0
 /// <summary>
 /// Toggles the status of a user (active to inactive and vice versa)
 /// </summary>
 /// <param name="ID">ID of a specific user</param>
 /// <returns>Updated Status (boolean)</returns>
 public static bool? SetUserStatus(int ID)
 {
     WOLinqClassesDataContext db = new WOLinqClassesDataContext();
     User u = db.Users.Single(i => i.ID == ID);
     if (u == null) return null;
     u.Active = !u.Active;
     db.SubmitChanges();
     return u.Active;
 }
Example #4
0
        /// <summary>
        /// Submit the form!
        /// </summary>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            btnSubmit.Enabled = false; // prevent double submission
            using (WOLinqClassesDataContext db = new WOLinqClassesDataContext())
            {
                // if the user doesn't need approval, skip the approval process
                bool IsUserDesigner = Users.IsUserDesigner();
                bool NeedsApproval = !IsUserDesigner && !Users.IsUserCoordinator();
                Workorder w = new Workorder();
                w.submitted_date = DateTime.Now;
                w.submitted_by = Function.GetUserName();
                if (Request.QueryString["quote"] != null && Request.QueryString["quote"].Equals("1"))
                    w.wotype = 5;
                else
                    w.wotype = 1;
                w.duedate = txtDueDate.Text.ConvertToDate();
                w.ProgramManager = int.Parse(ddCoordinators.SelectedValue);
                w.title = txtPubTitle.Text;
                w.status = NeedsApproval ? 1 : 2;
                db.Workorders.InsertOnSubmit(w);

                WorkOrdersPrint p = new WorkOrdersPrint();
                p.Workorder = w;
                p.ProjectType = int.Parse(ddTypeProject.SelectedValue);
                p.ProjectTypeOther = txtProjectOther.Text;
                p.TypeOfDisplay = ddTypeOfDisplay.SelectedIndex > 0 ? int.Parse(ddTypeOfDisplay.SelectedValue) : (int?)null;
                p.TypeOfDisplayOther = txtDisplayOther.Text;
                p.PromoItem = txtPromoItem.Text;
                p.PrintingMethod = int.Parse(ddPrintingMethod.SelectedValue);
                p.Budget = txtBudget.Text;
                p.PaperSize = int.Parse(ddPaperSize.SelectedValue);
                p.CustomPaperSize = txtCustomPaperSize.Text;
                p.PaperType = int.Parse(ddPaperType.SelectedValue);
                p.ColourInfo = int.Parse(ddColourInfo.SelectedValue);
                p.NumberCopies = txtNumberCopies.Text;
                p.FullBleed = ddFullBleed.Value;
                p.Credit = int.Parse(ddCredits.SelectedValue);
                p.CreditName = txtCreditName.Text;
                p.Notes = txtNotes.Text;
                db.WorkOrdersPrints.InsertOnSubmit(p);
                db.SubmitChanges();
                int ID = p.wID;
                // upload attached files
                WO.UploadFiles(w.ID, AttachedFiles.UploadedFiles);
                // log the activity
                WO.LogAction(ID, "Work order created");
                // send notification (if necessary)
                WO.SendNewWONotification(ID, NeedsApproval, IsUserDesigner);

                // if the user added the option to add to the website, transfer user to web work order page
                if (ddAddToWebsite.Value == true)
                    Response.Redirect("~/Create/Web.aspx?AddTo=" + ID);
                else // if not, success!!
                    Response.Redirect("~/MyWorkOrders.aspx?success=true&ID=" + ID + "&type=" + w.wotype.ToString());
            }
        }
Example #5
0
 /// <summary>
 /// Saves changes to the user account
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     using (WOLinqClassesDataContext db = new WOLinqClassesDataContext())
     {
         int ID = int.Parse(Request.QueryString["ID"]);
         User u = db.Users.Single(z => z.ID == ID);
         u.Username = txtUsername.Text;
         u.FullName = txtFullName.Text;
         u.Email = txtEmail.Text;
         u.Role = int.Parse(ddRole.SelectedValue);
         db.SubmitChanges();
         notSuccess.Visible = true;
     }
 }
Example #6
0
        /// <summary>
        /// Submit the form
        /// </summary>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            btnSubmit.Enabled = false; // prevent double entry
            using (WOLinqClassesDataContext db = new WOLinqClassesDataContext())
            {
                // skip approval process for designers and program managers (coordinators)
                bool IsUserDesigner = Users.IsUserDesigner();
                bool NeedsApproval = !IsUserDesigner && !Users.IsUserCoordinator();
                Workorder w = new Workorder();
                w.submitted_date = DateTime.Now;
                w.submitted_by = Function.GetUserName();
                w.wotype = 6;
                w.duedate = txtDueDate.Text.ConvertToDate();
                w.ProgramManager = int.Parse(ddCoordinators.SelectedValue);
                w.title = txtTitleVideo.Text;
                w.status = NeedsApproval ? 1 : 2;
                db.Workorders.InsertOnSubmit(w);

                WorkOrdersVideo v = new WorkOrdersVideo();
                v.Workorder = w;
                v.VideoSource = int.Parse(ddVideoSource.SelectedValue);
                v.VideoDestination = Function.GetChecklistItems(chkVideoDestination);
                v.DestinationURL = txtDestinationURL.Text;
                v.NumberDVDs = txtNumberDVDs.Text;
                v.VideoLength = txtVideoLength.Text;
                v.BackgroundMusic = ddBackgroundMusic.Value;
                v.SongChoices = txtSongChoices.Text;
                v.NarrationReqd = ddNarrationRequired.Value;
                v.Narrator = ddNarrator.SelectedIndex > 0 ? ddNarrator.SelectedIndex : (int?)null;
                v.VideoDescription = txtVideoDescription.Text;
                v.CreditsRequired = ddCreditsRequired.Value;
                v.Notes = txtNotes.Text;
                db.WorkOrdersVideos.InsertOnSubmit(v);
                db.SubmitChanges();
                int ID = w.ID;
                // upload the attached files
                WO.UploadFiles(w.ID, AttachedFiles.UploadedFiles);
                // log it
                WO.LogAction(ID, "Work order created");
                // send out the notifications if necessary
                WO.SendNewWONotification(ID, NeedsApproval, IsUserDesigner);
                // success!
                Response.Redirect("~/MyWorkOrders.aspx?success=true&ID=" + ID + "&type=" + w.wotype);
            }
        }
Example #7
0
        /// <summary>
        /// Submit the form!
        /// </summary>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            btnSubmit.Enabled = false; // prevent double submission
            using (WOLinqClassesDataContext db = new WOLinqClassesDataContext())
            {
                // if the user is a designer or coordinator, they don't need to go through the approval process
                bool IsUserDesigner = Users.IsUserDesigner();
                bool NeedsApproval = !IsUserDesigner && !Users.IsUserCoordinator();
                Workorder w = new Workorder();
                w.submitted_date = DateTime.Now;
                w.submitted_by = Function.GetUserName();
                w.wotype = 4;
                w.duedate = txtDateToIssue.Text.ConvertToDate();
                w.ProgramManager = int.Parse(ddCoordinators.SelectedValue);
                w.title = txtTitleTopic.Text;
                w.status = NeedsApproval ? 1 : 2;
                db.Workorders.InsertOnSubmit(w);
                WorkOrdersNews n = new WorkOrdersNews();
                n.Workorder = w;
                n.DistributionOutlets = int.Parse(ddDistributionOutlets.SelectedValue);
                n.DistributionDetails = txtDistributionOutletsOther.Text;
                n.Contact = txtContact.Text;
                n.AdditionalNotes = txtNotes.Text;
                db.WorkOrdersNews.InsertOnSubmit(n);
                db.SubmitChanges();
                int ID = w.ID;

                // look after the files
                WO.UploadFiles(w.ID, AttachedFiles.UploadedFiles);
                // log the work order
                WO.LogAction(ID, "Work order created");
                // send notification as needed
                WO.SendNewWONotification(ID, NeedsApproval, IsUserDesigner);

                // move on!
                Response.Redirect("~/MyWorkOrders.aspx?success=true&ID=" + ID + "&type=" + w.wotype);
            }
        }
Example #8
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     // let's make sure the username exists in AD...
     if (Classes.Users.DoesUserExist(txtUsername.Text))
     {
         using (WOLinqClassesDataContext db = new WOLinqClassesDataContext())
         {
             // next, let's make sure the user isn't already in the system...
             if (db.Users.Any(u => u.Username == txtUsername.Text))
             {
                 notSuccess.Type = Notification.Types.Error;
                 notSuccess.Message = "It looks like this user already exists in the system...";
                 notSuccess.Visible = true;
             }
             // let's create the user!
             else {
                 User u = new User();
                 u.Username = txtUsername.Text;
                 u.FullName = txtFullName.Text;
                 u.Email = txtEmail.Text;
                 u.Role = int.Parse(ddRole.SelectedValue);
                 db.Users.InsertOnSubmit(u);
                 db.SubmitChanges();
                 SendWelcomeEmail(u.Email);
                 notSuccess.Visible = true;
                 // clear the fields for next use
                 txtFullName.Text = txtEmail.Text = txtUsername.Text = String.Empty;
             }
         }
     }
     // username doesn't exist
     else
     {
         notSuccess.Type = Notification.Types.Error;
         notSuccess.Message = "Sorry - it doesn't seem that this username exists...";
         notSuccess.Visible = true;
     }
 }
Example #9
0
        /// <summary>
        /// Sets the status of a work order accordingly
        /// </summary>
        /// <param name="ID">Work order ID</param>
        /// <param name="newStatus">New status ID</param>
        /// <param name="notes">Program coordinator notes</param>
        private static void UpdateStatus(int ID, int newStatus, string notes)
        {
            using  (WOLinqClassesDataContext db = new WOLinqClassesDataContext())
            {
                Workorder wo = db.Workorders.Single(w => w.ID == ID);
                wo.status = newStatus;

                // only modify the status if it's "approved with changes"
                if (newStatus == 3)
                    wo.coordinatorNotes = notes;

                // we want to add this to the activity log as well
                LogActivity log = new LogActivity();
                log.action = "Marked '" + wo.Status1.status + "'";
                log.DateTime = DateTime.Now;
                log.username = Function.GetUserName();
                log.wID = wo.ID;
                db.LogActivities.InsertOnSubmit(log);
                db.SubmitChanges();

            }
        }
Example #10
0
 /// <summary>
 /// Removes a file entry from the db
 /// </summary>
 /// <param name="ID">File ID</param>
 /// <returns>Filepath (used by DeleteFile())</returns>
 private static string RemoveFile(int ID)
 {
     WOLinqClassesDataContext db = new WOLinqClassesDataContext();
     File f = db.Files.Single(fi => fi.ID == ID);
     if (f == null)
         return String.Empty;
     else
     {
         String filepath = HttpContext.Current.Server.MapPath("~/uploads/" + f.wID + "/" + f.Filename);
         db.Files.DeleteOnSubmit(f);
         db.SubmitChanges();
         return filepath;
     }
 }
Example #11
0
 /// <summary>
 /// Adds file information to the database
 /// </summary>
 /// <param name="wID">Work order ID</param>
 /// <param name="filename">Name of the file</param>
 /// <param name="IsRevision">Whether this was uploaded by a program manager</param>
 private static void AddFile(int wID, string filename, bool IsRevision)
 {
     WOLinqClassesDataContext db = new WOLinqClassesDataContext();
     File f = new File();
     f.wID = wID;
     f.Filename = filename;
     f.Revision = IsRevision;
     db.Files.InsertOnSubmit(f);
     db.SubmitChanges();
 }
Example #12
0
 /// <summary>
 /// Adds an action to the activity log
 /// </summary>
 /// <param name="wID">Work order ID</param>
 /// <param name="action">Text that will be added to the activity log</param>
 public static void LogAction(int wID, string action)
 {
     using (WOLinqClassesDataContext db = new WOLinqClassesDataContext())
     {
         LogActivity l = new LogActivity();
         l.DateTime = DateTime.Now;
         l.wID = wID;
         l.username = Function.GetUserName();
         l.action = action;
         db.LogActivities.InsertOnSubmit(l);
         db.SubmitChanges();
     }
 }
Example #13
0
        /// <summary>
        /// Submitting the form!
        /// </summary>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            btnSubmit.Enabled = false; // prevent double submission
            using (WOLinqClassesDataContext db = new WOLinqClassesDataContext())
            {
                // skip the approval process for designers and program managers
                bool IsUserDesigner = Users.IsUserDesigner();
                bool NeedsApproval = !IsUserDesigner && !Users.IsUserCoordinator();
                Workorder w = new Workorder();
                w.submitted_date = DateTime.Now;
                w.submitted_by = Function.GetUserName();
                w.wotype = 2;

                // decide on the duedate based on which web work order selected
                switch (Int32.Parse(ddTypeWebWork.SelectedValue))
                {
                    case 1: // new content
                        w.duedate = txtAtoZPostingDate.Text.ConvertToDate(); break;
                    case 2: // update content
                        w.duedate = txtDateToBeChanged.Text.ConvertToDate(); break;
                    case 4: // cd989 web ad
                        w.duedate = txtWebAdPostDate.Text.ConvertToDate(); break;
                    case 5: // facebook status
                        w.duedate = txtFacebookPostDate.Text.ConvertToDate(); break;
                    default:
                    case 3: // new website
                        w.duedate = DateTime.Today; break;
                }
                w.ProgramManager = int.Parse(ddCoordinators.SelectedValue);
                w.title = ddTypeWebWork.SelectedIndex > 0 ? ddTypeWebWork.SelectedItem.Text : "Unspecified";
                w.status = NeedsApproval ? 1 : 2;
                db.Workorders.InsertOnSubmit(w);

                WorkOrdersWeb wow = new WorkOrdersWeb();
                wow.Workorder = w;
                wow.TypeWebWork = ddTypeWebWork.SelectedIndex > 0 ? int.Parse(ddTypeWebWork.SelectedValue) : (int?)null;
                wow.Website = ddWebsite.SelectedIndex > 0 ? int.Parse(ddWebsite.SelectedValue) : (int?)null;
                wow.Location = Function.GetChecklistItems(chkLocation);
                wow.AtoZLocation = txtAtoZLocation.Text;
                wow.AtoZPostingDate = txtAtoZPostingDate.Text.ConvertToDate();
                wow.AtoZRemovalDate = txtAtoZRemovalDate.Text.ConvertToDate();
                wow.AtoZHeading = txtAtoZHeading.Text;
                wow.AtoZContent = txtAtoZContent.Text;
                wow.CalEventName = txtCalEventName.Text;
                wow.CalEventLocation = txtCalEventLocation.Text;
                wow.CalEventStartDate = txtCalStartDate.Text.ConvertToDate();
                wow.CalEventStartTime = txtCalStartTime.Text;
                wow.CalEventEndDate = txtCalEndDate.Text.ConvertToDate();
                wow.CalEventEndTime = txtCalEndTime.Text;
                wow.ContactName = txtContactName.Text;
                wow.ContactEmail = txtContactEmail.Text;
                wow.EventDescription = txtEventDesc.Text;
                wow.DateToBePosted = txtDatePosted.Text.ConvertToDate();
                wow.TypeOfUpdate = ddTypeOfUpdate.SelectedIndex > 0 ? int.Parse(ddTypeOfUpdate.SelectedValue) : (int?)null;
                wow.DateToBeChanged = txtDateToBeChanged.Text.ConvertToDate();
                wow.UpdateLocation = txtURL.Text;
                wow.UpdateDescription = txtUpdateDesc.Text;
                wow.Budget = txtBudget.Text;
                wow.Timeframe = txtTimeFrame.Text;
                wow.Goals = txtGoals.Text;
                wow.Explanation = txtExplanation.Text;
                wow.Audience = txtAudience.Text;
                wow.NumberOfPages = txtNumberOfPages.Text;
                wow.WebAdPostDate = txtWebAdPostDate.Text.ConvertToDate();
                wow.WebAdEndDate = txtWebAdEndDate.Text.ConvertToDate();
                wow.WebAdURL = txtWebAdURL.Text;
                wow.WebAdContent = txtWebAdContent.Text;
                wow.FacebookPostDate = txtFacebookPostDate.Text.ConvertToDate();
                wow.FacebookContent = txtFacebookContent.Text;
                wow.Notes = txtNotes.Text;

                // if this was added on to a Print work order, let's link this to it!
                int pID = 0;
                if (int.TryParse(Request.QueryString["AddTo"], out pID))
                {
                    wow.pID = pID;
                }
                else
                    wow.pID = null;
                db.WorkOrdersWebs.InsertOnSubmit(wow);
                db.SubmitChanges();
                int ID = w.ID;

                // if we're linking print and web work orders, let's add the link to the print work order too so we can go back and forth easily
                if (pID != 0)
                {
                    WorkOrdersPrint p = db.WorkOrdersPrints.Single(u => u.wID == pID);
                    p.webID = ID;
                    db.SubmitChanges();
                }
                // upload attached files
                WO.UploadFiles(ID, AttachedFiles.UploadedFiles);
                // log actions
                WO.LogAction(ID, "Work order created.");
                // send notifications if necessary
                WO.SendNewWONotification(ID, NeedsApproval, IsUserDesigner);
                // redirect! hooray!
                Response.Redirect("~/MyWorkOrders.aspx?success=true&ID=" + ID + "&type=" + w.wotype);
            }
        }