Ejemplo n.º 1
0
        private void EditStatus(int id)
        {
            List <InvoiceEntity>  invoices = _invoiceApp.GetInvoiceByProposalId(id);
            ProposalTrackerEntity entity   = new App.ProposalTrackerApplication().Get(id);

            entity.ModifyOn = DateTime.Now;
            var newStatus = 7;//Paid/Completed

            foreach (var invoice in invoices)
            {
                if (!invoice.Approved)
                {
                    newStatus = 4;//Awaiting Development
                    break;
                }
                else if (invoice.SendOn == null || invoice.DueOn == null)
                {
                    newStatus = 5;//Awaiting Sending Invoice
                    break;
                }
                else if (invoice.ReceiveOn == null)
                {
                    newStatus = 6;//Awaiting Payment
                    break;
                }
            }
            if (entity.Status != newStatus)
            {
                entity.Status = newStatus;
                new App.ProposalTrackerApplication().UpdateProposalTracker(entity);
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (UserInfo.Role != RolesEnum.ADMIN && UserInfo.Role != RolesEnum.PM && UserInfo.Role != RolesEnum.Sales)
            {
                ShowFailMessageToClient("unauthorized access.");
                return;
            }
            if (QS("ID", 0) == 0)
            {
                ShowFailMessageToClient("unauthorized access.");
                return;
            }

            if (!IsPostBack)
            {
                ProposalTrackerEntity entity = new App.ProposalTrackerApplication().Get(QS("ID", 0));
                if (entity == null)
                {
                    ShowFailMessageToClient("unauthorized access.");
                    return;
                }
                InitProject(entity);
                BindStatus(entity.Status);
                BindData(entity);
                CheckStatus(entity.Status);
                this.ddlStatus.Attributes.Add("onchange", "statusChange()");
            }
        }
Ejemplo n.º 3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!fileUpload.HasFile)
            {
                ShowFailMessageToClient("Please upload file");
                return;
            }
            ProposalTrackerEntity proposaltrackerEntity = new App.ProposalTrackerApplication().Get(QS("ID", 0));

            if (proposaltrackerEntity == null)
            {
                ShowFailMessageToClient("unauthorized access.");
                return;
            }

            FilesEntity model = FileFactory.CreateFileEntity(UserInfo.ID, ObjectFactory.GetInstance <ISystemDateTime>());

            model.FilePath = UtilFactory.Helpers.FileHelper.SaveUploadFiles("ProposalTracker", proposaltrackerEntity.ProjectID, fileUpload.PostedFile);;

            model.ProposalTrackerId = proposaltrackerEntity.ProposalTrackerID;
            model.ContentType       = fileUpload.PostedFile.ContentType;
            model.FileID            = 0;
            model.FileSize          = fileUpload.PostedFile.ContentLength;
            model.FileTitle         = Path.GetFileName(fileUpload.PostedFile.FileName);
            model.IsDelete          = false;
            model.IsPublic          = UserInfo.Role == RolesEnum.CLIENT;
            model.SourceType        = (int)FileSourceType.WorkRequest;
            model.ThumbPath         = txtFileTitle.Text;
            model.IsDelete          = false;
            model.Tags = txtTags.Text.Trim();
            bool result = true;

            result = fileApp.AddFile(model) > 0;

            if (!result)
            {
                ShowFailMessageToClient(fileApp.BrokenRuleMessages);
            }
            else
            {
                Redirect(EmptyPopPageUrl, false, true);
            }
        }
Ejemplo n.º 4
0
        public void TicketsDataBind()
        {
            string keyWord = txtKeyword.Text.Trim();

            int proposaltrackerId        = QS("ID", 0);
            ProposalTrackerEntity entity = new App.ProposalTrackerApplication().Get(proposaltrackerId);

            if (entity == null)
            {
                ShowFailMessageToClient("unauthorized access.");
                return;
            }

            var condition = new SearchTicketCondition();

            if (!string.IsNullOrEmpty(keyWord))
            {
                condition.Keyword = keyWord;
            }
            condition.Statuses.AddRange(TicketsStateHelper.NoneFailStates);
            condition.ProjectId      = entity.ProjectID;
            condition.OrderBy        = OrderBy;
            condition.OrderDirection = OrderDirection;
            condition.PageCount      = anpWaitting.PageSize;
            //condition.CurrentPage = anpWaitting.CurrentPageIndex;
            condition.CurrentPage = CurrentPageIndex;

            condition.UserId = UserInfo.ID;

            int wid = QS("ID", 0);

            list = ticketApp.SearchTicketsNotInTid(condition);


            if (null != list && list.Count > 0)
            {
                trNoTickets.Visible = false;
            }
            rptTickets.DataSource = list;
            rptTickets.DataBind();

            anpWaitting.RecordCount = condition.TotalRecords;
        }
