コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Trip trip = null;

            if (!IsPostBack)
            {
                if (Request.QueryString["id"] != null)
                {
                    int Id = Convert.ToInt32(Request.QueryString["id"].ToString());
                    hid.Value = Id.ToString();
                    BindGrid(Id);
                    trip = TripBLL.GetTripDetailByID(Id);
                    if (trip.Status == (int)Utility.FleetRequestStatus.Pending_Supervisor_Approval)
                    {
                        LinkButton1.Visible = true;
                        LinkButton2.Visible = true;
                    }
                    if (trip != null)
                    {
                        lbheader.Text = trip.ID.ToString();
                        lbInit.Text   = trip.InitiatorName.ToUpper();
                    }
                }
                else
                {
                    Response.Redirect("MyFleetRequest.aspx", false);
                }
            }
        }
コード例 #2
0
        private void BindGrid()
        {
            string RequestID = ""; string status = ""; usr = (User)Session["user"];
            string init = ""; string fromDate = ""; string toDate = "";

            if (!string.IsNullOrWhiteSpace(txtID.Text))
            {
                RequestID = txtID.Text;
            }
            if (!string.IsNullOrWhiteSpace(txtInit.Text))
            {
                init = txtInit.Text;
            }
            if (!string.IsNullOrWhiteSpace(ddlStatus.SelectedValue))
            {
                status = ddlStatus.SelectedValue;
            }
            if (!string.IsNullOrWhiteSpace(txtFromDate.Text))
            {
                fromDate = txtFromDate.Text;
            }

            if (!string.IsNullOrWhiteSpace(txtToDate.Text))
            {
                toDate = txtToDate.Text;
            }
            gvRequest.DataSource = TripBLL.GetTripListByAdmin(usr.LocationID.Value, RequestID, status, init, fromDate, toDate);
            gvRequest.DataBind();
            //gvRequest.DataSource = TripBLL.GetTripListByAdmin();
            //gvRequest.DataBind();
        }
コード例 #3
0
        protected void BindLogGrid()
        {
            int id = int.Parse(hid.Value);

            gvLog.DataSource = TripBLL.GetTripListByID(id).Where(t => t.Status == (int)Utility.FleetRequestStatus.Completed).ToList();
            gvLog.DataBind();
        }
コード例 #4
0
        private void BindTrip()
        {
            usr = (User)Session["user"];
            int id = int.Parse(hid.Value);

            gvTrip.DataSource = TripBLL.GetTripListByAdmin(usr.LocationID.Value).Where(p => p.AssignedVehicle == id).ToList();
            gvTrip.DataBind();
        }
コード例 #5
0
        public JsonResult drawStops(string Data)
        {
            TripBLL tripbl = new TripBLL();

            var res = new { lat = tripbl.getBusstopsLatByRouteID(int.Parse(Data)).ToArray(), lon = tripbl.getBusstopsLonByRouteID(int.Parse(Data)).ToArray() };

            return(Json(res));
        }
