Beispiel #1
0
        public void BindGrid(object sender, EventArgs e)
        {
            try
            {
                PmsDocuments pmsDoc = new PmsDocuments();
                pmsDoc.PmsId = PmsID;

                PmsDocumentsBiz      pmsDocBiz  = new PmsDocumentsBiz();
                IList <PmsDocuments> pmsDocList = pmsDocBiz.SelectPmsDocumentsOther(pmsDoc);

                // if projectType=="Service",绑定gridViewService,隐藏gridViewMain
                // else 绑定gridViewMain,隐藏gridViewService
                if (ProjectType == PmsCommonEnum.ProjectTypeFlowId.Service.GetDescription())
                {
                    gridViewMain.Visible       = false;
                    gridViewService.Visible    = true;
                    gridViewService.DataSource = pmsDocList;
                    gridViewService.DataBind();
                }
                else
                {
                    gridViewMain.Visible    = true;
                    gridViewService.Visible = false;
                    gridViewMain.DataSource = pmsDocList;
                    gridViewMain.DataBind();
                }
            }
            catch
            {
                Msgbox("BindGrid failure!");
            }
        }
Beispiel #2
0
        protected void buttonGetFile_Click(object sender, EventArgs e)
        {
            PmsHead  pmsHead   = new PmsHead();
            DateTime dtCurDate = PmsSysBiz.GetDBDateTime();

            pmsHead.Creator    = LoginName;
            pmsHead.CreateDate = dtCurDate;
            pmsHead.PmsId      = PmsID;
            pmsHead.CrId       = CrID;
            IList <PmsDocuments> listPmsDocuments = new PmsDocumentsBiz().GetPmsDocuments(pmsHead);
            int saveResult = 0;

            foreach (PmsDocuments pmsDocuments in listPmsDocuments)
            {
                IList <PmsDocuments> pmsDocList = new PmsDocumentsBiz().SelectPmsDocuments(pmsDocuments);
                if (pmsDocList != null && pmsDocList.Count > 0)
                {
                    continue;
                }
                saveResult = new PmsDocumentsBiz().InsertPmsDocuments(pmsDocuments);
                if (saveResult <= 0)
                {
                    Msgbox("Get File failure!");
                    return;
                }
            }
            BindGrid(sender, e); // BindGrid时需判断projectType
        }
Beispiel #3
0
        protected void gridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                int    rowIndex  = e.RowIndex;
                int    docTypeId = 0;
                string fileName  = string.Empty;
                string owner     = string.Empty;
                switch (ProjectType)
                {
                // string service = PmsCommonEnum.ProjectTypeFlowId.Service.GetDescription();
                case "Service":
                    docTypeId = int.Parse(gridViewService.DataKeys[rowIndex]["DocTypeId"].ToString());
                    fileName  = gridViewService.DataKeys[rowIndex]["FileName"].ToString();
                    owner     = gridViewService.DataKeys[rowIndex]["Creator"].ToString();
                    break;

                default:
                    docTypeId = int.Parse(gridViewMain.DataKeys[rowIndex]["DocTypeId"].ToString());
                    fileName  = gridViewMain.DataKeys[rowIndex]["FileName"].ToString();
                    owner     = gridViewMain.DataKeys[rowIndex]["Creator"].ToString();
                    break;
                }

                if (string.Compare(owner.ToLower(), LoginName.ToLower()) != 0)
                {
                    Msgbox("You can not delete it, you are not owner!");
                    return;
                }
                PmsDocuments pmsDoc = new PmsDocuments();
                pmsDoc.PmsId     = PmsID;
                pmsDoc.DocTypeId = docTypeId;
                pmsDoc.FileName  = fileName;
                PmsDocumentsBiz pmsDocBiz    = new PmsDocumentsBiz();
                int             deleteResult = pmsDocBiz.DeletePmsDocuments(pmsDoc);
                if (deleteResult <= 0)
                {
                    Msgbox("Delete failure!");
                }
                else
                {
                    if (ProjectType == PmsCommonEnum.ProjectTypeFlowId.Service.GetDescription())
                    {
                        string filePath = gridViewService.DataKeys[rowIndex]["Path"].ToString();

                        File.Delete(filePath); //删除数据库记录的同时,删除服务器上的文件
                    }
                    BindGrid(sender, e);
                }
            }
            catch
            {
                Msgbox("Delete failure!");
            }
        }
