Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IPackageRepository packageRepository = new PackageRepository(ConfigurationManager.ConnectionStrings["ENetCare"].ConnectionString);

            _packageService = new PackageService(packageRepository);

            IEmployeeRepository repository = new EmployeeRepository(ConfigurationManager.ConnectionStrings["ENetCare"].ConnectionString);

            _employeeService = new EmployeeService(repository);

            ucPackageBarcode.AddValidate += PackageBarcodeOnAdd;

            if (!Page.IsPostBack)
            {
                var centres = _employeeService.GetAllDistributionCentres();

                ddlDestination.DataTextField  = "Name";
                ddlDestination.DataValueField = "CentreId";
                ddlDestination.DataSource     = centres;
                ddlDestination.DataBind();

                SetSendDateTextBox(DateTime.Today);

                EmployeeMembershipUser user          = (EmployeeMembershipUser)System.Web.Security.Membership.GetUser();
                DistributionCentre     _senderCentre = _employeeService.GetDistributionCentre(user.DistributionCentreId);
                ViewState["senderCentre"] = _senderCentre;
            }
            else if (!string.IsNullOrEmpty(Request.Form[txtSendDate.UniqueID]))
            {
                DateTime sendDate = DateTime.Parse(Request.Form[txtSendDate.UniqueID]);
                SetSendDateTextBox(sendDate);
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IEmployeeRepository repository = new EmployeeRepository(ConfigurationManager.ConnectionStrings["ENetCare"].ConnectionString);

            _employeeService = new EmployeeService(repository);

            if (!Page.IsPostBack)
            {
                var centres = _employeeService.GetAllDistributionCentres();

                ddlLocation.DataTextField  = "Name";
                ddlLocation.DataValueField = "CentreId";
                ddlLocation.DataSource     = centres;
                ddlLocation.DataBind();

                EmployeeMembershipUser user = (EmployeeMembershipUser)System.Web.Security.Membership.GetUser();
                var employee = _employeeService.Retrieve(user.UserName);
                if (employee != null)
                {
                    litUserName.Text              = employee.UserName;
                    txtFullName.Text              = employee.FullName;
                    txtEmailAddress.Text          = employee.EmailAddress;
                    rblEmployeeType.SelectedValue = employee.EmployeeType.ToString();
                    ddlLocation.SelectedValue     = employee.Location.CentreId.ToString();
                }
            }
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                EmployeeMembershipUser user = (EmployeeMembershipUser)System.Web.Security.Membership.GetUser();

                litEmployeeUsername.Text   = user.UserName;
                litEmployeeFullName.Text   = user.Comment;
                litEmployeeType.Text       = user.EmployeeType.ToString();
                litLocationCentreName.Text = user.DistributionCentreName;

                switch (user.EmployeeType)
                {
                case EmployeeType.Doctor:
                    SiteMapDataSource1.SiteMapProvider = "DoctorSiteMapProvider";
                    break;

                case EmployeeType.Agent:
                    SiteMapDataSource1.SiteMapProvider = "AgencySiteMapProvider";
                    break;

                case EmployeeType.Manager:
                    SiteMapDataSource1.SiteMapProvider = "ManagerSiteMapProvider";
                    break;
                }
            }
        }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IPackageRepository packageRepository = new PackageRepository(ConfigurationManager.ConnectionStrings["ENetCare"].ConnectionString);

            _packageService = new PackageService(packageRepository);

            IEmployeeRepository repository = new EmployeeRepository(ConfigurationManager.ConnectionStrings["ENetCare"].ConnectionString);

            _employeeService = new EmployeeService(repository);

            ImageBarcode.Visible = false;
            btnNext.Enabled      = false;

            if (!Page.IsPostBack)
            {
                var centres = _employeeService.GetAllDistributionCentres();

                ddlLocation.DataTextField  = "Name";
                ddlLocation.DataValueField = "CentreId";
                ddlLocation.DataSource     = centres;
                ddlLocation.DataBind();

                EmployeeMembershipUser user = (EmployeeMembershipUser)System.Web.Security.Membership.GetUser();

                ddlLocation.SelectedValue = user.DistributionCentreId.ToString();

                var packageTypes = _packageService.GetAllStandardPackageTypes();

                ddlPackageType.DataTextField  = "Description";
                ddlPackageType.DataValueField = "PackageTypeId";
                ddlPackageType.DataSource     = packageTypes;
                ddlPackageType.DataBind();
            }
        }