コード例 #6
0
        protected void lnkHold_Click(object sender, EventArgs e)
        {
            try
            {
                int  requestId = Convert.ToInt32(hid.Value);
                Trip trip      = TripBLL.GetTripDetailByID(requestId);
                if (trip != null)
                {
                    trip.Status = (int)Utility.FleetRequestStatus.OnHold;
                    if (TripBLL.UpdateTrip(trip))
                    {
                        lnkCheckAvailabity.Visible = false;
                        lnkHold.Enabled            = false;
                        BindGrid(requestId);
                        //send email to requestor
                        string body = "";
                        string from = ConfigurationManager.AppSettings["exUser"].ToString();

                        string appLogo  = ConfigurationManager.AppSettings["appLogoUrl"].ToString();
                        string siteUrl  = ConfigurationManager.AppSettings["siteUrl"].ToString();
                        string subject  = "Fleet Request Notification";
                        string FilePath = Server.MapPath("EmailTemplates/");
                        if (File.Exists(FilePath + "RequestOnHoldNotification.htm"))
                        {
                            FileStream   f1 = new FileStream(FilePath + "RequestOnHoldNotification.htm", FileMode.Open);
                            StreamReader sr = new StreamReader(f1);
                            body = sr.ReadToEnd();
                            body = body.Replace("@add_appLogo", appLogo);
                            body = body.Replace("@add_siteUrl", siteUrl);
                            body = body.Replace("@add_comment", txtComment.Text);
                            body = body.Replace("@add_requestID", trip.ID.ToString());
                            // body = body.Replace("@add_approver", usr.StaffName); //Replace the values from DB or any other source to personalize each mail.
                            f1.Close();
                        }
                        try
                        {
                            string rst2 = Utility.SendMail(trip.InitiatorEmail, from, "", subject, body);
                        }
                        catch { }
                        success.Visible   = true;
                        success.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> Request has been successfully Declined. Notifications has been sent to Initiator";
                    }
                    else
                    {
                        error.Visible   = true;
                        error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred while updating status.. kindly try again!!!";
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
コード例 #7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (Session["user"] != null)
         {
             usr = (User)Session["user"];
         }
         else
         {
             Response.Redirect("../Login.aspx", false);
             return;
         }
         if (!IsPostBack)
         {
             if (User.IsInRole(GssAdminRole))
             {
                 btnBatchAppr.Visible = true;
                 dvbatch.Visible      = true;
             }
             if (User.IsInRole(headDriverRole))
             {
                 btnBatch.Visible = true;
                 BindVehicleGrid();
             }
             if (Request.QueryString["vid"] != null)
             {
                 int vId = int.Parse(Request.QueryString["vid"].ToString());
                 gvRequest.DataSource = TripBLL.GetTripListByAdmin(usr.LocationID.Value).Where(t => t.AssignedVehicle == vId).ToList();
                 gvRequest.DataBind();
             }
             else if (Request.QueryString["stat"] != null)
             {
                 int stId = int.Parse(Request.QueryString["stat"].ToString());
                 gvRequest.DataSource = TripBLL.GetTripListByAdmin(usr.LocationID.Value).Where(t => t.Status == stId).ToList();
                 gvRequest.DataBind();
             }
             else
             {
                 BindGrid();
             }
             BindList();
         }
     }
     catch (Exception ex)
     {
         error.Visible   = true;
         error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred. kindly try again!!!";
         Utility.WriteError("Error: " + ex.InnerException);
     }
 }
コード例 #8
0
        private void BindGridAppr()
        {
            User usr = null;

            if (Session["user"] != null)
            {
                usr = (User)Session["user"];
            }
            else
            {
                Response.Redirect("Login.aspx", false);
                return;
            }
            gvRequestAppr.DataSource = TripBLL.GetFleetRequestApprovedByUser(usr.ID, (int)Utility.FleetRequestStatus.Pending_Supervisor_Approval);
            gvRequestAppr.DataBind();
        }
コード例 #9
0
 protected void btnSearch_Click(object sender, EventArgs e)
 {
     try
     {
         if (!string.IsNullOrWhiteSpace(txtSea.Value))
         {
             int RequestID = Convert.ToInt32(txtSea.Value);
             gvRequestAppr.DataSource = TripBLL.GetTripListByID(RequestID).Where(p => p.Status > (int)Utility.FleetRequestStatus.Pending_Supervisor_Approval).ToList();
             gvRequestAppr.DataBind();
         }
     }
     catch (Exception ex)
     {
         error.Visible   = true;
         error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred. kindly try again!!!";
         Utility.WriteError("Error: " + ex.InnerException);
     }
 }
コード例 #10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (!User.Identity.IsAuthenticated)
         {
             Response.Redirect("Login.aspx", false);
             return;
         }
         Trip trip = null;
         if (!IsPostBack)
         {
             if (Request.QueryString["id"] != null)
             {
                 int Id = Convert.ToInt32(Request.QueryString["id"].ToString());
                 hid.Value = Id.ToString();
                 BindGrid(Id);
                 trip = TripBLL.GetTripDetailByID(Id);
                 if (trip != null)
                 {
                     lbheader.Text = trip.ID.ToString();
                     lbInit.Text   = trip.InitiatorName.ToUpper();
                     if (trip.Status == (int)Utility.FleetRequestStatus.Enroute || trip.Status == (int)Utility.FleetRequestStatus.Completed || trip.Status == (int)Utility.FleetRequestStatus.Declined || trip.Status == (int)Utility.FleetRequestStatus.Cancelled)
                     {
                         LinkButton1.Visible = false;
                     }
                 }
             }
             else
             {
                 Response.Redirect("MyFleetRequest.aspx", false);
                 return;
             }
         }
     }
     catch (Exception ex)
     {
         error.Visible   = true;
         error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred. kindly try again!!!";
         Utility.WriteError("Error: " + ex.InnerException);
         return;
     }
 }
コード例 #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            User usr = null;

            if (!IsPostBack)
            {
                if (Session["user"] != null)
                {
                    usr = (User)Session["user"];
                }
                else
                {
                    Response.Redirect("../Login.aspx", false);
                    return;
                }
                int totalPendAppr = 0; int totalPendAss = 0; int totalCmpRequest = 0; int totalVehPool = 0; int totalvehEnt = 0;
                totalPendAppr   = TripBLL.GetTripListByAdmin(usr.LocationID.Value).Where(t => t.Status == (int)Utility.FleetRequestStatus.Pending_FleetManager_Approval).Count();
                totalPendAss    = TripBLL.GetTripListByAdmin(usr.LocationID.Value).Where(t => t.Status == (int)Utility.FleetRequestStatus.Pending_Vehicle_Assignment).Count();
                totalCmpRequest = TripBLL.GetTripListByAdmin(usr.LocationID.Value).Where(t => t.Status == (int)Utility.FleetRequestStatus.Completed).Count();
                totalVehPool    = VehicleBLL.GetVehicleList(usr.LocationID.Value).Where(t => t.Status == (int)Utility.VehicleStatus.Available).Count();
                totalvehEnt     = VehicleBLL.GetVehicleList(usr.LocationID.Value).Where(t => t.Status == (int)Utility.VehicleStatus.Enroute).Count();
                //lnkPendAppr.Text = "Total Number of Requests pending Approval ("+totalPendAppr.ToString()+")";
                //lnkPendAppr.NavigateUrl = "ManageFleetRequest.aspx?stat=" + ((int)Utility.FleetRequestStatus.Pending_FleetManager_Approval).ToString();
                lnkPendAppr1.InnerHtml = "Total Number of Requests pending Approval<b> (" + totalPendAppr.ToString() + ")</b>";
                lnkPendAppr1.HRef      = "ManageFleetRequest.aspx?stat=" + ((int)Utility.FleetRequestStatus.Pending_FleetManager_Approval).ToString();

                lnkpendAss.InnerHtml = "Total Number of Requests pending Vehicle Assignment <b>(" + totalPendAss.ToString() + ")</b>";
                lnkpendAss.HRef      = "ManageFleetRequest.aspx?stat=" + ((int)Utility.FleetRequestStatus.Pending_Vehicle_Assignment).ToString();

                lnkCmpReq.InnerHtml = "Total Number of Completed Request (<b>" + totalCmpRequest.ToString() + ")</b>";
                lnkCmpReq.HRef      = "ManageFleetRequest.aspx?stat=" + ((int)Utility.FleetRequestStatus.Completed).ToString();

                lnkVehPool.InnerHtml = "Total Number of Vehicles Available in the Pool <b>(" + totalVehPool + ")</b>";
                lnkVehPool.HRef      = "ManageVehicle.aspx?stat=" + ((int)Utility.VehicleStatus.Available).ToString();

                lnkvehEnt.InnerHtml = "Total Number of Vehicles Enroute <b>(" + totalvehEnt + ")</b>";
                lnkvehEnt.HRef      = "ManageVehicle.aspx?stat=" + ((int)Utility.VehicleStatus.Enroute).ToString();
            }
        }