Beispiel #4
0
        protected void InsertPmsDocuments(string fileName, string fileFullPath, string fileSize, out int saveResult)
        {
            PmsDocuments pmsDocuments = new PmsDocuments();

            pmsDocuments.PmsId     = PmsID;
            pmsDocuments.DocTypeId = (int)PmsCommonEnum.DocumentType.Other;
            pmsDocuments.FileName  = fileName;
            pmsDocuments.Path      = fileFullPath;
            pmsDocuments.Size      = fileSize;

            pmsDocuments.Creator = WSC.GlobalDefinition.Cookie_LoginUser.Replace(" ", ".");;
            DateTime dtCurDate = PmsSysBiz.GetDBDateTime();

            pmsDocuments.CreateDate = dtCurDate;

            PmsDocumentsBiz pmsDocBiz = new PmsDocumentsBiz();

            saveResult = pmsDocBiz.InsertPmsDocuments(pmsDocuments);
        }
        protected void buttonSave_Click(object sender, EventArgs e)
        {
            try
            {
                #region Check Validity
                if (dropdownlistDocType != null && dropdownlistDocType.Items.Count > 0)
                {
                    if (dropdownlistDocType.SelectedItem.Text.ToString().Trim() == "")
                    {
                        Msgbox("Please select Document Type!");
                        dropdownlistDocType.Focus();
                        return;
                    }
                }

                if (textboxUrl.Text.Trim() == "")
                {
                    Msgbox("Please input URL!");
                    textboxUrl.Focus();
                    return;
                }
                if (textboxUrl.Text.Length > 500)
                {
                    Msgbox("The length of URL is larger than 500!");
                    textboxUrl.Focus();
                    return;
                }

                if (!ValidateUrl(textboxUrl.Text.Trim()))
                {
                    Msgbox("The Url is not legal!");
                    textboxUrl.Focus();
                    return;
                }

                #endregion

                #region For Insert PmsDocuments
                PmsDocuments pmsDocuments = new PmsDocuments();
                pmsDocuments.PmsId     = PmsID;
                pmsDocuments.DocTypeId = int.Parse(dropdownlistDocType.SelectedValue);
                pmsDocuments.FileName  = FileName;

                if (textboxUrl.Text.Trim().LastIndexOf("\\") != -1)
                {
                    pmsDocuments.FileName = Server.UrlDecode(textboxUrl.Text.Trim().Substring(textboxUrl.Text.Trim().LastIndexOf("\\") + 1));
                }
                else
                {
                    pmsDocuments.FileName = Server.UrlDecode(textboxUrl.Text.Trim().Substring(textboxUrl.Text.Trim().LastIndexOf("/") + 1));
                }

                int documentTypeId = int.Parse(dropdownlistDocType.SelectedValue);


                PmsHead pmsHead = new PmsHeadBiz().SelectCrIdSystemVersionByPmsId(PmsID);

                string errorInfo;
                if (!CheckFileName(pmsDocuments.FileName, documentTypeId, pmsHead.CrId, pmsHead.System, pmsHead.NewVersion, out errorInfo))
                {
                    Msgbox(errorInfo);
                    return;
                }

                pmsDocuments.Path = textboxUrl.Text.Trim();
                DateTime dtCurDate = PmsSysBiz.GetDBDateTime();
                pmsDocuments.Creator    = LoginName;
                pmsDocuments.CreateDate = dtCurDate;
                //默认给"0"
                pmsDocuments.Size = "0";

                PmsDocumentsBiz      pmsDocBiz  = new PmsDocumentsBiz();
                IList <PmsDocuments> pmsDocList = pmsDocBiz.SelectPmsDocuments(pmsDocuments);
                int saveResult = 0;
                if (pmsDocList != null && pmsDocList.Count > 0)
                {
                    Msgbox("File Exists!");
                    return;
                }

                saveResult = pmsDocBiz.InsertPmsDocuments(pmsDocuments);
                if (saveResult <= 0)
                {
                    Msgbox("Save failure!");
                    return;
                }
                #endregion

                Session["DocPage_Refresh"] = "Y";
                Msgbox("Save Successfully!");

                PageRegisterStartupScript("window.close();");
            }
            catch
            {
                Msgbox("Save failure!");
            }
        }