Beispiel #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IReportRepository repository = new ReportRepository(ConfigurationManager.ConnectionStrings["ENetCare"].ConnectionString);

            _reportService = new ReportService(repository);

            EmployeeMembershipUser user = (EmployeeMembershipUser)System.Web.Security.Membership.GetUser();

            grd.DataSource = _reportService.GetStocktaking(user.DistributionCentreId);
            grd.DataBind();
        }
Beispiel #6
0
        protected void btnSave_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                pnlErrorMessage.Visible = true;
                litErrorMessage.Text    = "There are errors";
                return;
            }

            StringBuilder successMessage = new StringBuilder(10);

            DateTime receiveDate = DateTime.Parse(Request.Form[txtReceiveDate.UniqueID]);

            EmployeeMembershipUser user = (EmployeeMembershipUser)System.Web.Security.Membership.GetUser();
            var destinationCentre       = _employeeService.GetDistributionCentre(user.DistributionCentreId);

            List <string> barcodes = ucPackageBarcode.GetBarcodes();

            for (int i = 0; i < barcodes.Count(); i++)
            {
                Result result = _packageService.Receive(barcodes[i], destinationCentre, receiveDate);
                if (!result.Success)
                {
                    var err = new CustomValidator();
                    err.ValidationGroup = "receiveDetails";
                    err.IsValid         = false;
                    err.ErrorMessage    = string.Format("{0} - {1}", barcodes[i], result.ErrorMessage);
                    Page.Validators.Add(err);

                    pnlErrorMessage.Visible = true;
                    litErrorMessage.Text    = "There are errors";
                }
                else
                {
                    if (successMessage.Length == 0)
                    {
                        successMessage.Append("The following barcodes were received");
                    }

                    successMessage.AppendFormat(", {0}", barcodes[i]);
                }
            }

            if (successMessage.Length > 0)
            {
                pnlMessage.Visible = true;
                litMessage.Text    = successMessage.ToString();
            }

            ucPackageBarcode.Visible = false;
            txtReceiveDate.Enabled   = false;
            btnSave.Enabled          = false;
        }
Beispiel #7
0
        private void PackageBarcodeOnAdd(object sender, BarCodeAddValidateEventArgs eventArgs)
        {
            eventArgs.Success = true;

            EmployeeMembershipUser user = (EmployeeMembershipUser)System.Web.Security.Membership.GetUser();

            if (eventArgs.Package.CurrentStatus == PackageStatus.InStock && eventArgs.Package.CurrentLocation.CentreId == user.DistributionCentreId)
            {
                eventArgs.Success      = false;
                eventArgs.ErrorMessage = "Package is already in stock at " + eventArgs.Package.CurrentLocation.Name;
            }
        }
Beispiel #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IPackageRepository packageRepository = new PackageRepository(ConfigurationManager.ConnectionStrings["ENetCare"].ConnectionString);

            _packageService = new PackageService(packageRepository);

            //Use the custom Barcode event which is triggered when a new barcode is to be added
            ucPackageBarcode.AddValidate += PackageBarcodeOnAdd;

            if (!Page.IsPostBack)
            {
                IEmployeeRepository repository = new EmployeeRepository(ConfigurationManager.ConnectionStrings["ENetCare"].ConnectionString);
                var employeeService            = new EmployeeService(repository);

                EmployeeMembershipUser user   = (EmployeeMembershipUser)System.Web.Security.Membership.GetUser();
                DistributionCentre     centre = employeeService.GetDistributionCentre(user.DistributionCentreId);

                //Save centre and username in the viewstate
                ViewState["DistributionCentre"] = centre;
                ViewState["EmployeeUsername"]   = user.UserName;
            }
        }