コード例 #12
0
        protected void btnbtnAppr_Click(object sender, EventArgs e)
        {
            try
            {
                User usr = null;
                if (Session["user"] != null)
                {
                    usr = (User)Session["user"];
                }
                else
                {
                    Response.Redirect("Login.aspx", false);
                    return;
                }
                int  requestId = Convert.ToInt32(hid.Value);
                Trip trip      = TripBLL.GetTripDetailByID(requestId);
                if (trip != null)
                {
                    trip.Status = (int)Utility.FleetRequestStatus.Pending_FleetManager_Approval;

                    if (TripBLL.UpdateTrip(trip))
                    {
                        LinkButton1.Enabled = false;
                        LinkButton2.Visible = false;
                        BindGrid(requestId);
                        ///send mail to fleet manager...
                        {
                            string body     = "";
                            string from     = ConfigurationManager.AppSettings["exUser"].ToString();
                            string rolname  = ConfigurationManager.AppSettings["GssAdminRole"].ToString();
                            string to       = Utility.GetUsersEmailAdd(rolname, trip.LocationID.Value);
                            string appLogo  = ConfigurationManager.AppSettings["appLogoUrl"].ToString();
                            string siteUrl  = ConfigurationManager.AppSettings["siteUrl"].ToString();
                            string subject  = "Fleet Request Approval Notification";
                            string FilePath = Server.MapPath("EmailTemplates/");
                            if (File.Exists(FilePath + "FleetManagerNotification.htm"))
                            {
                                FileStream   f1 = new FileStream(FilePath + "FleetManagerNotification.htm", FileMode.Open);
                                StreamReader sr = new StreamReader(f1);
                                body = sr.ReadToEnd();
                                body = body.Replace("@add_appLogo", appLogo);
                                body = body.Replace("@add_siteUrl", siteUrl + "?RequestId=" + trip.ID.ToString());
                                body = body.Replace("@add_requestor", trip.InitiatorName);
                                body = body.Replace("@priority", Utility.GetPriority(trip.priority));
                                body = body.Replace("@add_Destination", trip.Destination); //Replace the values from DB or any other source to personalize each mail.
                                body = body.Replace("@add_purpose", trip.Purpose);
                                body = body.Replace("@add_tripDate", trip.TripDate.Value.ToString("dd-MMM-yyyy"));
                                body = body.Replace("@add_DeptTime", trip.ExpectedDepartureTime);
                                body = body.Replace("@add_approver", usr.StaffName);
                                body = body.Replace("@add_comment", txtCommentAppr.Text);
                                f1.Close();
                            }
                            try
                            {
                                User hod = null;
                                if (usr.isHoD == false)
                                {
                                    hod = UserBLL.GetDeptHOD(usr.DepartmentID.Value);
                                }
                                if (hod != null)
                                {
                                    string rst = Utility.SendMail(to, from, hod.Email.Trim(), subject, body);
                                }
                                else
                                {
                                    string rst = Utility.SendMail(to, from, "", subject, body);
                                }
                            }
                            catch { }

                            /////send mail to Requestor...
                            {
                                string body1 = "";
                                string from1 = ConfigurationManager.AppSettings["exUser"].ToString();


                                string subject1  = "Fleet Request Notification";
                                string FilePath1 = Server.MapPath("EmailTemplates/");
                                if (File.Exists(FilePath1 + "RequestorStatusNotification.htm"))
                                {
                                    FileStream   f1 = new FileStream(FilePath1 + "RequestorStatusNotification.htm", FileMode.Open);
                                    StreamReader sr = new StreamReader(f1);
                                    body1 = sr.ReadToEnd();
                                    body1 = body1.Replace("@add_appLogo", appLogo);
                                    body1 = body1.Replace("@add_siteUrl", siteUrl);
                                    //body1 = body1.Replace("@add_requestor", trip.InitiatorName);
                                    body1 = body1.Replace("@add_requestID", trip.ID.ToString());
                                    body1 = body1.Replace("@add_msg", "and it is currently <b>pending FleetManager approver</b>");
                                    body1 = body1.Replace("@add_approver", usr.StaffName); //Replace the values from DB or any other source to personalize each mail.
                                    body1 = body1.Replace("@add_comment", txtCommentAppr.Text);
                                    f1.Close();
                                }
                                try
                                {
                                    string rst2 = Utility.SendMail(trip.InitiatorEmail, from1, "", subject1, body1);
                                }
                                catch { }
                            }
                            success.Visible   = true;
                            success.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> Request has been successfully approved. Notifications has been sent to Fleet Manager for further action on the request";
                        }
                    }
                    else
                    {
                        error.Visible   = true;
                        error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred while updating request.. kindly try again!!!";
                        return;
                    }
                }
                else
                {
                    error.Visible   = true;
                    error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred while retrieving request.. kindly try again!!!";
                    return;
                }
            }
            catch (Exception ex)
            {
                error.Visible   = true;
                error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred. kindly try again!!!";
                Utility.WriteError("Error: " + ex.InnerException);
                return;
            }
        }
コード例 #13
0
 private void BindGrid(int id)
 {
     gvheader.DataSource = TripBLL.GetTripListByID(id);
     gvheader.DataBind();
 }
