Exemplo n.º 1
0
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            try
            {
                //get creator,createDate,pmsID,crID
                string   creator = WSC.GlobalDefinition.Cookie_LoginUser.Replace(" ", ".");
                DateTime createDate;
                string   pmsID = string.Empty;
                string   crId  = string.Empty;
                m_PmsCRCreatBiz.GetNewPmsIdTempCrId(out createDate, out pmsID, out crId);

                //get pmsHead,pmsflow,sdpDetail,getPmsChangeHistory,getPmsItarmMapping,getPmsFlow,itarmCrList
                PmsHead              pmsHead          = getPmsHead(creator, createDate, pmsID);
                SdpDetail            sdpDetail        = getSdpDetail(pmsID);
                PmsChangeHistory     pmsChangeHistory = getPmsChangeHistory(creator, createDate, pmsID);
                PmsItarmMapping      pmsItarmMapping  = getPmsItarmMapping(creator, createDate, pmsID, crId);
                PmsFlow              pmsFlow          = getPmsFlow(creator, createDate, pmsID);
                ItarmCrList          itarmCrList      = getItarmCrList(creator, createDate, crId);
                IList <PmsDocuments> pmsDocuments     = getPmsDocuments(creator, createDate, pmsID, crId);
                if (pmsHead == null)
                {
                    Msgbox("Save failed");
                    return;
                }
                //Insert
                PmsHeadBiz pmsInsert = new PmsHeadBiz();
                string     errorInfo;
                int        insertResult = pmsInsert.InsertPmsHeadAndDoc(pmsHead, sdpDetail, pmsChangeHistory, pmsItarmMapping, pmsFlow, itarmCrList, pmsDocuments, out errorInfo);

                if (insertResult == 0)
                {
                    Msgbox(errorInfo);
                }
                else
                {
                    //将TempFile文件夹里的文件移动到UploadFile下以CRNO命名的文件夹里并删除Temp里的文件。
                    MoveUploadFileDeleteTempFile(crId);
                    LoginName.Replace(".", " ");
                    pmsHead.UserName = LoginName;
                    new MailBiz().SendCreateMail(pmsHead);

                    // 更新Stage 自动把这个Cr推进到AssginMember
                    int    oldStage  = (int)PmsCommonEnum.ProjectStage.PES;
                    int    newStage  = (int)PmsCommonEnum.ProjectStage.AssignMember;
                    string strAction = Enum.Parse(typeof(PmsCommonEnum.ProjectStage), oldStage.ToString()).GetDescription();
                    bool   blResult  = new BasicInformationDetailBiz().UpdateStages(pmsID, LoginName, oldStage, newStage, strAction);
                    if (!blResult)
                    {
                        Msgbox("更新stage数据失败!");
                        return;
                    }
                    new MailBiz().SendPromoteMail(pmsHead, newStage);
                    Msgbox("Create Successful!");
                    PageRegisterStartupScript("window.close();");
                }
            }
            catch (Exception exception)
            {
                throw new Exception(exception.ToString());
            }
        }
