/// <summary>
        /// 获取材料类别信息表
        /// </summary>
        /// <param name="lstMaterialType">材料类别信息表</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>返回是否成功获取材料类别信息表</returns>
        public bool GetAllMaterialType(out List <MaterialTypeData> lstMaterialType, out string error)
        {
            lstMaterialType = null;
            error           = null;

            DataSet ds = new DataSet();

            if (!AccessDB.ExecuteDbProcedure("SelAllS_Depot", ds, out error))
            {
                return(false);
            }

            DataTable dt = ds.Tables[0];

            if (dt == null || dt.Rows.Count == 0)
            {
                error = "没有获取到材料类别信息";
                return(false);
            }

            lstMaterialType = new List <MaterialTypeData>(dt.Rows.Count);

            foreach (DataRow row in dt.Rows)
            {
                MaterialTypeData info = GetMaterialTypeInfo(row, dt.Columns);
                lstMaterialType.Add(info);
            }

            return(true);
        }
Exemple #2
0
        /// <summary>
        /// 重置允许加班调休的时间
        /// </summary>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        public bool AddAttendanceSummaryByAllowOverTime(out string error)
        {
            error = "";

            if (!AccessDB.ExecuteDbProcedure("HR_Update_OverTime", out error))
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// 获取零部件的条形码
        /// </summary>
        /// <param name="partCodes">要获取条形码的零部件</param>
        /// <param name="barcodes">零部件代码与条形码配对的字典, 如果某零部件没有获取到条形码则该零部件value值为null</param>
        /// <param name="err">错误信息, 如果没有则输出值为null</param>
        /// <returns>成功返回true, 失败返回false</returns>
        public bool GetBarcodeOfParts(string[] partCodes, out Dictionary <string, string> barcodes, out string err)
        {
            Debug.Assert(partCodes != null && partCodes.Length > 0, "参数 'partCodes' 不能为 null");

            barcodes = null;
            err      = null;

            if (partCodes == null)
            {
                err = "partCodes 不能为 null";
                return(false);
            }

            string strPartCodes = "";

            for (int i = 0; i < partCodes.Length; i++)
            {
                strPartCodes = strPartCodes.Insert(strPartCodes.Length, partCodes[i]);

                if (i != partCodes.Length - 1)
                {
                    strPartCodes = strPartCodes.Insert(strPartCodes.Length, ",");
                }
            }

            // 执行存储过程从数据库中获取数据表
            Hashtable paramTable = new Hashtable();

            paramTable.Add("@PartCodes", strPartCodes);

            DataSet ds = new DataSet();

            if (!AccessDB.ExecuteDbProcedure("SelectPartBarcode", paramTable, ds, out err))
            {
                return(false);
            }

            DataTable dt = ds.Tables[0];

            if (dt == null || dt.Rows.Count == 0)
            {
                err = "没有获取到装配条码信息";
                return(false);
            }

            barcodes = new Dictionary <string, string>(dt.Rows.Count);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                barcodes.Add(dt.Rows[i][0].ToString(), dt.Rows[i][1].ToString());
            }

            return(true);
        }
        /// <summary>
        /// 添加材料类别
        /// </summary>
        /// <param name="materialType">要增加的材料类别信息</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>成功返回true</returns>
        public bool AddMaterialType(MaterialTypeData materialType, out string error)
        {
            error = null;

            Hashtable paramTable = GetParamTable(materialType);

            if (!AccessDB.ExecuteDbProcedure("AddMaterialType", paramTable, out error))
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// 更新数据库中用于生成管理条形码的流水号数据(流水号在在以前的基础上+产品数量)
        /// </summary>
        /// <param name="assemblyName">总成名称, 仅对独立装配有效,整台装配时此值必须为NULL</param>
        /// <param name="batchBarcodeInf">条形码信息</param>
        /// <param name="productAmount">产品数量</param>
        /// <param name="err">错误信息, 如果没有则输出值为null</param>
        /// <returns>成功返回true, 失败返回false</returns>
        private bool UpdateSerialNumber(string assemblyName, BatchBarcodeInf batchBarcodeInf, int productAmount, out string err)
        {
            Debug.Assert(batchBarcodeInf != null && batchBarcodeInf.Barcodes != null, "参数 'batchBarcodeInf' 不能为 null");
            Debug.Assert(productAmount > 0, "参数 'productAmount' 必须 > 0");

            err = null;

            if (batchBarcodeInf == null || batchBarcodeInf.Barcodes == null)
            {
                err = "参数 'batchBarcodeInf' 不能为 null";
                return(false);
            }

            if (productAmount < 1)
            {
                err = "参数 'productAmount' 必须 > 0";
                return(false);
            }

            // 执行存储过程从数据库中获取数据表
            Hashtable paramTable = new Hashtable();

            int productTypeID = 0;

            foreach (KeyValuePair <string, AssemblyManagementBarcode> var in batchBarcodeInf.Barcodes)
            {
                productTypeID = Convert.ToInt32(var.Value.SourceData[1]);
                break;
            }

            paramTable.Add("@ProductTypeID", productTypeID);

            if (GlobalObject.GeneralFunction.IsNullOrEmpty(assemblyName))
            {
                paramTable.Add("@AssemblyName", DBNull.Value);
            }
            else
            {
                paramTable.Add("@AssemblyName", assemblyName);
            }

            paramTable.Add("@UpdateAmount", productAmount);

            if (!AccessDB.ExecuteDbProcedure("UpdateSerialNoOfAssemblyLineBarcode", paramTable, out err))
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// 删除某一材料类别信息
        /// </summary>
        /// <param name="materialTypeCode">材料类别编码</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>返回是否成功删除某一材料类别信息</returns>
        public bool DeleteMaterialType(string materialTypeCode, out string error)
        {
            error = null;

            Hashtable paramTable = new Hashtable();

            paramTable.Add("@MaterialTypeCode", materialTypeCode);

            if (!AccessDB.ExecuteDbProcedure("DelMaterialType", paramTable, out error))
            {
                return(false);
            }

            return(true);
        }
Exemple #7
0
        /// <summary>
        /// 添加考勤分析汇总
        /// </summary>
        /// <param name="workID">员工编号</param>
        /// <param name="starDate">考勤起始日期</param>
        /// <param name="endDate">考勤截止日期</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        public bool AddAttendanceSummary(string workID, DateTime starDate, DateTime endDate, out string error)
        {
            error = "";

            string    sql = "SELECT * FROM HR_AttendanceSummary where year=" + endDate.Year + " and month=" + endDate.Month;
            DataTable dt  = GlobalObject.DatabaseServer.QueryInfo(sql);

            if (dt != null)
            {
                Hashtable paramTable = new Hashtable();

                paramTable.Add("@workID", workID);
                paramTable.Add("@starDate", starDate.Date);
                paramTable.Add("@endDate", endDate.Date);
                paramTable.Add("@recorder", BasicInfo.LoginID);

                if (!AccessDB.ExecuteDbProcedure("HR_Add_AttendanceSummary", paramTable, out error))
                {
                    return(false);
                }
            }

            return(true);
        }
        /// <summary>
        /// 根据指定的流水号批量生成重复使用的条形码(不更改数据库中装配管理条形码表中各零部件的流水号)
        /// </summary>
        /// <param name="productTypeCode">产品类型编码</param>
        /// <param name="assemblyName">总成名称, 仅对独立装配有效,整台装配时此值必须为NULL</param>
        /// <param name="productAmount">本班次生产的产品数量,直接影响生成的条码数</param>
        /// <param name="beginSerialNumber">起始流水码</param>
        /// <param name="batchBarcodeInf">批量生成的条形码信息(可能会包含产品编码、零部件名称等其它附加信息), 如果操作失败输出值为null</param>
        /// <param name="err">错误信息, 如果没有则输出值为null</param>
        /// <returns>成功返回true, 失败返回false</returns>
        public bool BatchGenerateBarcodeForRepeatedMode(
            string productTypeCode, string assemblyName, int productAmount,
            int beginSerialNumber, out BatchBarcodeInf batchBarcodeInf, out string err)
        {
            Debug.Assert(productTypeCode != null && productTypeCode.Length > 0, "参数 'productCode' 不能为 null 或空串");
            Debug.Assert(productAmount > 0, "参数 'productAmount' 必须 > 0");

            batchBarcodeInf = null;
            err             = null;

            if (productTypeCode == null || productTypeCode.Length == 0)
            {
                err = "参数 'productCode' 不能为 null 或空串";
                return(false);
            }

            if (productAmount < 1)
            {
                err = "参数 'productAmount' 必须 > 0";
                return(false);
            }

            // 执行存储过程从数据库中获取数据表
            Hashtable paramTable = new Hashtable();

            paramTable.Add("@productCode", productTypeCode);

            if (GlobalObject.GeneralFunction.IsNullOrEmpty(assemblyName))
            {
                paramTable.Add("@AssemblyName", DBNull.Value);
            }
            else
            {
                paramTable.Add("@AssemblyName", assemblyName);
            }

            DataSet ds = new DataSet();

            if (!AccessDB.ExecuteDbProcedure("SelP_AssemblyLineBarcode", paramTable, ds, out err))
            {
                return(false);
            }

            DataTable dt = ds.Tables[0];

            if (dt == null || dt.Rows.Count == 0)
            {
                err = "没有获取到装配条码信息";
                return(false);
            }

            // 创建存储生成的管理条形码信息的对象
            BatchBarcodeInf managementBarcode = new BatchBarcodeInf();

            // 从数据表中提取生成条形码的源数据
            ExtractSourceDataFormDT(productTypeCode, productAmount, dt, managementBarcode);

            int serialNumber = beginSerialNumber;

            // 根据规则生成条形码
            foreach (KeyValuePair <string, AssemblyManagementBarcode> var in managementBarcode.Barcodes)
            {
                var.Value.SerialNumber = serialNumber++;

                for (int i = 0; i < productAmount; i++)
                {
                    var.Value.Barcode[i] = string.Format("{0} {1:D3}", var.Value.PartCode, beginSerialNumber + i);
                }
            }

            // 输出的条形码信息
            batchBarcodeInf = managementBarcode;

            return(true);
        }
        /// <summary>
        /// 批量生成条形码(生成条形码成功后会自动增加数据库中的装配管理条形码表中各零部件的流水号)
        /// </summary>
        /// <param name="productTypeCode">产品类型编码</param>
        /// <param name="assemblyName">总成名称, 仅对独立装配有效,整台装配时此值必须为NULL</param>
        /// <param name="productAmount">本班次生产的产品数量,直接影响生成的条码数</param>
        /// <param name="remark">备注信息</param>
        /// <param name="batchBarcodeInf">批量生成的条形码信息(可能会包含产品编码、零部件名称等其它附加信息), 如果操作失败输出值为null</param>
        /// <param name="err">错误信息, 如果没有则输出值为null</param>
        /// <returns>成功返回true, 失败返回false</returns>
        public bool BatchGenerateBarcode(string productTypeCode, string assemblyName, int productAmount, string remark, out BatchBarcodeInf batchBarcodeInf, out string err)
        {
            Debug.Assert(productTypeCode != null && productTypeCode.Length > 0, "参数 'productCode' 不能为 null 或空串");
            Debug.Assert(productAmount > 0, "参数 'productAmount' 必须 > 0");

            batchBarcodeInf = null;
            err             = null;

            if (productTypeCode == null || productTypeCode.Length == 0)
            {
                err = "参数 'productCode' 不能为 null 或空串";
                return(false);
            }

            if (productAmount < 1)
            {
                err = "参数 'productAmount' 必须 > 0";
                return(false);
            }

            // 执行存储过程从数据库中获取数据表
            Hashtable paramTable = new Hashtable();

            paramTable.Add("@ProductTypeCode", productTypeCode);
            paramTable.Add("@UpdateAmount", productAmount);
            paramTable.Add("@IsRepairMode", productTypeCode.Contains(" FX") ? 1 : 0);
            paramTable.Add("@UserCode", GlobalObject.BasicInfo.LoginID);
            paramTable.Add("@Remark", GlobalObject.GeneralFunction.IsNullOrEmpty(remark) ? "打印装配条形码" : remark);

            if (GlobalObject.GeneralFunction.IsNullOrEmpty(assemblyName))
            {
                paramTable.Add("@AssemblyName", DBNull.Value);
            }
            else
            {
                paramTable.Add("@AssemblyName", assemblyName);
            }

            DataSet ds = new DataSet();

            if (!AccessDB.ExecuteDbProcedure("ZPX_AssignAssemblyLineBarcode", paramTable, ds, out err))
            {
                return(false);
            }

            DataTable dt = ds.Tables[0];

            if (dt == null || dt.Rows.Count == 0)
            {
                err = "没有获取到装配条码信息";
                return(false);
            }

            // 创建存储生成的管理条形码信息的对象
            BatchBarcodeInf managementBarcode = new BatchBarcodeInf();

            // 从数据表中提取生成条形码的源数据
            ExtractSourceDataFormDT(productTypeCode, productAmount, dt, managementBarcode);

            DateTime dt1     = ServerModule.ServerTime.Time;
            DateTime barDate = dt1;

            if (dt1.Day > 25)
            {
                if (dt1.Month == 12)
                {
                    barDate = new DateTime(dt1.Year + 1, 1, 1);
                }
                else
                {
                    barDate = new DateTime(dt1.Year, dt1.Month + 1, 1);
                }
            }

            // 根据规则生成条形码
            foreach (KeyValuePair <string, AssemblyManagementBarcode> var in managementBarcode.Barcodes)
            {
                BuildBarcode(productTypeCode, productAmount, barDate, var.Value);
            }

            // 输出的条形码信息
            batchBarcodeInf = managementBarcode;

            return(true);
        }