Exemple #1
0
        /// <summary>
        /// 添加数据
        /// </summary>
        /// <param name="data">要添加的数据</param>
        /// <returns>操作是否成功的标志</returns>
        public bool Add(ZPX_CVTOffLineTestResult data)
        {
            DepotManagementDataContext context = CommentParameter.DepotDataContext;

            var result = from r in context.ZPX_CVTOffLineTestResult
                         where r.ProductType == data.ProductType && r.ProductNumber == data.ProductNumber &&
                         !r.ReviewFlag
                         select r;

            if (result.Count() > 0)
            {
                throw new Exception("已经存在此记录,不允许重复添加");
            }

            data.Date = ServerTime.Time;

            var resultLog = from a in context.ZPX_CVTOffLineTestResultLog
                            where a.ProdutCode == data.ProductType + " " + data.ProductNumber
                            select a;

            context.ZPX_CVTOffLineTestResultLog.DeleteAllOnSubmit(resultLog);

            context.ZPX_CVTOffLineTestResult.InsertOnSubmit(data);
            context.SubmitChanges();

            return(true);
        }
Exemple #2
0
        /// <summary>
        /// 审核数据
        /// </summary>
        /// <param name="dataID">要审核的数据编号</param>
        /// <returns>操作是否成功的标志</returns>
        public bool Auditing(int dataID)
        {
            DepotManagementDataContext context = CommentParameter.DepotDataContext;

            var result = from r in context.ZPX_CVTOffLineTestResult
                         where r.ID == dataID
                         select r;

            if (result.Count() == 0)
            {
                throw new Exception("找不到要审核的记录,无法进行此操作");
            }

            ZPX_CVTOffLineTestResult updateData = result.Single();

            if (updateData.UserCode != GlobalObject.BasicInfo.LoginID)
            {
                throw new Exception("不是记录创建人员不允许进行此操作");
            }

            if (updateData.ReviewFlag)
            {
                throw new Exception("记录已经审核,不允许进行此操作");
            }

            updateData.ReviewFlag = true;
            updateData.ReviewDate = ServerTime.Time;

            context.SubmitChanges();

            return(true);
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (!CheckData())
                {
                    return;
                }

                ZPX_CVTOffLineTestResult data = new ZPX_CVTOffLineTestResult();

                data.ProductType   = cmbProductCode.Text;
                data.ProductNumber = txtProductNumber.Text;
                data.Assembler     = txtAssembler.Tag.ToString();
                data.Fault         = txtFault.Text;
                data.Remark        = txtRemark.Text.Trim();
                data.QualifiedFlag = 试验合格.Checked;
                data.UserCode      = GlobalObject.BasicInfo.LoginID;
                data.Type          = cmbRepairType.Text;

                m_testServer.Add(data);

                RefreshDataGridView(m_testServer.GetViewData(new View_ZPX_CVTOffLineTestResult()
                {
                    编号 = data.ID
                }));
            }
            catch (Exception exce)
            {
                MessageDialog.ShowErrorMessage(exce.Message);
            }
        }
Exemple #4
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="data">要更新的数据</param>
        /// <returns>操作是否成功的标志</returns>
        public bool Update(View_ZPX_CVTOffLineTestResult data)
        {
            DepotManagementDataContext context = CommentParameter.DepotDataContext;

            var result = from r in context.ZPX_CVTOffLineTestResult
                         where r.ID == data.编号
                         select r;

            if (result.Count() == 0)
            {
                throw new Exception("找不到要更新的记录,无法进行此操作");
            }

            ZPX_CVTOffLineTestResult updateData = result.Single();

            if (updateData.UserCode != GlobalObject.BasicInfo.LoginID)
            {
                throw new Exception("不是记录创建人员不允许进行此操作");
            }

            if (updateData.ReviewFlag)
            {
                throw new Exception("记录已经审核,不允许进行此操作");
            }

            View_ZPX_CVTOffLineTestResult old = (from r in context.View_ZPX_CVTOffLineTestResult
                                                 where r.编号 == data.编号
                                                 select r).Single();

            if (GlobalObject.StapleFunction.SimpleEqual <View_ZPX_CVTOffLineTestResult>(old, data))
            {
                throw new Exception("数据没有任何变化,不需要进行此操作");
            }

            PlatformManagement.ILogManagement log =
                PlatformManagement.PlatformFactory.GetObject <PlatformManagement.ILogManagement>();

            log.WriteUpdateLog <View_ZPX_CVTOffLineTestResult>(GlobalObject.BasicInfo.LoginID, "下线试验信息管理",
                                                               new List <string>(new string[] { "编号" }), old, data);

            updateData.ProductType   = data.产品型号;
            updateData.ProductNumber = data.产品箱号;
            updateData.Assembler     = data.预装员工号;
            updateData.Date          = ServerTime.Time;
            updateData.QualifiedFlag = data.合格标志;
            updateData.Fault         = data.故障现象;
            updateData.Remark        = data.备注;

            context.SubmitChanges();

            return(true);
        }
Exemple #5
0
        /// <summary>
        /// 更新说明
        /// </summary>
        /// <param name="data">要更新的数据</param>
        /// <returns>操作是否成功的标志</returns>
        public bool UpdateRemark(View_ZPX_CVTOffLineTestResult data)
        {
            DepotManagementDataContext context = CommentParameter.DepotDataContext;

            var result = from r in context.ZPX_CVTOffLineTestResult
                         where r.ID == data.编号
                         select r;

            if (result.Count() == 0)
            {
                throw new Exception("找不到要更新的记录,无法进行此操作");
            }

            ZPX_CVTOffLineTestResult updateData = result.Single();

            if (updateData.UserCode != GlobalObject.BasicInfo.LoginID)
            {
                throw new Exception("不是记录创建人员不允许进行此操作");
            }

            View_ZPX_CVTOffLineTestResult old = (from r in context.View_ZPX_CVTOffLineTestResult
                                                 where r.编号 == data.编号
                                                 select r).Single();

            PlatformManagement.ILogManagement log =
                PlatformManagement.PlatformFactory.GetObject <PlatformManagement.ILogManagement>();

            log.WriteUpdateLog <View_ZPX_CVTOffLineTestResult>(GlobalObject.BasicInfo.LoginID, "下线试验信息管理",
                                                               new List <string>(new string[] { "编号" }), old, data);

            updateData.Remark = data.备注;

            context.SubmitChanges();

            return(true);
        }