Exemplo n.º 1
0
        private LabelData ExplainXMLToLabelData(string xmlString)
        {
            LabelData rlt = null;

            XmlDocument xml = new XmlDocument();

            try
            {
                xml.LoadXml(xmlString);

                foreach (XmlNode node in xml.SelectNodes("Root/Action"))
                {
                    if (node.Attributes["Action"].Value == "PDASocketPrint")
                    {
                        rlt = new LabelData();

                        rlt.LabelFMTString = node.Attributes["Data"].Value;
                        string[] strings = rlt.LabelFMTString.Split('\n');

                        rlt.SKUID    = strings[10].Substring(20, 18);
                        rlt.Quantity = strings[14].Substring(31, 10);

                        int length = strings[11].Length;
                        int pos    = strings[11].IndexOf(":") + 1;
                        rlt.MaterialCode =
                            strings[11].Substring(
                                pos,
                                length - pos);

                        length          = strings[20].Length;
                        pos             = strings[20].IndexOf(":") + 1;
                        rlt.InLotNumber =
                            strings[20].Substring(
                                pos,
                                length - pos);

                        length          = strings[16].Length;
                        pos             = strings[16].IndexOf(":") + 1;
                        rlt.StoreSiteNo =
                            strings[16].Substring(
                                pos,
                                length - pos);

                        break;
                    }
                }
            }
            catch (Exception error)
            {
                return(null);
            }

            return(rlt);
        }
Exemplo n.º 2
0
        private List <LabelData> GetLabelFMTStrings(string filter)
        {
            List <LabelData> rlts = new List <LabelData>();

            string dbConnectionStr = GetDBConnectionString();

            SqlConnection conn = new SqlConnection(dbConnectionStr);

            try
            {
                conn.Open();
            }
            catch (Exception error)
            {
                XtraMessageBox.Show(
                    error.Message,
                    Text,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return(rlts);
            }

            string cmdStr =
                "SELECT '<Root><Action Ordinal=\"\" Action=\"PDASocketPrint\" " +
                "PrintToAddress=\"\" PrintToPort=\"\" Data = \"'" +
                "+ REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(" +
                "REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE" +
                "(TemplateFMTStr, '%1!', S.SKUID), '%2!', L101.Code), '%3!', S.LotNumber)" +
                ", '%4!', Convert(varchar(10), S.MFGDate, 120)), '%5!'" +
                ", SubString(IRAPMDM.dbo.ufn_GetStr_QuantityWithUM(S.QtyInStore, 6, 'KG'), " +
                "1, Len(IRAPMDM.dbo.ufn_GetStr_QuantityWithUM(S.QtyInStore, 6, 'KG')) - 5))" +
                ", '%6!', ''), '%7!', Stuff(L106.AlternateCode, 1, 2, '')), '%8!', L104.Code)" +
                ", '%9!', ''), '%10!', Convert(varchar(10), DateAdd(day, 1, S.ShelfLifeEndDate), " +
                "120)), '%11!', 'KG')" +
                ", '%12!', ''), '%13!', 'YES'), '%14!', ''), '%15!', S.RecvBatchNo)" +
                "+ '\" /></Root>' FROM IRAPMDM..GenAttr_Label G117" +
                ", IRAPRIMCS..utb_MaterialStore S, IRAPMDM..stb058 L106, IRAPMDM..stb058 L101" +
                ", IRAPMDM..stb058 L104 " +
                "WHERE G117.PartitioningKey = 600100117 AND G117.EntityID = 1031099 " +
                "AND S.PartitioningKey = 600100000 AND S.Leaf02 = 5333465 " + //AND S.ASNTransactNo = 0 " +
                "AND L106.PartitioningKey = 600100106 AND L106.LeafID = S.Leaf03 " +
                "AND L101.PartitioningKey = 600100101 AND L101.LeafID = S.Leaf01 " +
                "AND L104.PartitioningKey = 600100104 AND L104.LeafID = S.Leaf05 ";
            SqlCommand sqlCmd = new SqlCommand(cmdStr, conn)
            {
                CommandType    = CommandType.Text,
                CommandTimeout = 60 * 1000 * 5,
            };
            SqlDataAdapter sda      = new SqlDataAdapter(sqlCmd);
            DataSet        dsLabels = new DataSet();

            sda.Fill(dsLabels);

            if (dsLabels.Tables.Count > 0)
            {
                DataTable dt = dsLabels.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    if (dr[0].ToString().ToUpper().IndexOf("<ROOT>") >= 0)
                    {
                        LabelData data = ExplainXMLToLabelData(dr[0].ToString());
                        if (data != null)
                        {
                            if (filter == "")
                            {
                                rlts.Add(data);
                            }
                            else
                            if (data.StoreSiteNo.IndexOf(filter) == 0)
                            {
                                rlts.Add(data);
                            }
                        }
                    }
                }
            }

            return(rlts);
        }