Esempio n. 1
0
        /// <summary>
        /// Save Service Data
        /// </summary>
        /// <param name="pmsHead"></param>
        /// <param name="sdpDetail"></param>
        /// <param name="pmsFlow"></param>
        /// <param name="pmsDocuments"></param>
        /// <returns></returns>
        public int InsertServiceDataToDB(PmsHead pmsHead, SdpDetail sdpDetail, PmsFlow pmsFlow, PmsDocuments pmsDocuments)
        {
            int returnResult = 0;

            try
            {
                m_PMSSqlConnection.BeginTransaction();

                // Insert PmsHead
                pmsHead.Vid   = "PM";
                pmsHead.Stage = 1;
                pmsHead.Pm    = "";
                pmsHead.Sd    = "";
                pmsHead.Se    = "";
                pmsHead.Qa    = "";
                // m_PMSSqlConnection.Insert("InsertPmsHead", pmsHead);

                // Insert SdpDetail
                SdpDetailBiz sdpDetailBiz = new SdpDetailBiz();
                returnResult = sdpDetailBiz.InsertSdpDetailByTemplate(sdpDetail);

                if (returnResult == 0)
                {
                    m_PMSSqlConnection.RollBackTransaction();
                    return(returnResult);
                }

                // Insert PmsFlow
                PmsFlowBiz pmsFlowBiz = new PmsFlowBiz();
                pmsFlowBiz.InsertPmsFlow(pmsFlow);


                // Insert PmsDocuments
                if (pmsDocuments.FileName != string.Empty)
                {
                    m_PMSSqlConnection.Insert("InsertPmsDocuments", pmsDocuments);
                }

                m_PMSSqlConnection.CommitTransaction();
            }
            catch (Exception ex)
            {
                m_PMSSqlConnection.RollBackTransaction();
                m_Logger.Error("PmsHeadBiz/InsertServiceDataToDB" + ex.Message.ToString());
            }

            return(returnResult);
        }
Esempio n. 2
0
        public int InsertPmsHeadAndDoc(PmsHead pmsHead, SdpDetail sdpDetail, PmsChangeHistory pmsChangeHistory, PmsItarmMapping pmsItarmMapping,
                                       PmsFlow pmsFlow, ItarmCrList itarmCrList, IList <PmsDocuments> listPmsDocuments, out string errorInfo)
        {
            errorInfo = string.Empty;
            int returnResult = 0;

            try
            {
                m_PMSSqlConnection.BeginTransaction();

                #region Insert PmsHead
                //string type = pmsHead.PmsName.GetTypeCode;
                m_PMSSqlConnection.Insert("InsertPmsHead", pmsHead);
                #endregion

                #region Insert PmsItarmMapping
                PmsItarmMappingBiz pmsItarmMappingBiz = new PmsItarmMappingBiz();
                pmsItarmMappingBiz.InsertPmsItarmMapping(pmsItarmMapping);
                #endregion

                #region Insert PmsDocuments

                if (listPmsDocuments != null)
                {
                    foreach (PmsDocuments pmsDocuments in listPmsDocuments)
                    {
                        if (pmsDocuments.DocTypeId == 0)
                        {
                            errorInfo = "DocTypeId is Invalid!";
                            return(returnResult);
                        }

                        if (pmsDocuments.FileName == string.Empty)
                        {
                            errorInfo = "FileName is Empty!";
                            return(returnResult);
                        }

                        if (pmsDocuments.FileName != string.Empty)
                        {
                            m_PMSSqlConnection.Insert("InsertPmsDocuments", pmsDocuments);
                        }
                    }
                }


                #endregion

                #region Insert SdpDetail
                SdpDetailBiz sdpDetailBiz = new SdpDetailBiz();
                returnResult = sdpDetailBiz.InsertSdpDetailByTemplate(sdpDetail);

                if (returnResult == 0)
                {
                    m_PMSSqlConnection.RollBackTransaction();
                    return(returnResult);
                }
                #endregion

                #region Insert PmsChangeHistory
                PmsChangeHistoryBiz pmsChangeHistoryBiz = new PmsChangeHistoryBiz();
                pmsChangeHistoryBiz.InsertPmsChangeHistory(pmsChangeHistory);
                #endregion

                #region Insert PmsFlow
                PmsFlowBiz pmsFlowBiz = new PmsFlowBiz();
                pmsFlowBiz.InsertPmsFlow(pmsFlow);
                #endregion

                #region Insert ItarmCrList
                bool resultInsertItarm = new PmsCRCreatBiz().InsertItarmCrList(itarmCrList);
                if (!resultInsertItarm)
                {
                    m_PMSSqlConnection.RollBackTransaction();
                    errorInfo = "Save Fail";
                    return(0);
                }
                #endregion

                m_PMSSqlConnection.CommitTransaction();
            }
            catch (Exception ex)
            {
                m_PMSSqlConnection.RollBackTransaction();
                errorInfo = "Save Fail";
                m_Logger.Error("PmsHeadBiz/InsertPmsHeadAndDoc" + ex.Message.ToString());
            }

            return(returnResult);
        }