bool ICollectionPointService.DeleteCollectionPoint(int collectionPointID)
        {
            int code = collectionPointID;
            Collection_Point collectionPoint = collectionPointDAO.FindByCollectionPointID(code);

            return(collectionPointDAO.DeleteCollectionPoint(code));
        }
        protected void Page_Load(object sender, EventArgs e)

        {
            loginUSer = User.Identity.Name;
            UserModel user = new UserModel(loginUSer);

            headUSerName = user.FindDelegateOrDeptHead().Username;
            sdept        = user.Department;


            //sdept = (Department)Session["sDept"];
            LabelContactName.Text = new UserModel(sdept.contact_user).Fullname;
            LabelPhNo.Text        = sdept.contact_num.ToString();
            LabelFaxNo.Text       = sdept.fax_num.ToString();
            currentCollectId      = sdept.collection_point;

            Collection_Point cp = context.Collection_Point.SingleOrDefault(x => x.collection_pt_id == currentCollectId);

            lbCollectP.Text = cp.location + " (" + cp.day_of_week + " -" + cp.date_time.TimeOfDay + " )";
            lbRepName.Text  = changeUsernameToFullName(sdept.rep_user.ToString());

            if (!IsPostBack)
            {
                ddlDataBinding();
            }
        }
Exemple #3
0
 public Collection_Point FindByCollectionPointID(int id)
 {
     using (StationeryModel entity = new StationeryModel())
     {
         Collection_Point cp = entity.Collection_Points.Where(x => x.collectionPointID == id).First();
         return(cp);
     }
 }
