Exemple #1
0
 /// <summary>
 /// 整合追溯信息为Hashtable
 /// </summary>
 /// <returns></returns>
 private Hashtable GetHashtable()
 {
     try
     {
         string    sql   = string.Format("SELECT * FROM (SELECT t.* FROM (SELECT b.*, m.tablename, m.fieldname FROM productinfo p, productbominfo b, materialfield m WHERE p.productcode = b.productcode AND p.producttype = b.producttype AND b.materialcode = m.materialcode AND m.tablename='{0}') t LEFT JOIN batchno n ON t.materialcode = n.materialcode) t WHERE  productcode='{1}' AND producttype='{2}' AND tracetype in({3});", BaseVariable.ResultTableName, this.productModel.ProductCode, BaseVariable.DeviceEntity.ProductType, "'扫描追溯'");
         DataTable table = LocalDbDAL.GetDataTable(sql);
         if (table != null && table.Rows.Count > 0)
         {
             Hashtable HTSelect = MaterialBomDAL.GetList(table);
             Hashtable HTResult = new Hashtable();
             foreach (var item in RequestParam)
             {
                 if (HTSelect.ContainsKey(item.Key))
                 {
                     MaterialBomMDL model = HTSelect[item.Key] as MaterialBomMDL;
                     model.BatchBarCode = item.Value;
                     HTResult.Add(item.Key, model);
                 }
             }
             return(HTResult);
         }
         return(null);
     }
     catch (Exception ex)
     {
         CLog.WriteErrLog(ex.Message);
         return(null);
     }
 }
        /// <summary>
        /// 返修更新信息
        /// </summary>
        private void Update()
        {
            string sql = "";

            try
            {
                string param = context.Request.Params["param"].ToString();
                //获取到的json数据
                Dictionary <string, object> dict = JsonHelper.JsonDeSerializer <Dictionary <string, object> >(param);
                //解析获得result的Hashtable集合
                Dictionary <string, object> HTReceive = JsonHelper.JsonDeSerializer <Dictionary <string, object> >(dict["data"].ToString());

                string TableName   = dict["TableName"].ToString();   //表名
                string HJBarCode   = dict["HJBarCode"].ToString();   //合件条码
                string UserID      = dict["UserID"].ToString();      //用户ID
                string StationID   = dict["StationID"].ToString();   //工位号
                string ProductCode = dict["ProductCode"].ToString(); //产品编码
                string ProductType = dict["ProductType"].ToString(); //产品类型
                string TraceType   = "'扫描追溯','批次追溯'";
                sql = string.Format("SELECT * FROM (SELECT t.* FROM (SELECT b.*, m.tablename, m.fieldname FROM productinfo p, productbominfo b, materialfield m WHERE p.productcode = b.productcode AND p.producttype = b.producttype AND b.materialcode = m.materialcode AND m.tablename='{0}') t LEFT JOIN batchno n ON t.materialcode = n.materialcode) t WHERE  productcode='{1}' AND producttype='{2}' AND tracetype in({3});", TableName, ProductCode, ProductType, TraceType);
                DataTable table = CommonDAL.GetDataTable(sql);
                Dictionary <string, MaterialBomMDL> HTSelect = MaterialBomDAL.GetList(table);
                Hashtable HTResult = new Hashtable();
                foreach (var item in HTReceive)
                {
                    MaterialBomMDL model = HTSelect[item.Key] as MaterialBomMDL;
                    model.BatchBarCode = item.Value.ToString();
                    HTResult.Add(item.Key, model);
                }
                //获取组装的SQL语句
                sql = AssembleSqlCode(TableName, ProductType, HJBarCode, ProductCode, UserID, StationID, null, HTResult);
                //CLog.WriteErrLog(sql);
                if (!string.IsNullOrEmpty(sql))
                {
                    //执行组装的SQL语句,返回结果
                    bool flag = CommonDAL.ExecuteSql(sql, null);
                    if (flag)
                    {
                        ReturnData.Code = "1";
                        ReturnData.Msg  = "OK";
                    }
                }
            }
            catch (Exception ex)
            {
                CLog.WriteStationLog("SQLErr", sql);
                CLog.WriteErrLog(ex.Message);
            }
        }
Exemple #3
0
 /// <summary>
 /// 获取产品BOM信息
 /// </summary>
 private void Select()
 {
     try
     {
         string TableName   = context.Request.Params["TableName"].ToString();
         string ProductType = context.Request.Params["ProductType"].ToString();
         string ProductCode = context.Request.Params["ProductCode"].ToString();
         string TraceType   = context.Request.Params["TraceType"].ToString();
         if (string.IsNullOrEmpty(TraceType) || TraceType == "0")
         {
             TraceType = "'扫描追溯','批次追溯'";
         }
         else if (TraceType == "1")
         {
             TraceType = "'扫描追溯'";
         }
         else if (TraceType == "2")
         {
             TraceType = "'批次追溯'";
         }
         string    sql   = string.Format("SELECT * FROM (SELECT t.*,n.tid ext1,n.batchno ext2,n.stocknum ext3 FROM (SELECT b.*, m.tablename, m.fieldname FROM productinfo p, productbominfo b, materialfield m WHERE p.productcode = b.productcode AND p.producttype = b.producttype AND b.materialcode = m.materialcode AND m.tablename='{0}') t LEFT JOIN batchno n ON t.materialcode = n.materialcode) t WHERE  productcode='{1}' AND producttype='{2}' AND tracetype in({3});", TableName, ProductCode, ProductType, TraceType);
         DataTable table = CommonDAL.GetDataTable(sql);
         if (table != null && table.Rows.Count > 0)
         {
             //object obj = TableHelper.TableToObj(table);
             Dictionary <string, MaterialBomMDL> HTMaterialTable = MaterialBomDAL.GetList(table, 3);
             ReturnData.Code = "1";
             ReturnData.Msg  = "OK";
             ReturnData.Data = HTMaterialTable;
         }
     }
     catch (Exception ex)
     {
         CLog.WriteErrLog(ex.Message);
     }
 }