コード例 #14
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                string   dTime    = Request.Form["timepicker1"].ToString();
                string   aTime    = Request.Form["timepicker2"].ToString();
                string[] dTimeArg = dTime.Split(new char[] { ':', ' ' });
                string[] aTimeArg = aTime.Split(new char[] { ':', ' ' });
                int      aHr      = int.Parse(aTimeArg[0]);
                int      aMin     = int.Parse(aTimeArg[1]);
                int      dHr      = int.Parse(dTimeArg[0]);
                int      dMin     = int.Parse(dTimeArg[1]);
                string   afrmt    = aTimeArg[2];
                string   dfrmt    = dTimeArg[2];
                if (dfrmt == afrmt)
                {
                    if (dHr > aHr && dHr != 12)
                    {
                        error.Visible   = true;
                        error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button>Sorry Departure Time could not be greater than Arrival time";

                        return;
                    }
                    if (dHr == aHr && dMin >= aMin)
                    {
                        error.Visible   = true;
                        error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button>Sorry Departure Time could not be greater than Arrival time";
                        UpdatePanel1.Update();
                        return;
                    }
                }
                if (dfrmt == "PM" && dHr != 12)
                {
                    dHr += 12;
                }
                if (afrmt == "PM" && aHr != 12)
                {
                    aHr += 12;
                }
                if (dfrmt == "AM" && dHr == 12)
                {
                    //dHr -= 12;
                }
                if (afrmt == "AM" && aHr == 12)
                {
                    // aHr -= 12;
                }
                string  dMinPad   = dMin.ToString().PadRight(2, '0');
                string  aMinPad   = aMin.ToString().PadRight(2, '0');
                decimal dpartTime = decimal.Parse(dHr.ToString() + "." + dMinPad);
                decimal arrTime   = decimal.Parse(aHr.ToString() + "." + aMin);
                decimal duration  = 0;
                duration = Utility.GetTripDuration(dHr, dMin, aHr, aMin);
                //if (dfrmt == afrmt && dHr == 12)
                //{
                //    duration = arrTime - dpartTime;
                //    duration += 12;
                //}
                //else
                //{
                //    duration = arrTime - dpartTime;
                //}

                Trip trip = new Trip();
                trip.Location       = ddlLocation.SelectedItem.Text.Trim();
                trip.LocationID     = int.Parse(ddlLocation.SelectedValue);
                trip.PickupLocation = txtLoc.Text;
                trip.Destination    = txtDesn.Text;
                trip.Purpose        = txtPur.Text;
                trip.TripDate       = DateTime.Parse(txtDate.Text, culture);
                trip.DateAdded      = DateTime.Now;
                trip.InitiatorID    = User.Identity.Name;
                User usr = new User();
                if (Session["user"] != null)
                {
                    usr = (User)Session["user"];
                    trip.InitiatorName  = usr.StaffName;
                    trip.InitiatorEmail = usr.Email;
                }
                else
                {
                    Response.Redirect("Login.aspx", false);
                    return;
                }
                int userId = int.Parse(ddlDeptApproval.SelectedValue);
                trip.ApproverIDLeve1 = userId;
                User appr = UserBLL.GetByID(userId);
                if (appr != null)
                {
                    trip.DepartmentID = appr.DepartmentID;
                }
                else
                {
                    error.Visible   = true;
                    error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred in retrieving approver's detail. kindly try again";
                    return;
                }
                trip.ExpectedDepartureTime = dTime;
                trip.ExpectedReturnTime    = aTime;
                trip.ExpectedDuration      = duration;
                trip.priority = int.Parse(ddlPriority.SelectedValue);
                trip.Status   = (int)Utility.FleetRequestStatus.Pending_Supervisor_Approval;
                if (TripBLL.AddTrip(trip))
                {
                    //send email to supervisor
                    string body    = "";
                    string from    = ConfigurationManager.AppSettings["exUser"].ToString();
                    string appLogo = ConfigurationManager.AppSettings["appLogoUrl"].ToString();
                    string siteUrl = ConfigurationManager.AppSettings["siteUrl"].ToString();

                    string subject  = "Fleet Request Approval Notification";
                    string FilePath = Server.MapPath("EmailTemplates/");
                    if (File.Exists(FilePath + "ApprovalNotification.htm"))
                    {
                        FileStream   f1 = new FileStream(FilePath + "ApprovalNotification.htm", FileMode.Open);
                        StreamReader sr = new StreamReader(f1);
                        body = sr.ReadToEnd();
                        body = body.Replace("@add_appLogo", appLogo);
                        body = body.Replace("@add_siteUrl", siteUrl + "?id=" + trip.ID.ToString());
                        //body = body.Replace("@add_fname",appr.StaffName);
                        body = body.Replace("@add_username", usr.StaffName);
                        body = body.Replace("@add_Destination", txtDesn.Text); //Replace the values from DB or any other source to personalize each mail.
                        body = body.Replace("@add_purpose", txtPur.Text);
                        body = body.Replace("@add_tripDate", txtDate.Text);
                        body = body.Replace("@add_DepartTime", dTime);
                        body = body.Replace("@add_DepartTime", dTime);
                        body = body.Replace("@add_Return", aTime);
                        f1.Close();
                    }
                    string rst = Utility.SendMail(appr.Email, from, "", subject, body);
                    if (rst.Contains("Successful"))
                    {
                        Reset();
                        Response.Redirect("SuccessRequest.aspx", false);
                        return;
                    }
                    else
                    {
                        Reset();
                        Response.Redirect("SuccessRequest.aspx", false);
                        return;
                    }
                }
            }

            catch (Exception ex)
            {
                error.Visible   = true;
                error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred. kindly try again!!!";
                Utility.WriteError("Error: " + ex.InnerException);
                return;
            }
        }