Ejemplo n.º 5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (IdentityContext.UserID <= 0)
            {
                context.Response.Write("unauthorized access.");
                return;
            }
            UsersEntity userEntity = new App.UserApplication().GetUser(IdentityContext.UserID);

            if (userEntity == null ||
                (userEntity.Role != RolesEnum.ADMIN &&
                 userEntity.Role != RolesEnum.PM &&
                 userEntity.Role != RolesEnum.Sales))
            {
                context.Response.Write("unauthorized access.");
                return;
            }

            string id = context.Request.QueryString["id"];
            int    proposalTrackerId = 0;

            if (!int.TryParse(id, out proposalTrackerId))
            {
                context.Response.Write("File not found.");
                return;
            }

            ProposalTrackerEntity entity = new App.ProposalTrackerApplication().Get(proposalTrackerId);

            if (entity == null)
            {
                context.Response.Write("File not found.");
                return;
            }

            string tmpPath = HttpContext.Current.Server.MapPath(entity.WorkScope);

            if (System.IO.File.Exists(tmpPath))
            {
                System.IO.FileInfo file = new System.IO.FileInfo(tmpPath);

                context.Response.AddHeader("Content-Length", file.Length.ToString());

                context.Response.AddHeader("Content-Disposition"
                                           , string.Format("attachment;filename={0}", System.Web.HttpUtility.UrlEncode(entity.WorkScopeDisplayName.NoHTML(), Encoding.UTF8)));

                switch (file.Extension.ToLower())
                {
                case ".png":
                    context.Response.ContentType = "image/png";
                    ShowImage(context, tmpPath, ".png");
                    return;

                case ".gif":
                    context.Response.ContentType = "image/GIF";
                    ShowImage(context, tmpPath, ".gif");
                    return;

                case ".jpg":
                case ".jpeg":
                    context.Response.ContentType = "image/jpeg";
                    ShowImage(context, tmpPath, ".jpg");
                    return;

                case ".bmp":
                    context.Response.ContentType = "image/bmp";
                    ShowImage(context, tmpPath, ".bmp");
                    return;

                case ".zip":
                    context.Response.ContentType = "application/octet-stream";
                    break;

                case ".rar":
                    context.Response.ContentType = "application/octet-stream";
                    break;

                case ".txt":
                    context.Response.ContentType = "text/plain";
                    break;

                case ".wps":
                    context.Response.ContentType = "application/octet-stream";
                    break;

                case ".doc":
                    context.Response.ContentType = "application/ms-word";
                    break;

                case ".xls":
                    context.Response.ContentType = "application/ms-excel";
                    break;

                case ".swf":
                    context.Response.ContentType = "application/x-shockwave-flash";
                    break;

                case ".ppt":
                    context.Response.ContentType = "application/ms-powerpoint";
                    break;

                case ".fla":
                    context.Response.ContentType = "application/octet-stream";
                    break;

                case ".mp3":
                    context.Response.ContentType = "audio/mp3";
                    break;

                default:
                    context.Response.ContentType = "text/plain";
                    break;
                }
                context.Response.TransmitFile(entity.WorkScope);
                context.Response.End();
                return;
            }
            else
            {
                context.Response.Write("File not found.");
                return;
            }
        }
