/// <summary>
        /// 修改点检内容
        /// </summary>
        /// <param name="inspectionContentSet">点检内容数据集</param>
        /// <param name="cvtTypeList">适用CVT型号数据列表</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        public bool UpdateContent(ZPX_InspectionContentSet inspectionContentSet, List <string> cvtTypeList, out string error)
        {
            error = null;

            DepotManagementDataContext dataContext = CommentParameter.DepotDataContext;

            dataContext.Connection.Open();
            dataContext.Transaction = dataContext.Connection.BeginTransaction();

            try
            {
                var varData = from a in dataContext.ZPX_InspectionContentSet
                              where a.ID == inspectionContentSet.ID
                              select a;

                if (varData.Count() != 1)
                {
                    error = "数据为空或者不唯一";
                    throw new Exception(error);
                }
                else
                {
                    ZPX_InspectionContentSet lnqContent = varData.Single();

                    lnqContent.InspectionContent = inspectionContentSet.InspectionContent;
                    lnqContent.WorkBench         = inspectionContentSet.WorkBench;
                    lnqContent.Date   = ServerTime.Time;
                    lnqContent.WorkID = BasicInfo.LoginID;

                    dataContext.SubmitChanges();
                }

                var varDataCVT = from a in dataContext.ZPX_InspectionContentCVTType
                                 where a.ContentID == inspectionContentSet.ID
                                 select a;

                dataContext.ZPX_InspectionContentCVTType.DeleteAllOnSubmit(varDataCVT);

                foreach (string cvtType in cvtTypeList)
                {
                    ZPX_InspectionContentCVTType lnqCVTType = new ZPX_InspectionContentCVTType();

                    lnqCVTType.ContentID = inspectionContentSet.ID;
                    lnqCVTType.CVTType   = cvtType;

                    dataContext.ZPX_InspectionContentCVTType.InsertOnSubmit(lnqCVTType);
                }

                dataContext.SubmitChanges();

                dataContext.Transaction.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                dataContext.Transaction.Rollback();
                error = ex.Message;
                return(false);
            }
        }
Esempio n. 2
0
        private void btnContentUpdate_Click(object sender, EventArgs e)
        {
            if (m_lstCVTType.Count == 0 &&
                MessageDialog.ShowEnquiryMessage("此记录未选择任何CVT适用型号,是否继续?") == DialogResult.No)
            {
                return;
            }

            ZPX_InspectionContentSet lnqContent = new ZPX_InspectionContentSet();

            lnqContent.ID = Convert.ToInt32(txtInspectionContent.Tag);
            lnqContent.InspectionContent = txtInspectionContent.Text;
            lnqContent.WorkBench         = txtWorkBench.Text;
            lnqContent.Date   = ServerTime.Time;
            lnqContent.WorkID = BasicInfo.LoginID;

            if (!m_serverInspection.UpdateContent(lnqContent, m_lstCVTType, out m_strErr))
            {
                MessageBox.Show(m_strErr);
            }

            RefrshData();

            PositioningContentRecord(lnqContent.ID.ToString());
        }
Esempio n. 3
0
        private void btnContentAdd_Click(object sender, EventArgs e)
        {
            if (m_lstCVTType.Count == 0 &&
                MessageDialog.ShowEnquiryMessage("此记录未选择任何CVT适用型号,是否继续?") == DialogResult.No)
            {
                return;
            }

            ZPX_InspectionContentSet lnqContent = new ZPX_InspectionContentSet();

            lnqContent.InspectionContent = txtInspectionContent.Text;
            lnqContent.WorkBench         = txtWorkBench.Text;
            lnqContent.WorkID            = BasicInfo.LoginID;
            lnqContent.Date = ServerTime.Time;
            lnqContent.Msrepl_tran_version = Guid.NewGuid();

            if (!m_serverInspection.AddContent(lnqContent, m_lstCVTType, out m_strErr))
            {
                MessageBox.Show(m_strErr);
            }

            RefrshData();

            PositioningContentRecord(m_serverInspection.GetSingleContentInfo(lnqContent).ID.ToString());
        }
        /// <summary>
        /// 获得一条点检内容记录
        /// </summary>
        /// <param name="inspectionContentSet">点检内容数据集</param>
        /// <returns>返回数据集</returns>
        public ZPX_InspectionContentSet GetSingleContentInfo(ZPX_InspectionContentSet inspectionContentSet)
        {
            DepotManagementDataContext dataContext = CommentParameter.DepotDataContext;

            var varData = from a in dataContext.ZPX_InspectionContentSet
                          where a.InspectionContent == inspectionContentSet.InspectionContent &&
                          a.WorkBench == inspectionContentSet.WorkBench
                          select a;

            return(varData.Single());
        }
        /// <summary>
        /// 新增点检内容
        /// </summary>
        /// <param name="inspectionContentSet">点检内容数据集</param>
        /// <param name="cvtTypeList">适用CVT型号数据列表</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        public bool AddContent(ZPX_InspectionContentSet inspectionContentSet, List <string> cvtTypeList, out string error)
        {
            error = null;

            DepotManagementDataContext dataContext = CommentParameter.DepotDataContext;

            dataContext.Connection.Open();
            dataContext.Transaction = dataContext.Connection.BeginTransaction();

            try
            {
                var varData = from a in dataContext.ZPX_InspectionContentSet
                              where a.InspectionContent == inspectionContentSet.InspectionContent &&
                              a.WorkBench == inspectionContentSet.WorkBench
                              select a;

                if (varData.Count() != 0)
                {
                    error = "数据不唯一";
                    throw new Exception(error);
                }
                else
                {
                    dataContext.ZPX_InspectionContentSet.InsertOnSubmit(inspectionContentSet);
                }

                dataContext.SubmitChanges();

                int ContentID = (from a in dataContext.ZPX_InspectionContentSet
                                 where a.InspectionContent == inspectionContentSet.InspectionContent &&
                                 a.WorkBench == inspectionContentSet.WorkBench
                                 select a).Single().ID;

                foreach (string cvtType in cvtTypeList)
                {
                    ZPX_InspectionContentCVTType lnqCVTType = new ZPX_InspectionContentCVTType();

                    lnqCVTType.ContentID = ContentID;
                    lnqCVTType.CVTType   = cvtType;

                    dataContext.ZPX_InspectionContentCVTType.InsertOnSubmit(lnqCVTType);
                }

                dataContext.SubmitChanges();
                dataContext.Transaction.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                dataContext.Transaction.Rollback();
                error = ex.Message;
                return(false);
            }
        }