コード例 #15
0
        protected void lnkAppr_Click(object sender, EventArgs e)
        {
            User usr = null;

            if (Session["user"] != null)
            {
                usr = (User)Session["user"];
            }
            else
            {
                Response.Redirect("../Login.aspx", false);
                return;
            }
            try
            {
                int  requestId = Convert.ToInt32(hid.Value);
                Trip trip      = TripBLL.GetTripDetailByID(requestId);
                if (trip != null)
                {
                    trip.Status           = (int)Utility.FleetRequestStatus.Pending_Vehicle_Assignment;
                    trip.ApproverIDlevel2 = usr.ID;
                    trip.DateApproved     = DateTime.Now;
                    if (TripBLL.UpdateTrip(trip))
                    {
                        BindGrid(requestId);
                        lnkAppr.Enabled   = false;
                        lnkReject.Visible = false;
                        lnkHold.Visible   = false;
                        //Send mail and sms to HeadDriver
                        string body     = "";
                        string from     = ConfigurationManager.AppSettings["exUser"].ToString();
                        string rolname  = ConfigurationManager.AppSettings["HeadDriverRole"].ToString();
                        string to       = Utility.GetUsersEmailAdd(rolname, trip.LocationID.Value);
                        string appLogo  = ConfigurationManager.AppSettings["appLogoUrl"].ToString();
                        string siteUrl  = ConfigurationManager.AppSettings["siteUrl"].ToString();
                        string subject  = "Fleet Request Approval Notification";
                        string FilePath = Server.MapPath("EmailTemplates/");
                        if (File.Exists(FilePath + "HeadDriverNotification.htm"))
                        {
                            FileStream   f1 = new FileStream(FilePath + "HeadDriverNotification.htm", FileMode.Open);
                            StreamReader sr = new StreamReader(f1);
                            body = sr.ReadToEnd();
                            body = body.Replace("@add_appLogo", appLogo);
                            body = body.Replace("@add_siteUrl", siteUrl);
                            body = body.Replace("@add_requestor", trip.InitiatorName);
                            body = body.Replace("@priority", Utility.GetPriority(trip.priority));
                            body = body.Replace("@add_Destination", trip.Destination);     //Replace the values from DB or any other source to personalize each mail.
                            body = body.Replace("@add_purpose", trip.Purpose);
                            body = body.Replace("@add_tripDate", trip.TripDate.Value.ToString("dd-MMM-yyyy"));
                            body = body.Replace("@add_DeptTime", trip.ExpectedDepartureTime);
                            body = body.Replace("@add_approver", usr.StaffName);
                            body = body.Replace("@add_batch", "N/A");
                            f1.Close();
                            try
                            {
                                string rst = Utility.SendMail(to, from, "", subject, body);
                            }
                            catch { }
                        }
                        //send a mail to requestor
                        string body1     = "";
                        string from1     = ConfigurationManager.AppSettings["exUser"].ToString();
                        string subject1  = "Fleet Request Notification";
                        string FilePath1 = Server.MapPath("EmailTemplates/");
                        if (File.Exists(FilePath1 + "RequestorStatusNotification.htm"))
                        {
                            FileStream   f1 = new FileStream(FilePath1 + "RequestorStatusNotification.htm", FileMode.Open);
                            StreamReader sr = new StreamReader(f1);
                            body1 = sr.ReadToEnd();
                            body1 = body1.Replace("@add_appLogo", appLogo);
                            body1 = body1.Replace("@add_siteUrl", siteUrl);
                            //body1 = body1.Replace("@add_requestor", trip.InitiatorName);
                            body1 = body1.Replace("@add_requestID", trip.ID.ToString());
                            body1 = body1.Replace("@add_msg", "A vehicle and driver will be assign to you shortly");
                            body1 = body1.Replace("@add_approver", usr.StaffName);     //Replace the values from DB or any other source to personalize each mail.
                            f1.Close();
                        }
                        try
                        {
                            string rst2 = Utility.SendMail(trip.InitiatorEmail, from1, "", subject1, body1);
                        }
                        catch { }
                        success.Visible   = true;
                        success.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> Request has been successfully approved. Notifications has been sent to HeadDriver for further action on the request";
                    }
                    else
                    {
                        error.Visible   = true;
                        error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred while updating request.. kindly try again!!!";
                        return;
                    }
                }
                else
                {
                    error.Visible   = true;
                    error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred while retrieving request.. kindly try again!!!";
                    return;
                }
            }
            catch (Exception ex)
            {
                error.Visible   = true;
                error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred. kindly try again!!!";
                Utility.WriteError("Error: " + ex.InnerException);
                return;
            }
        }
