/// <summary>
        /// 保存CVT下线试验数据
        /// </summary>
        /// <param name="testInfo">CVT下线试验信息</param>
        /// <returns>返回操作是否成功的标志</returns>
        public bool SaveCVTExpData(CvtTestInfo testInfo)
        {
            if (testInfo == null)
            {
                throw new ArgumentException("试验数据参数不允许为空");
            }

            if (GlobalObject.GeneralFunction.IsNullOrEmpty(testInfo.CvtNumber))
            {
                throw new Exception("CVT编号不允许为空");
            }

            string[] cvtNumber = testInfo.CvtNumber.Split(new char[] { ' ' });

            if (cvtNumber.Length != 2)
            {
                throw new Exception("CVT编号格式不正确");
            }

            if (GlobalObject.GeneralFunction.IsNullOrEmpty(testInfo.OilType))
            {
                throw new Exception("油品类型不允许为空");
            }

            if (GlobalObject.GeneralFunction.IsNullOrEmpty(testInfo.TestDevice))
            {
                throw new Exception("试验设备名称不允许为空");
            }

            if (GlobalObject.GeneralFunction.IsNullOrEmpty(testInfo.TestResult))
            {
                throw new Exception("试验结果不允许为空");
            }

            if (GlobalObject.GeneralFunction.IsNullOrEmpty(testInfo.Tester))
            {
                throw new Exception("实验员不允许为空");
            }

            if (GlobalObject.GeneralFunction.IsNullOrEmpty(testInfo.PreassemblyPersonnel))
            {
                throw new Exception("预装员不允许为空");
            }

            if (testInfo.TestData == null || testInfo.TestData.Rows.Count == 0)
            {
                throw new Exception("试验项目表不允许为空");
            }

            string error = null;

            Hashtable paramTable = new Hashtable();

            paramTable.Add("@ProductType", cvtNumber[0]);
            paramTable.Add("@CvtNumber", cvtNumber[1]);
            paramTable.Add("@TestDevice", testInfo.TestDevice);
            paramTable.Add("@OilType", testInfo.OilType);
            paramTable.Add("@TestResult", testInfo.TestResult);
            paramTable.Add("@Tester", testInfo.Tester);
            paramTable.Add("@PreassemblyPersonnel", testInfo.PreassemblyPersonnel);
            paramTable.Add("@Remark", testInfo.Remark);

            IDBOperate dbOperate = AccessDB.GetIDBOperate("DepotManagement");

            string[]    lstCmd    = new string[testInfo.TestData.Rows.Count + 1];
            Hashtable[] lstParam  = new Hashtable[testInfo.TestData.Rows.Count + 1];
            Hashtable[] outParams = new Hashtable[testInfo.TestData.Rows.Count + 1];

            lstCmd[0]   = "ZPX_InsertCVTTestInfo";
            lstParam[0] = paramTable;

            for (int i = 0; i < testInfo.TestData.Rows.Count; i++)
            {
                lstCmd[i + 1] = "ZPX_InsertCVTTestDataItems";

                paramTable = new Hashtable();

                paramTable.Add("@TestType", testInfo.TestData.Rows[i]["TestType"].ToString());
                paramTable.Add("@TestItemName", testInfo.TestData.Rows[i]["TestItemName"].ToString());
                paramTable.Add("@TestCondition", testInfo.TestData.Rows[i]["TestCondition"].ToString());
                paramTable.Add("@TestRequirement", testInfo.TestData.Rows[i]["TestRequirement"].ToString());
                paramTable.Add("@TestData", testInfo.TestData.Rows[i]["TestData"].ToString());
                paramTable.Add("@TestResult", testInfo.TestData.Rows[i]["TestResult"].ToString());

                lstParam[i + 1] = paramTable;
            }

            Dictionary <OperateCMD, object> dicOperateCMD = dbOperate.Transaction_CMD(lstCmd, lstParam, ref outParams);

            if (!AccessDB.GetResult(dicOperateCMD, out error))
            {
                throw new Exception(error);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 修改指定BOM节点的总成标志信息
        /// </summary>
        /// <param name="edition">版本</param>
        /// <param name="bom">要修改的BOM节点</param>
        /// <param name="isAssembly">修改成的总成标志</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>返回是否成功的标志</returns>
        //public bool UpdateBom(string edition, Bom bom, bool isAssembly, out string error)
        //{
        //    error = null;

        //    Hashtable paramTable = new Hashtable();

        //    if (bom.ParentCode != "")
        //    {
        //        paramTable.Add("@ParentCode", bom.ParentCode);
        //    }
        //    else
        //    {
        //        paramTable.Add("@ParentCode", DBNull.Value);
        //    }

        //    paramTable.Add("@PartCode", bom.PartCode);
        //    paramTable.Add("@AssemblyFlag", Convert.ToInt32(isAssembly));
        //    paramTable.Add("@Edition", edition);
        //    paramTable.Add("@UserCode", bom.UserCode);
        //    paramTable.Add("@FillDate", bom.FillData);
        //    paramTable.Add("@Version", bom.Version);

        //    Dictionary<OperateCMD, object> dicOperateCMD = m_dbOperate.Transaction_CMD("Update_ProductBomAssemblyFlag", paramTable);

        //    if (!Convert.ToBoolean(dicOperateCMD[OperateCMD.Return_OperateResult]))
        //    {
        //        error = Convert.ToString(dicOperateCMD[OperateCMD.Return_Errmsg]);
        //        return false;
        //    }

        //    return true;
        //}

        /// <summary>
        /// 删除BOM信息
        /// </summary>
        /// <param name="edition">版本</param>
        /// <param name="lstBom">要删除的BOM信息列表</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>返回是否成功的标志</returns>
        public bool UpdateBom(string edition, List <Bom> lstBom, out string error)
        {
            error = null;

            string[]    cmds      = new string[lstBom.Count];
            Hashtable[] inParams  = new Hashtable[lstBom.Count];
            Hashtable[] outParams = new Hashtable[lstBom.Count];
            int         i         = 0;

            foreach (var bom in lstBom)
            {
                Hashtable paramTable = new Hashtable();

                if (bom.ParentCode != "")
                {
                    paramTable.Add("@ParentCode", bom.ParentCode);
                }
                else
                {
                    paramTable.Add("@ParentCode", DBNull.Value);
                }

                paramTable.Add("@PartCode", bom.PartCode);
                paramTable.Add("@AssemblyFlag", Convert.ToInt32(bom.AssemblyFlag));
                paramTable.Add("@Edition", edition);
                paramTable.Add("@Spec", bom.Spec);
                paramTable.Add("@Version", bom.Version);

                if (bom.StatusFlag == Bom.Status.Remove)
                {
                    cmds[i] = "DelP_ProductBom";
                }
                else if (bom.StatusFlag == Bom.Status.Add || bom.StatusFlag == Bom.Status.Update)
                {
                    if (bom.StatusFlag == Bom.Status.Update)
                    {
                        paramTable.Add("@Id", bom.Id);
                        cmds[i] = "UpdateP_ProductBom";
                    }
                    else
                    {
                        cmds[i] = "AddP_ProductBom";
                    }

                    paramTable.Add("@PartName", bom.PartName);
                    paramTable.Add("@Counts", Convert.ToInt32(bom.Counts));

                    if (bom.Remark != "")
                    {
                        if (bom.AssemblyFlag)
                        {
                            paramTable.Add("@Remark", bom.Remark + "该记录为总成记录");
                        }
                        else
                        {
                            paramTable.Add("@Remark", bom.Remark);
                        }
                    }
                    else
                    {
                        paramTable.Add("@Remark", DBNull.Value);
                    }

                    paramTable.Add("@UserCode", bom.UserCode);
                    paramTable.Add("@FillDate", bom.FillData);
                }

                inParams[i++] = paramTable;
            }

            Dictionary <OperateCMD, object> dicOperateCMD = m_dbOperate.Transaction_CMD(cmds, inParams, ref outParams);

            if (!Convert.ToBoolean(dicOperateCMD[OperateCMD.Return_OperateResult]))
            {
                error = Convert.ToString(dicOperateCMD[OperateCMD.Return_Errmsg]);
                return(false);
            }

            return(true);
        }