Ejemplo n.º 6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            bool result = true;

            if (fileUpload.HasFile)
            {
                string fileContentType = fileUpload.PostedFile.ContentType;
                if ((fileContentType != "application/msword" && fileContentType != "application/pdf" &&
                     fileContentType != "application/vnd.openxmlformats-officedocument.wordprocessingml.document"))
                {
                    ShowFailMessageToClient("Please select a file to upload ( *.doc, *.docx, *.pdf)");
                    return;
                }
            }

            ProposalTrackerEntity entity = new App.ProposalTrackerApplication().Get(QS("ID", 0));

            // basic infomation
            entity.ProjectID = Convert.ToInt32(ddlProject.SelectedValue);
            //entity.Payment = Convert.ToInt32(this.ddlPayment.SelectedValue);
            entity.InvoiceNo = "";
            bool   sendEmailToTeam = entity.Status != Convert.ToInt32(ddlStatus.SelectedValue);
            string oldStatusName   = ((ProposalTrackerStatusEnum)entity.Status).ToString().Replace("_", " ");

            entity.Status = Convert.ToInt32(ddlStatus.SelectedValue);
            string newStatusName = ((ProposalTrackerStatusEnum)entity.Status).ToString().Replace("_", " ");

            entity.Title       = txtTitle.Text.Trim();
            entity.Description = txtDescription.Text.Trim();

            entity.ModifyOn = DateTime.Now;
            entity.ModifyBy = UserInfo.UserID;


            entity.ProposalSentTo = txtProposalSentTo.Text.Trim();
            DateTime proposalSentOn;

            if (DateTime.TryParse(txtProposalSentOn.Text.Trim(), out proposalSentOn))
            {
                entity.ProposalSentOn = proposalSentOn;
            }
            else
            {
                entity.ProposalSentOn = null;
            }
            entity.PoTotalLessThenProposalTotal = chkLessThen.Checked;
            entity.PONo       = txtPO.Text.Trim();
            entity.ApprovedBy = txtApprovedBy.Text.Trim();
            DateTime approvedOn;

            if (DateTime.TryParse(txtApprovedOn.Text.Trim(), out approvedOn))
            {
                entity.ApprovedOn = approvedOn;
            }
            else
            {
                entity.ApprovedOn = null;
            }
            //DateTime invoiceSentOn;
            //if (DateTime.TryParse(txtInvoiceSentOn.Text.Trim(), out invoiceSentOn))
            //{
            //    entity.InvoiceSentOn = invoiceSentOn;
            //}
            //else
            //{
            //    entity.InvoiceSentOn = null;
            //}


            if (fileUpload.HasFile)
            {
                string fileContentType = fileUpload.PostedFile.ContentType;
                entity.WorkScope            = UtilFactory.Helpers.FileHelper.SaveUploadFiles("WorkScope", entity.ProjectID, fileUpload.PostedFile);
                entity.WorkScopeDisplayName = fileUpload.FileName;

                if (wrApp.UpdateProposalTracker(entity))
                {
                    if (sendEmailToTeam)
                    {
                        string subject = "[ " + entity.Title + " ]" + " -- " + "[ " + newStatusName + " ]";
                        string content = UserInfo.FirstAndLastName + " changed [" + entity.Title + "]'s status from [" + oldStatusName + "] to " + "[" + newStatusName + "] on " + entity.ModifyOn;
                        ObjectFactory.GetInstance <IEmailSender>().SendMail("*****@*****.**", Config.DefaultSendEmail, subject, content);
                    }
                    FilesEntity model = FileFactory.CreateFileEntity(UserInfo.ID, ObjectFactory.GetInstance <ISystemDateTime>());
                    model.FilePath          = entity.WorkScope;
                    model.ProposalTrackerId = entity.ProposalTrackerID;
                    model.ContentType       = fileUpload.PostedFile.ContentType;
                    model.FileID            = 0;
                    model.FileSize          = fileUpload.PostedFile.ContentLength;
                    model.FileTitle         = Path.GetFileName(fileUpload.FileName);
                    model.IsDelete          = false;
                    model.IsPublic          = UserInfo.Role == RolesEnum.CLIENT;
                    model.SourceType        = (int)FileSourceType.WorkRequestScope;
                    model.ThumbPath         = Path.GetFileName(fileUpload.PostedFile.FileName);
                    result = fileApp.AddFile(model) > 0 ? true : false;
                    if (string.IsNullOrEmpty(QS("returnurl")))
                    {
                        Redirect("index.aspx");
                    }
                    else
                    {
                        Redirect(QS("returnurl"));
                    }
                    //Redirect(string.Format("EditProposalTracker.aspx?ID={0}&returnurl={1}", entity.ProposalTrackerID, QS("returnurl")));
                }
                else
                {
                    ShowFailMessageToClient(wrApp.BrokenRuleMessages);
                    return;
                }
            }
            else
            {
                if (wrApp.UpdateProposalTracker(entity))
                {
                    if (sendEmailToTeam)
                    {
                        string subject = "[ " + entity.Title + " ]" + " -- " + "[ " + newStatusName + " ]";
                        string content = UserInfo.FirstAndLastName + " changed [" + entity.Title + "]'s status from [" + oldStatusName + "] to " + "" + newStatusName + "] on " + entity.ModifyOn;
                        ObjectFactory.GetInstance <IEmailSender>().SendMail("*****@*****.**", Config.DefaultSendEmail, subject, content);
                    }
                    Redirect(QS("returnurl"));
                    //Redirect(string.Format("EditProposalTracker.aspx?ID={0}&returnurl={1}", entity.ProposalTrackerID, QS("returnurl")));
                }
                else
                {
                    ShowFailMessageToClient(wrApp.BrokenRuleMessages);
                    return;
                }
            }
        }