コード例 #16
0
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            try
            {
                Trip trip = null;
                int  id   = int.Parse(hid.Value);
                trip = TripBLL.GetTripDetailByID(id);
                if (trip != null)
                {
                    trip.Status = (int)Utility.FleetRequestStatus.Cancelled;
                    if (TripBLL.UpdateTrip(trip))
                    {
                        LinkButton1.Visible = false;

                        BindGrid(id);
                        //send email to GssAdmin and Copy HeadDriver
                        string body     = "";
                        string from     = ConfigurationManager.AppSettings["exUser"].ToString();
                        string to       = ConfigurationManager.AppSettings["GssMailGrp"].ToString();
                        string cc       = ConfigurationManager.AppSettings["headDriverMail"].ToString();
                        string appLogo  = ConfigurationManager.AppSettings["appLogoUrl"].ToString();
                        string siteUrl  = ConfigurationManager.AppSettings["siteUrl"].ToString();
                        string subject  = "Fleet Request Notification";
                        string FilePath = Server.MapPath("EmailTemplates/");
                        if (File.Exists(FilePath + "RequestCancelledNotification.htm"))
                        {
                            FileStream   f1 = new FileStream(FilePath + "RequestCancelledNotification.htm", FileMode.Open);
                            StreamReader sr = new StreamReader(f1);
                            body = sr.ReadToEnd();
                            body = body.Replace("@add_appLogo", appLogo);
                            body = body.Replace("@add_siteUrl", siteUrl);
                            body = body.Replace("@add_initiator", trip.InitiatorName);
                            body = body.Replace("@add_requestID", trip.ID.ToString());
                            //body = body.Replace("@add_comment", txtComment.Text);
                            // body = body.Replace("@add_approver", usr.StaffName); //Replace the values from DB or any other source to personalize each mail.
                            f1.Close();
                        }
                        try
                        {
                            string rst2 = Utility.SendMail(to, from, cc, subject, body);
                        }
                        catch { }
                        success.Visible   = true;
                        success.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> Request has been successfully Cancelled. Notifications has been sent to Fleet Admin";
                    }
                }
                else
                {
                    error.Visible   = true;
                    error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred while retrieving request.. kindly try again!!!";
                    return;
                }
            }
            catch (Exception ex)
            {
                error.Visible   = true;
                error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred. kindly try again!!!";
                Utility.WriteError("Error: " + ex.InnerException);
                return;
            }
        }
コード例 #17
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (!User.Identity.IsAuthenticated)
         {
             Response.Redirect("../Login.aspx", false);
         }
         if (Session["user"] != null)
         {
             usr = (User)Session["user"];
         }
         else
         {
             Response.Redirect("../Login.aspx", false);
             return;
         }
         if (!IsPostBack)
         {
             Trip trip = null; int Id = 0; string stat = "";
             if (Request.QueryString["id"] != null)
             {
                 Id        = Convert.ToInt32(Request.QueryString["id"].ToString());
                 hid.Value = Id.ToString();
                 BindGrid(Id);
                 BindLogGrid();
                 trip = TripBLL.GetTripDetailByID(Id);
                 if (trip != null)
                 {
                     stat             = trip.Status.Value.ToString();
                     lbheader.Text    = trip.ID.ToString();
                     lbInit.Text      = trip.InitiatorName.ToUpper();
                     lbDateAdded.Text = trip.DateAdded.Value.ToString("dd-MMM-yyyy");
                 }
                 else
                 {
                     error.Visible   = true;
                     error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred. kindly try again!!!";
                     return;
                 }
                 int status = int.Parse(stat);
                 if (status == (int)Utility.FleetRequestStatus.Completed || status == (int)Utility.FleetRequestStatus.Declined || status == (int)Utility.FleetRequestStatus.Cancelled)
                 {
                     dvTripCanCel.Visible = false;
                     //lnkCancel.Visible = false;
                 }
                 if (User.IsInRole(GssAdminRole) && stat == ((int)Utility.FleetRequestStatus.Pending_FleetManager_Approval).ToString())
                 {
                     dvFleetmgr.Visible = true;
                     dvAct.Visible      = false;
                 }
                 if (User.IsInRole(GssAdminRole) && stat == ((int)Utility.FleetRequestStatus.OnHold).ToString())
                 {
                     //dvTripCmpl.Visible = true;
                     //dvHeadDriver.Visible = true;
                     // BindVehicleGrid();
                     dvFleetmgr.Visible = true;
                     dvAct.Visible      = false;
                     lnkHold.Visible    = false;
                 }
                 if (User.IsInRole(DeptApprverRole) && stat == ((int)Utility.FleetRequestStatus.Pending_FleetManager_Approval).ToString()) //enable FleetManager Role for GSS Departmt approval
                 {
                     if (dualRole.Length > 0)                                                                                              //granting users in dual list backoffice access
                     {
                         foreach (string uID in dualRole)
                         {
                             if (uID == User.Identity.Name)
                             {
                                 dvFleetmgr.Visible = true;
                                 dvAct.Visible      = false;
                                 if (stat == ((int)Utility.FleetRequestStatus.OnHold).ToString())
                                 {
                                     //dvTripCmpl.Visible = true;
                                     //dvHeadDriver.Visible = true;
                                     // BindVehicleGrid();
                                     lnkHold.Visible = false;
                                     dvAct.Visible   = false;
                                 }
                             }
                         }
                     }
                 }
                 if (User.IsInRole(headDriverRole))
                 {
                     if (stat == ((int)Utility.FleetRequestStatus.Pending_Vehicle_Assignment).ToString())
                     {
                         dvHeadDriver.Visible = true;
                         BindVehicleGrid();
                         dvAct.Visible = false;
                     }
                 }
                 if (User.IsInRole(headDriverRole) && stat == ((int)Utility.FleetRequestStatus.Enroute).ToString())
                 {
                     dvTripCmpl.Visible = true;
                     BindVehicleGrid();
                     dvAct.Visible = false;
                 }
             }
             else
             {
                 Response.Redirect("ManageFleetRequest.aspx", false);
                 return;
             }
         }
     }
     catch (Exception ex)
     {
         error.Visible   = true;
         error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred. kindly try again!!!";
         Utility.WriteError("Error: " + ex.InnerException);
         return;
     }
 }