Exemple #4
0
        public static WCFCollectionPoint convertToWCFCollectionPoint(Collection_Point cp)
        {
            WCFCollectionPoint wcfcp = new WCFCollectionPoint();

            wcfcp.Collection_Point_Name = cp.collectionPointName;
            wcfcp.Collection_Point_ID   = cp.collectionPointID;


            return(wcfcp);
        }
        private Collection_Point ConvertFromViewModel(CollectionPointViewModel cpVM)
        {
            Collection_Point collectionPoint = new Collection_Point();

            collectionPoint.collectionPointID   = cpVM.collectionPointID;
            collectionPoint.collectionPointName = cpVM.collectionPointName;


            return(collectionPoint);
        }
        private CollectionPointViewModel ConvertToViewModel(Collection_Point collectionPoint)
        {
            CollectionPointViewModel cpVM = new CollectionPointViewModel();

            cpVM.collectionPointID   = collectionPoint.collectionPointID;
            cpVM.collectionPointName = collectionPoint.collectionPointName;


            return(cpVM);
        }
        private void FillPage()
        {
            // need to login
            if (!User.Identity.IsAuthenticated)
            {
                Response.Redirect("~/login.aspx?return=Views/DepartmentHead/HeadDashboard.aspx");
            }

            string    username    = User.Identity.Name.ToString();
            UserModel user        = new UserModel(username);
            string    currentDept = user.Department.dept_code;
            var       requestInfo = (from o in context.Requests
                                     where (currentDept == o.dept_code) && (o.current_status == RequestStatus.PENDING | o.current_status == RequestStatus.UPDATED)
                                     select new { o.request_id, o.username, o.date_time, o.reason }).ToList();

            GridView1.DataSource = requestInfo;
            GridView1.DataBind();
            string pendingnum = GridView1.Rows.Count.ToString();

            lblPendingNum.Text = "You Have " + pendingnum + " Requests(s) to View";

            string currentUser = Page.User.Identity.Name;
            string fullName    = "";

            using (SSISEntities context = new SSISEntities())
            {
                fullName = context.Dept_Registry.Find(currentUser).fullname;
            }
            lblFullName.Text = "Welcome, " + fullName;

            Department       dept     = context.Departments.Where(x => currentDept == x.dept_code).First();
            Collection_Point colpoint = context.Collection_Point.Where(y => y.collection_pt_id == dept.collection_point).First();
            Dept_Registry    dr       = context.Dept_Registry.Where(x => x.username == dept.rep_user).First();

            lblrep.Text      = dr.fullname;
            lblcolpoint.Text = colpoint.location + " (" + colpoint.day_of_week + " - " + colpoint.date_time.ToShortTimeString() + ")";

            var deldept = (from x in context.Approval_Duties select x.dept_code).ToList();

            if (deldept.Contains(currentDept))
            {
                List <Approval_Duties> ads = context.Approval_Duties.Where(x => currentDept == x.dept_code).ToList();
                foreach (Approval_Duties ad in ads)
                {
                    DateTime start = ad.start_date;
                    DateTime end   = ad.end_date;
                    if ((DateTime.Now > start && DateTime.Now < end) && (ad.deleted == "N"))
                    {
                        lbldelegation.Text = ad.username + " (" + start + " - " + end + ")";
                        break;
                    }
                }
            }
        }
        bool ICollectionPointService.UpdateCollectionPointInfo(CollectionPointViewModel cpVM)
        {
            Collection_Point collectionPoint = ConvertFromViewModel(cpVM);

            if (collectionPointDAO.UpdateCollectionPointInfo(collectionPoint) == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #9
0
        private void FillPage(string deptcode)
        {
            Department       d  = context.Departments.Find(deptcode);
            Collection_Point cp = context.Collection_Point.Where(x => x.collection_pt_id == d.collection_point).First();

            lbldeptname.Text  = d.name;
            lblhead.Text      = new UserModel(d.head_user).Fullname;
            lblrep.Text       = new UserModel(d.rep_user).Fullname;
            lblconname.Text   = new UserModel(d.contact_user).Fullname;
            lblconnum.Text    = d.contact_num;
            lblfax.Text       = d.fax_num;
            lblcollpoint.Text = cp.location + " on " + cp.day_of_week + " at " + cp.date_time.ToShortTimeString();
        }
Exemple #10
0
        private void _sendEmail(string currentUser, List<string> deptCodes)
        {
            UserModel currentUserModel = new UserModel(currentUser);

            List<UserModel> repUsers = new List<UserModel>();

            using (SSISEntities context = new SSISEntities())
            {
                foreach (var deptCode in deptCodes)
                {
                    string repUser = context.Departments.Find(deptCode).rep_user;
                    UserModel repUserModel = new UserModel(repUser);

                    repUsers.Add(repUserModel);
                }

                /* Email logic */
                string fromEmail = currentUserModel.Email;
                string fromName = currentUserModel.Fullname;
                //UserModel deptHead = currentUserModel.FindDelegateOrDeptHead();

                foreach (var repUserModel in repUsers)
                {
                    string toEmail = repUserModel.Email;
                    string toName = repUserModel.Fullname;

                    string subject = string.Format("New disbursement for collection");
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("Dear " + toName + ",");
                    sb.AppendLine("<br />");
                    sb.AppendLine("<br />");
                    sb.AppendLine(string.Format("{0} has scheduled some items for collection.", fromName));
                    sb.AppendLine("<br />");
                    Collection_Point collectionPt = repUserModel.Department.Collection_Point1;
                    sb.AppendLine(string.Format("The collecton point is: {0}, on {1} at {2}.", collectionPt.location, collectionPt.day_of_week, collectionPt.date_time.ToShortTimeString()));
                    sb.AppendLine("<br />");
                    sb.AppendLine(string.Format("Please <a href=\"{0}\">follow this link to login to the system</a>.", "https://rebrand.ly/ssis-login"));
                    sb.AppendLine("<br />");
                    sb.AppendLine("<br />");
                    sb.AppendLine("Thank you.");
                    sb.AppendLine("<br />");
                    sb.AppendLine("<br />");
                    sb.AppendLine("<i>This message was auto-generated by the Stationery Store Inventory System.</i>");

                    string body = sb.ToString();

                    new Emailer(fromEmail, fromName).SendEmail(toEmail, toName, subject, body);
                }
            }
            /* End of email logic */
        }
Exemple #11
0
        bool ICollectionPointDAO.DeleteCollectionPoint(int collectionPointID)
        {
            using (StationeryModel context = new StationeryModel())
            {
                Collection_Point collectionPoint = (from s in context.Collection_Points
                                                    where s.collectionPointID == collectionPointID
                                                    select s).FirstOrDefault();

                context.Collection_Points.Remove(collectionPoint);
                context.SaveChanges();

                return(true);
            }
        }
Exemple #12
0
        bool ICollectionPointDAO.AddNewCollectionPoint(Collection_Point collectionPoint)
        {
            using (StationeryModel context = new StationeryModel())
            {
                context.Collection_Points.Add(collectionPoint);
                int rowAffected = context.SaveChanges();

                if (rowAffected != 1)
                {
                    throw new DAOException();
                }

                return(true);
            }
        }
Exemple #13
0
        int ICollectionPointDAO.UpdateCollectionPointInfo(Collection_Point collectionPoint)
        {
            using (StationeryModel context = new StationeryModel())
            {
                Collection_Point c = (from x in context.Collection_Points
                                      where x.collectionPointID == collectionPoint.collectionPointID
                                      select x).FirstOrDefault();

                c.collectionPointName = collectionPoint.collectionPointName;


                int rowAffected = context.SaveChanges();

                return(rowAffected);
            }
        }