Exemplo n.º 2
0
        //private void BindDropDownListSiteAndImpactSite()
        //{
        //    try
        //    {
        //        PmsSys pmsSys = new PmsSys();
        //        pmsSys.Vid = "PM";
        //        pmsSys.Type = "Site";

        //        PmsSysBiz pmsSysBiz = new PmsSysBiz();
        //        IList<PmsSys> pmsSysList = pmsSysBiz.SelectData1ByType(pmsSys);

        //        dropdownlistSite.DataSource = pmsSysList;
        //        dropdownlistSite.DataTextField = "Data1";
        //        dropdownlistSite.DataValueField = "Data1";
        //        dropdownlistSite.DataBind();

        //        dropdownlistSite.Items.Insert(0, "");

        //        dropdownlistImpactSite.DataSource = pmsSysList;
        //        dropdownlistImpactSite.DataTextField = "Data1";
        //        dropdownlistImpactSite.DataValueField = "Data1";
        //        dropdownlistImpactSite.DataBind();

        //        QWeb.SelectItem(dropdownlistImpactSite, "QCS");

        //        //dropdownlistSite.Items.Insert(0, new ListItem());
        //        //dropdownlistSite.Items[0].Text = "";
        //        //dropdownlistSite.Items[0].Value = "";

        //        //dropdownlistImpactSite.Items.Insert(0, new ListItem());
        //        //dropdownlistImpactSite.Items[0].Text = "";
        //        //dropdownlistImpactSite.Items[0].Value = "";
        //    }
        //    catch
        //    {
        //        ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "alert('Bind ImpactSite failure');", true);
        //    }

        //}
        #endregion
        #endregion

        protected void buttonSave_Click(object sender, EventArgs e)
        {
            try
            {
                //#region Define Variable
                ////string strSavePath = "";
                ////int iTypeID = 0;
                //#endregion

                //检查控件中的值
                if (!CheckControlValue())
                {
                    return;
                }

                //获取新的Pmsid,CrId以及他们的创建时间
                DateTime dtCurDate;
                string   strPmsID = string.Empty;
                string   strCrId  = string.Empty;
                m_PmsCRCreatBiz.GetNewPmsIdTempCrId(out dtCurDate, out strPmsID, out strCrId);

                #region Get StageID
                PmsFlowTemplateBiz      pmsFlowTemplateBiz  = new PmsFlowTemplateBiz();
                IList <PmsFlowTemplate> pmsFlowTemplateList = pmsFlowTemplateBiz.SelectPmsFlowTemplateByTypeId(dropdownlistType.SelectedValue.Trim());
                int stageId = pmsFlowTemplateList[0].Stageid;
                #endregion

                #region For Insert PmsHead
                PmsHead pmsHeadInsert = new PmsHead();
                pmsHeadInsert.Vid         = "PM";
                pmsHeadInsert.PmsId       = strPmsID;
                pmsHeadInsert.PmsName     = textboxPmsName.Text.Trim().Replace("'", "");
                pmsHeadInsert.Type        = dropdownlistType.SelectedItem.Text.Trim();
                pmsHeadInsert.Description = textboxDescription.Text.Trim().Replace("'", "");
                pmsHeadInsert.System      = textboxSystem.Text.Trim().Replace("'", "");
                pmsHeadInsert.Domain      = dropdownlistDomain.SelectedItem.Text.Trim();
                pmsHeadInsert.Priority    = dropdownlistPriority.SelectedItem.Text.Trim();
                pmsHeadInsert.Site        = dropdownlistSite.SelectedValue;
                pmsHeadInsert.ImpactSite  = dropdownlistImpactSite.SelectedItem.Text.Trim();
                pmsHeadInsert.NeedSTP     = RadioButtonNeedSTPYes.Checked ? "Y" : "N";
                pmsHeadInsert.NeedSTC     = RadioButtonNeedSTCYes.Checked ? "Y" : "N";
                //要插VB2Net add by ITO.Abel.Li 2014-01-06
                pmsHeadInsert.Category   = RadioButtonVB2NetYes.Checked ? "Y" : "N";
                pmsHeadInsert.NewVersion = textboxNewVersion.Text.Trim().Replace("'", "");
                // pmsHeadInsert.OldVersion = textboxOldVersion.Text.Trim().Replace("'", "");
                pmsHeadInsert.OldVersion = HiddenFieldOldVersion.Value.Trim().Replace("'", "");

                pmsHeadInsert.DueDate       = DateTime.Parse(dateTextBoxDueDate.Text.Trim());
                pmsHeadInsert.PlanStartDate = DateTime.Parse(dateTextBoxPlanStartDate.Text.Trim());
                //pmsHeadInsert.ReleaseDate = 0;
                //pmsHeadInsert.CloseDate = 0;
                pmsHeadInsert.Stage         = stageId;
                pmsHeadInsert.Pm            = textboxPM.Text.Trim().Replace("'", "");
                pmsHeadInsert.Sd            = "";
                pmsHeadInsert.Se            = "";
                pmsHeadInsert.Qa            = "";
                pmsHeadInsert.AbnormalStage = 0;
                pmsHeadInsert.Rerver1       = "";
                pmsHeadInsert.Rerver2       = "";
                pmsHeadInsert.Rerver3       = "";
                pmsHeadInsert.Rerver4       = "";
                pmsHeadInsert.Rerver5       = "";
                pmsHeadInsert.CreateDate    = dtCurDate;
                pmsHeadInsert.Creator       = LoginName;
                //pmsHeadInsert.MaintainDate = dtCurDate;
                pmsHeadInsert.MaintainUser = "";
                pmsHeadInsert.OwnerDept    = m_PmsCRCreatBiz.GetOwnerDept(LoginName) ?? string.Empty;
                pmsHeadInsert.RelatedCrNo  = textboxRelatedCrNo.Text.Trim();
                #endregion

                #region For Insert PMS_ITARM_Mapping
                PmsItarmMapping pmsItarmMapping = new PmsItarmMapping();
                pmsItarmMapping.PmsId      = strPmsID;
                pmsItarmMapping.CrId       = strCrId;
                pmsItarmMapping.Creator    = LoginName;
                pmsItarmMapping.CreateDate = dtCurDate;
                #endregion

                #region File(注释不用)
                #region Get Document Type
                //PmsDocumentType pmsDocType = new PmsDocumentType();
                //pmsDocType.Vid = "PM";
                //pmsDocType.TypeName = "PES";

                //PmsDocumentTypeBiz pmsDocTypeBiz = new PmsDocumentTypeBiz();
                //IList<PmsDocumentType> pmsDocTypeList = pmsDocTypeBiz.SelectPmsDocumentType(pmsDocType);

                //if (pmsDocTypeList != null && pmsDocTypeList.Count > 0)
                //{
                //    iTypeID = pmsDocTypeList[0].TypeId;
                //}
                #endregion

                #region Get UploadFilePath
                //PmsSys pmsSys = new PmsSys();
                //pmsSys.Vid = "PM";
                //pmsSys.Type = "UploadFilePath";

                //PmsSysBiz pmsSysBiz = new PmsSysBiz();
                //IList<PmsSys> pmsSysList = pmsSysBiz.SelectData1ByType(pmsSys);
                //if (pmsSysList != null && pmsSysList.Count > 0)
                //{
                //    strSavePath = pmsSysList[0].Data1.ToString().Trim();
                //}
                //else
                //{
                //    ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "alert('Please maintain UploadFilePath!');", true);
                //    return;
                //}
                #endregion

                #region For Insert PmsDocuments
                //PmsDocuments pmsDocuments = new PmsDocuments();
                //pmsDocuments.PmsId = strPmsID;
                //pmsDocuments.DocTypeId = iTypeID;
                //pmsDocuments.FileName = pesUpload.PostedFile.FileName.Substring(pesUpload.PostedFile.FileName.LastIndexOf("\\") + 1);

                //string strTmp = strSavePath + "\\" + strPmsID + "\\" + pmsDocuments.FileName;
                //if (strTmp.Length > 150)
                //{
                //    ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "alert('The length of SavePath is larger than 150!');", true);
                //    pesUpload.Focus();
                //    return;
                //}

                //pmsDocuments.Path = strSavePath + "\\" + strPmsID + "\\" + pmsDocuments.FileName;
                //pmsDocuments.Size = pesUpload.PostedFile.ContentLength.ToString().Trim();
                //pmsDocuments.Creator = LoginName;
                //pmsDocuments.CreateDate = dtCurDate;
                //#endregion

                //#region Upload PES File
                //if (pmsDocuments.FileName != "")
                //{
                //    strSavePath = strSavePath + "\\" + strPmsID;

                //    if (!QFile.CheckFolderExist(strSavePath))
                //    {
                //        QFile.CreateDirectory(strSavePath);
                //    }

                //    strSavePath = strSavePath + "\\" + pmsDocuments.FileName;

                //    pesUpload.PostedFile.SaveAs(strSavePath);
                //}
                #endregion
                #endregion

                #region For Insert SdpDetail
                SdpDetail sdpDetail = new SdpDetail();
                sdpDetail.Pmsid = strPmsID;
                sdpDetail.Type  = dropdownlistType.SelectedValue.Trim();
                #endregion

                #region For Insert PmsFlow

                //pmsFlowTemplateList = pmsFlowTemplateBiz.SelectPmsFlowTemplateByTypeId(dropdownlistType.SelectedValue.Trim());

                PmsFlow pmsFlow = new PmsFlow();
                pmsFlow.FlowId     = pmsFlowTemplateList[0].FlowId;
                pmsFlow.PmsId      = strPmsID;
                pmsFlow.Creator    = LoginName;
                pmsFlow.CreateDate = dtCurDate;
                #endregion

                #region For Insert PMSChangeHistory
                PmsChangeHistory pmsChangeHistory = new PmsChangeHistory();
                pmsChangeHistory.PmsId         = strPmsID;
                pmsChangeHistory.ChangeContent = "";
                pmsChangeHistory.Action        = "CREATE";
                pmsChangeHistory.CreateDate    = dtCurDate;
                pmsChangeHistory.Creator       = LoginName;
                #endregion

                #region For Insert Itarm_Cr_List
                ItarmCrList itarmCrList = new ItarmCrList();
                itarmCrList.CrId       = strCrId;
                itarmCrList.CrName     = textboxPmsName.Text.Trim().Replace("'", "");
                itarmCrList.Site       = dropdownlistSite.SelectedValue;
                itarmCrList.Creator    = LoginName;
                itarmCrList.CreateDate = dtCurDate;
                itarmCrList.Pm         = textboxPM.Text.Trim().Replace("'", "");
                itarmCrList.System     = textboxSystem.Text.Trim().Replace("'", "");

                #endregion

                #region Insert
                PmsHeadBiz pmsInsert = new PmsHeadBiz();

                string errorInfo;
                int    insertResult = pmsInsert.InsertPmsHeadAndDoc(pmsHeadInsert, sdpDetail, pmsChangeHistory, pmsItarmMapping, pmsFlow, itarmCrList, null, out errorInfo);

                if (insertResult == 0)
                {
                    Msgbox("Save Fail!");
                }
                else
                {
                    #region 更新系统版本表
                    bool upVerResult =
                        m_PmsCRCreatBiz.UpdateSysVersion(dropdownlistDomain.SelectedValue, textboxSystem.Text.Trim(), dropdownlistSite.SelectedValue, textboxNewVersion.Text.Trim());

                    if (!upVerResult)
                    {
                        Msgbox("Updated system version number fail!");
                    }

                    #endregion

                    //  Session["InquiryPage_Refresh"] = "Y";
                    //发送创建成功的Mail

                    LoginName.Replace(".", " ");
                    pmsHeadInsert.UserName = LoginName;
                    new MailBiz().SendCreateMail(pmsHeadInsert);

                    Msgbox("Create Successful!");
                    PageRegisterStartupScript("window.close();");
                }
                #endregion
            }
            catch (Exception exception)
            {
                Msgbox("Save Fail!");
            }
        }