コード例 #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    Response.Redirect("Login.aspx", false);
                    return;
                }
                User usr = null;
                if (Session["user"] != null)
                {
                    usr = (User)Session["user"];
                }
                else
                {
                    Response.Redirect("Login.aspx", false);
                    return;
                }

                Label lblfnm = (Label)LoginView1.FindControl("lbFName");
                if (dualRole.Length > 0)//granting users in dual list backoffice access
                {
                    foreach (string uID in dualRole)
                    {
                        if (uID == usr.StaffID)
                        {
                            HyperLink lnkboffice = (HyperLink)LoginView1.FindControl("lnkBackOffice");
                            lnkboffice.Visible = true;
                            lblfnm.Text        = usr.StaffName;
                        }
                    }
                }
                if (HttpContext.Current.User.IsInRole(GssAdminRole) || HttpContext.Current.User.IsInRole(AdminRole) || HttpContext.Current.User.IsInRole(HeadDriverRole))
                {
                    HyperLink lnkboffice = (HyperLink)LoginView1.FindControl("lnkBackOffice");
                    lnkboffice.Visible = true;
                    lblfnm.Text        = usr.StaffName;
                }
                else if (HttpContext.Current.User.IsInRole(DeptApprverRole))
                {
                    lblfnm.Text = usr.StaffName;
                    HyperLink          lnkbtn  = (HyperLink)LoginView1.FindControl("lnkAlert");
                    IEnumerable <Trip> tripLst = TripBLL.GetFleetRequestByApproval(usr.ID, (int)Utility.FleetRequestStatus.Pending_Supervisor_Approval);
                    lnkbtn.Text          = tripLst.Count().ToString() + " Pending Request(s)";
                    lnkbtn.NavigateUrl   = "RequestApprovalList.aspx";
                    lnkbtn.Visible       = true;
                    mgtReq.Visible       = true;
                    mgtReqMobile.Visible = true;
                }
                else
                {
                    lblfnm.Text = usr.StaffName;
                }
                //    if (HttpContext.Current.User.IsInRole(MemberRole))
                //    {
                //        HyperLink lnkboffice = (HyperLink)LoginView1.FindControl("lnkBackOffice");
                //        lnkboffice.Visible = false;

                //        Label lblfnm = (Label)LoginView1.FindControl("lbFName");
                //        Label lbbid = (Label)LoginView1.FindControl("lbBidder");
                //        lbbid.Visible = true;
                //        if (Session["user"] != null)
                //        {
                //            lblfnm.Text = Session["user"].ToString();
                //        }
                //        if (Session["bidder"] != null)
                //        {
                //            lbbid.Text = "BidderID: "+Session["bidder"].ToString();
                //        }

                //    }
            }
            catch (Exception ex)
            {
                Utility.WriteError("Error: " + ex.InnerException);
                return;
            }
        }
コード例 #19
0
        protected void gvVehicle_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                User usr = null;
                if (Session["user"] != null)
                {
                    usr = (User)Session["user"];
                }
                else
                {
                    Response.Redirect("../Login.aspx", false);
                    return;
                }
                String          DriverName   = ((Label)gvVehicle.SelectedRow.FindControl("lbDrv")).Text;
                String          DriverMobile = ((Label)gvVehicle.SelectedRow.FindControl("lbDrvFone")).Text;
                String          VehicleMake  = ((Label)gvVehicle.SelectedRow.FindControl("lbMaker")).Text;
                int             VehicleID    = Convert.ToInt32(gvVehicle.SelectedDataKey["ID"].ToString());
                int             requestId    = Convert.ToInt32(hid.Value);
                SmsNotification sms          = new SmsNotification();
                Trip            trip         = TripBLL.GetTripDetailByID(requestId);
                Vehicle         veh          = VehicleBLL.GetVehicle(VehicleID);
                if (trip != null)
                {
                    trip.Status          = (int)Utility.FleetRequestStatus.Enroute;
                    trip.DateAssigned    = DateTime.Now;
                    trip.AssignedBy      = usr.ID;
                    trip.AssignedVehicle = VehicleID;

                    trip.MileageAtDeparture = veh.Mileage.HasValue ? veh.Mileage.Value : 0;
                    Department dept = DepartmentBLL.GetDepartment(trip.DepartmentID.Value);
                    sms.PHONE   = DriverMobile;
                    sms.SENDER  = smsSender;
                    sms.MESSAGE = "easyFLEET:Trip Assigned:: #Location:" + trip.Location.ToUpper() + " #Destination:" + trip.Destination.ToUpper() + " #Date:" + trip.TripDate.Value.ToString("dd-MMM-yyyy").ToUpper() + " #DepartureTime:" + trip.ExpectedDepartureTime + " #Requestor:" + trip.InitiatorName.ToUpper() + " #Dept:" + dept.Name + " Thanks.";
                    sms.STATUS  = "U";
                    if (TripBLL.UpdateTrip(trip))
                    {
                        BindGrid(requestId);

                        if (veh != null)
                        {
                            veh.Status = (int)Utility.VehicleStatus.Enroute;
                            VehicleBLL.UpdateVehicle(veh);
                        }
                        //Send Sms to drive---to do
                        Utility.AddSmsNotification(sms);

                        lnkCheckAvailabity.Enabled = false;
                        lnkHold.Visible            = false;
                        //send Email to Requestor and sms to Driver
                        string body = "";
                        string from = ConfigurationManager.AppSettings["exUser"].ToString();

                        string appLogo  = ConfigurationManager.AppSettings["appLogoUrl"].ToString();
                        string siteUrl  = ConfigurationManager.AppSettings["siteUrl"].ToString();
                        string subject  = "Vehicle Assignment Notification";
                        string FilePath = Server.MapPath("EmailTemplates/");
                        if (File.Exists(FilePath + "VehicleAssignedNotification.htm"))
                        {
                            FileStream   f1 = new FileStream(FilePath + "VehicleAssignedNotification.htm", FileMode.Open);
                            StreamReader sr = new StreamReader(f1);
                            body = sr.ReadToEnd();
                            body = body.Replace("@add_appLogo", appLogo);
                            body = body.Replace("@add_siteUrl", siteUrl);
                            //body = body.Replace("@add_Initiator", trip.InitiatorName);
                            body = body.Replace("@dd_RequestID", trip.ID.ToString());
                            body = body.Replace("@add_Plate", veh.PlateNo);
                            body = body.Replace("@add_driver", DriverName);
                            body = body.Replace("@add_Mobile", DriverMobile);
                            body = body.Replace("add_vehicleName", veh.Name + "[" + veh.PlateNo + "]");
                            // body = body.Replace("@add_approver", usr.StaffName); //Replace the values from DB or any other source to personalize each mail.
                            f1.Close();
                        }
                        try
                        {
                            string rst2 = Utility.SendMail(trip.InitiatorEmail, from, "", subject, body);
                        }
                        catch { }
                        success.Visible   = true;
                        success.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> Request has been successfully Treated. Notifications has been sent to Initiator, SMS has been sent to the Assigned Driver";
                    }
                }
            }
            catch (Exception ex)
            {
                error.Visible   = true;
                error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred. kindly try again!!!";
                Utility.WriteError("Error: " + ex.InnerException);
                return;
            }
        }
