Exemplo n.º 1
0
        public bool GetProductGYlistBygxDuanCode(string gxDuanCode, ref List <Mes_ProductGYInfo> lst, ref string machineName, ref string machineType, ref string ErrMsg)
        {
            lst = new List <Mes_ProductGYInfo>();
            try
            {
                ErrMsg = "";

                string strSql = "select MachineName,MachineType from Mes_GYD where gxDuanCode ='" + gxDuanCode + "' and isdel !=2 ";

                using (IDataReader dr = dbFactory.ExecuteReader(CommandType.Text, strSql))
                {
                    if (dr.Read())
                    {
                        machineName = dr["machineName"].ToDBString();
                        machineType = dr["machineType"].ToDBString();
                    }
                    else
                    {
                        machineName = machineType = "";
                    }
                }

                strSql = "select id,gxID,gxName,description,imagePic,imagePic2,imagePic3,videoUrl,gxSeq from Mes_GY where gxDuanCode ='" + gxDuanCode + "' and isdel !=2 and rownum < 100 ";

                using (IDataReader dr = dbFactory.ExecuteReader(CommandType.Text, strSql))
                {
                    while (dr.Read())
                    {
                        Mes_ProductGYInfo model = new Mes_ProductGYInfo();

                        model.ID          = dr["ID"].ToInt32();
                        model.gxID        = dr["gxID"].ToDBString();
                        model.gxName      = dr["gxName"].ToDBString();
                        model.description = dr["description"].ToDBString();
                        model.videoUrl    = dr["videoUrl"].ToDBString();
                        model.gxSeq       = dr["gxSeq"].ToInt32();
                        if (!string.IsNullOrWhiteSpace(dr["imagePic"].ToString()))
                        {
                            model.imagePic = (byte[])dr["imagePic"];
                        }
                        else
                        {
                            model.imagePic = null;
                        }
                        if (!string.IsNullOrWhiteSpace(dr["imagePic2"].ToString()))
                        {
                            model.imagePic2 = (byte[])dr["imagePic2"];
                        }
                        else
                        {
                            model.imagePic2 = null;
                        }
                        if (!string.IsNullOrWhiteSpace(dr["imagePic3"].ToString()))
                        {
                            model.imagePic3 = (byte[])dr["imagePic3"];
                        }
                        else
                        {
                            model.imagePic3 = null;
                        }

                        model.lstLimit = new List <Mes_ProductGY_LimitInfo>();

                        lst.Add(model);
                    }
                }

                //Mes_GY_Limit
                strSql = "select * from Mes_GY_Limit t where t.gxID in (select gxID from Mes_GY where gxDuanCode='" + gxDuanCode + "')";

                List <Mes_ProductGY_LimitInfo> lstLimit = new List <Mes_ProductGY_LimitInfo>();

                using (IDataReader dr = dbFactory.ExecuteReader(CommandType.Text, strSql))
                {
                    while (dr.Read())
                    {
                        Mes_ProductGY_LimitInfo model = new Mes_ProductGY_LimitInfo();

                        model.ID         = dr["ID"].ToInt32();
                        model.xzID       = dr["xzID"].ToDBString();
                        model.gyDetailID = dr["gxID"].ToDBString();
                        //model.gyLineID = dr["gyLineID"].ToDBString();
                        model.type  = dr["type"].ToDBString();
                        model.seqno = dr["seqno"].ToInt32();

                        model.xzName    = dr["xzName"].ToDBString();
                        model.xzRoleMax = dr["xzRoleMax"].ToDBString();
                        model.xzRoleMin = dr["xzRoleMin"].ToDBString();
                        model.QTY       = dr["QTY"].ToDBString();
                        model.Unit      = dr["Unit"].ToDBString();

                        lstLimit.Add(model);
                    }
                }

                if (lstLimit.Count > 0)
                {
                    lst.ForEach(delegate(Mes_ProductGYInfo entityGy)
                    {
                        var templst = lstLimit.FindAll(t => t.gyDetailID == entityGy.gxID);

                        if (templst != null && templst.Count > 0)
                        {
                            entityGy.lstLimit = templst;
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                ErrMsg = ex.Message;
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        public bool GetProductGYListDataBygxDuanCode(string gxDuanCode, ref Mes_ProductGYDInfo entityGYD, ref string ErrMsg)
        {
            string strSql = string.Empty;

            strSql = "select * from Mes_GYD t where t.gxDuanCode='" + gxDuanCode + "'";

            try
            {
                //GYD
                entityGYD = new Mes_ProductGYDInfo();

                using (IDataReader dr = dbFactory.ExecuteReader(CommandType.Text, strSql))
                {
                    if (dr.Read())
                    {
                        entityGYD.ID         = dr["ID"].ToInt32();
                        entityGYD.bbNo       = dr["bbNo"].ToDBString();
                        entityGYD.gxDuanCode = dr["gxDuanCode"].ToDBString();
                        entityGYD.gxDuanName = dr["gxDuanName"].ToDBString();

                        //add by cym 2018-10-29
                        entityGYD.gxSeq  = dr["seqno"].ToInt32();
                        entityGYD.cptype = dr["cptype"].ToDBString();
                        //add by cym 2018-11-7
                        entityGYD.workHours = dr["workHours"].ToDecimal();
                        //add by cym 2018-11-27
                        entityGYD.MachineType = dr["MachineType"].ToDBString();
                        entityGYD.MachineName = dr["MachineName"].ToDBString();

                        entityGYD.Creater    = dr["Creater"].ToDBString();
                        entityGYD.CreateTime = dr["CreateTime"].ToDateTime();

                        entityGYD.isDel = dr["isDel"].ToInt32();

                        entityGYD.lstGY = new List <Mes_ProductGYInfo>();
                    }
                    else
                    {
                        ErrMsg = "no Mes_GYD data!";
                        return(false);
                    }
                }

                //GY
                strSql = "select t.*,cp.name from Mes_GY t inner join mes_cptype cp on t.cptype=cp.id where t.gxDuanCode='" + gxDuanCode + "'";

                List <Mes_ProductGYInfo> lst = new List <Mes_ProductGYInfo>();

                using (IDataReader dr = dbFactory.ExecuteReader(CommandType.Text, strSql))
                {
                    while (dr.Read())
                    {
                        Mes_ProductGYInfo model = new Mes_ProductGYInfo();

                        model.ID          = dr["ID"].ToInt32();
                        model.gxID        = dr["gxID"].ToDBString();
                        model.bbNo        = dr["bbNo"].ToDBString();
                        model.gxDuanCode  = dr["gxDuanCode"].ToDBString();
                        model.gxDuanName  = dr["gxDuanName"].ToDBString();
                        model.cptype      = dr["cptype"].ToDBString();
                        model.machineType = dr["machineType"].ToDBString();
                        model.gxSeq       = dr["gxSeq"].ToInt32();
                        model.gxName      = dr["gxName"].ToDBString();

                        model.isDel       = dr["isDel"].ToInt32();
                        model.description = dr["description"].ToDBString();

                        model.CompanyCode = dr["name"].ToDBString();

                        //var blob = dr.GetOracleBlob(0);
                        //byte[] bout = new byte[blob.Length];
                        //blob.Read(bout, 0, bout.Length);

                        if (!string.IsNullOrWhiteSpace(dr["imagePic"].ToString()))
                        {
                            model.imagePic = (byte[])dr["imagePic"];
                        }
                        else
                        {
                            model.imagePic = null;
                        }

                        if (!string.IsNullOrWhiteSpace(dr["imagePic2"].ToString()))
                        {
                            model.imagePic2 = (byte[])dr["imagePic2"];
                        }
                        else
                        {
                            model.imagePic2 = null;
                        }

                        if (!string.IsNullOrWhiteSpace(dr["imagePic3"].ToString()))
                        {
                            model.imagePic3 = (byte[])dr["imagePic3"];
                        }
                        else
                        {
                            model.imagePic3 = null;
                        }

                        model.videoUrl = dr["videoUrl"].ToDBString();
                        model.remark   = dr["remark"].ToDBString();

                        model.Creater    = dr["Creater"].ToDBString();
                        model.CreateTime = dr["CreateTime"].ToDateTimeNull();
                        model.Modifyer   = dr["Modifyer"].ToDBString();
                        model.ModifyTime = dr["ModifyTime"].ToDateTimeNull();

                        model.lstLimit = new List <Mes_ProductGY_LimitInfo>();

                        lst.Add(model);
                    }
                }

                if (lst.Count <= 0)
                {
                    ErrMsg = "no Mes_GY data!";
                    return(false);
                }

                //Mes_GY_Limit
                strSql = "select * from Mes_GY_Limit t where t.gxID in (select gxID from Mes_GY where gxDuanCode='" + gxDuanCode + "')";

                List <Mes_ProductGY_LimitInfo> lstLimit = new List <Mes_ProductGY_LimitInfo>();

                using (IDataReader dr = dbFactory.ExecuteReader(CommandType.Text, strSql))
                {
                    while (dr.Read())
                    {
                        Mes_ProductGY_LimitInfo model = new Mes_ProductGY_LimitInfo();

                        model.ID         = dr["ID"].ToInt32();
                        model.xzID       = dr["xzID"].ToDBString();
                        model.gyDetailID = dr["gxID"].ToDBString();
                        //model.gyLineID = dr["gyLineID"].ToDBString();
                        model.type  = dr["type"].ToDBString();
                        model.seqno = dr["seqno"].ToInt32();

                        model.xzName    = dr["xzName"].ToDBString();
                        model.xzRoleMax = dr["xzRoleMax"].ToDBString();
                        model.xzRoleMin = dr["xzRoleMin"].ToDBString();
                        model.QTY       = dr["QTY"].ToDBString();
                        model.Unit      = dr["Unit"].ToDBString();

                        lstLimit.Add(model);
                    }
                }

                if (lstLimit.Count > 0)
                {
                    lst.ForEach(delegate(Mes_ProductGYInfo entityGy)
                    {
                        var templst = lstLimit.FindAll(t => t.gyDetailID == entityGy.gxID);

                        if (templst != null && templst.Count > 0)
                        {
                            entityGy.lstLimit = templst;
                        }
                    });
                }

                entityGYD.lstGY = lst;

                return(true);
            }
            catch (Exception ex)
            {
                ErrMsg = ex.Message;
                return(false);
            }
        }