コード例 #20
0
 protected void btnLog_Click(object sender, EventArgs e)
 {
     try
     {
         lbmsg.Visible = false;
         string   dTime    = Request.Form["timepicker1"].ToString();
         string   aTime    = Request.Form["timepicker2"].ToString();
         string[] dTimeArg = dTime.Split(new char[] { ':', ' ' });
         string[] aTimeArg = aTime.Split(new char[] { ':', ' ' });
         int      aHr      = int.Parse(aTimeArg[0]);
         int      aMin     = int.Parse(aTimeArg[1]);
         int      dHr      = int.Parse(dTimeArg[0]);
         int      dMin     = int.Parse(dTimeArg[1]);
         string   afrmt    = aTimeArg[2];
         string   dfrmt    = dTimeArg[2];
         if (dfrmt == afrmt)
         {
             if (dHr == aHr && dMin >= aMin)
             {
                 lbmsg.Visible = true;
                 lbmsg.Text    = "Sorry Departure Time could not be greater than or equal to Arrival time";
                 mpeLog.Show();
                 return;
             }
             if (dHr > aHr && dHr != 12)
             {
                 lbmsg.Visible = true;
                 lbmsg.Text    = "Sorry Departure Time could not be greater than Arrival time";
                 mpeLog.Show();
                 return;
             }
         }
         if (dfrmt == "PM" && dHr != 12)
         {
             dHr += 12;
         }
         if (afrmt == "PM" && aHr != 12)
         {
             aHr += 12;
         }
         if (dfrmt == "AM" && dHr == 12)
         {
             //dHr -= 12;
         }
         if (afrmt == "AM" && aHr == 12)
         {
             //aHr -= 12;
         }
         string  dMinPad   = dMin.ToString().PadRight(2, '0');
         string  aMinPad   = aMin.ToString().PadRight(2, '0');
         decimal dpartTime = decimal.Parse(dHr.ToString() + "." + dMinPad);
         decimal arrTime   = decimal.Parse(aHr.ToString() + "." + aMin);
         decimal duration  = 0;
         duration = Utility.GetTripDuration(dHr, dMin, aHr, aMin);
         //if (dfrmt == afrmt && dHr == 12)
         //{
         //    duration = arrTime - dpartTime;
         //    duration += 12;
         //}
         //else
         //{
         //    duration = arrTime - dpartTime;
         //}
         int  requestId = Convert.ToInt32(hid.Value);
         Trip trip      = TripBLL.GetTripDetailByID(requestId);
         if (trip == null)
         {
             error.Visible   = true;
             error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred. kindly try again!!!";
             return;
         }
         trip.ActualDepartureTime = dTime;
         trip.ActualRetunTime     = aTime;
         trip.ActualDuration      = duration;
         trip.Note   = txtNote.Text;
         trip.Status = (int)Utility.FleetRequestStatus.Completed;
         decimal mileage = 0;
         if (!decimal.TryParse(txtMileage.Text, out mileage))
         {
             lbmsg.Visible = true;
             lbmsg.Text    = "Mileage must be numeric";
             mpeLog.Show();
         }
         trip.MileageOnArrival = mileage;
         int     VehicleID = Convert.ToInt32(((Label)gvheader.Rows[0].FindControl("lbVeh")).Text);
         Vehicle veh       = VehicleBLL.GetVehicle(VehicleID);
         if (veh != null)//updating vehicle information on arrival;
         {
             if (veh.Mileage > mileage)
             {
                 error.Visible   = true;
                 error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button>Current vehicle mileage cannot be greater than logged mileage. Please review your input!!!";
                 return;
             }
             veh.Status  = (int)Utility.VehicleStatus.Available;
             veh.Mileage = mileage;
             VehicleBLL.UpdateVehicle(veh);
         }
         if (TripBLL.UpdateTrip(trip))
         {
             BindLogGrid(); lnkLog.Enabled = false;
             BindGrid(requestId);
             txtNote.Text      = "";
             success.Visible   = true;
             success.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> Trip Completion details has been logged successfully";
         }
         else
         {
             lbmsg.Visible = true;
             lbmsg.Text    = "An error occurred while updating.. kindly try again!!!";
             mpeLog.Show();
         }
     }
     catch (Exception ex)
     {
         error.Visible   = true;
         error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred. kindly try again!!!";
         Utility.WriteError("Error: " + ex.InnerException);
         return;
     }
 }
コード例 #21
0
 private void BindGrid(string usrname)
 {
     gvRequest.DataSource = TripBLL.GetFleetRequestByUser(usrname).OrderByDescending(p => p.DateAdded).ToList();
     gvRequest.DataBind();
 }