Пример #1
0
 /// <summary>
 /// 获取当前产品的记录条数
 /// </summary>
 /// <returns></returns>
 public static int GetMarterialCount()
 {
     try
     {
         string sql   = string.Format("SELECT COUNT(tid) FROM '{0}';", BaseVariable.ResultTableName);
         int    count = LocalDbDAL.ExecuteScaler(sql) == null && LocalDbDAL.ExecuteScaler(sql).ToString() == "0" ? (int)LocalDbDAL.ExecuteScaler(sql) : 0;
         return(count);
     }
     catch (Exception ex)
     {
         CLog.WriteErrLog(ex.Message);
         return(0);
     }
 }
Пример #2
0
        /// <summary>
        /// 组装SQL语句
        /// </summary>
        /// <param name="IsExit"></param>
        /// <param name="tid"></param>
        /// <returns></returns>
        private string AssembleSqlCode(Hashtable ParamHTList)
        {
            //查询合件是否存在
            object obj = LocalDbDAL.ExecuteScaler(string.Format("SELECT tid FROM {0} WHERE barcode ='{1}';", BaseVariable.ResultTableName, this.lblHJCode.Text));
            long   TID = obj != null && obj.ToString() != "0" ? long.Parse(obj.ToString()) : 0;
            string sql = "";

            if (TID != 0)
            {
                sql += string.Format("update {0} set ", BaseVariable.ResultTableName);
                #region 对应更新字段
                if (ParamHTList != null && ParamHTList.Count > 0)
                {
                    foreach (DictionaryEntry Entry in ParamHTList)
                    {
                        MaterialBomMDL model = Entry.Value as MaterialBomMDL;
                        if (!string.IsNullOrEmpty(model.BatchBarCode))
                        {
                            sql += string.Format("{0}='{1}',", model.FieldName, model.BatchBarCode);
                        }
                    }
                }
                #endregion
                sql += string.Format("userid='{0}',stationid='{1}',scantype='{2}'", BaseVariable.UserEntity.UserID, BaseVariable.DeviceEntity.StationID, CurrnetScanType);
                sql += string.Format(" where tid={0}", TID);
            }
            else
            {
                string field  = "";
                string values = "";
                #region 对应更新字段
                if (ParamHTList != null && ParamHTList.Count > 0)
                {
                    foreach (DictionaryEntry Entry in ParamHTList)
                    {
                        MaterialBomMDL model = Entry.Value as MaterialBomMDL;
                        if (!string.IsNullOrEmpty(model.BatchBarCode))
                        {
                            field  += model.FieldName + ",";
                            values += string.Format("'{0}',", model.BatchBarCode);
                        }
                    }
                }
                #endregion
                field  += "barcode,productcode,userid,stationid,scantype";
                values += string.Format("'{0}','{1}','{2}','{3}','{4}'", this.lblHJCode.Text, this.productModel.ProductCode, BaseVariable.UserEntity.UserID, BaseVariable.DeviceEntity.StationID, CurrnetScanType);
                sql    += string.Format("insert into {0}({1}) values({2});", BaseVariable.ResultTableName, field, values);
            }
            return(sql);
        }
Пример #3
0
 /// <summary>
 /// 获取批次的记录条数
 /// </summary>
 /// <returns></returns>
 public static int GetBatchCount()
 {
     try
     {
         string sql   = "SELECT COUNT(tid) FROM BatchNo;";
         int    count = LocalDbDAL.ExecuteScaler(sql) == null && LocalDbDAL.ExecuteScaler(sql).ToString() == "0" ? (int)LocalDbDAL.ExecuteScaler(sql) : 0;
         return(count);
     }
     catch (Exception ex)
     {
         CLog.WriteErrLog(ex.Message);
         return(0);
     }
 }
Пример #4
0
        /// <summary>
        /// 获取当前条码是否存在
        /// 1.合件号;2.零件号(是一一追溯的零件)
        /// </summary>
        /// <param name="type">1:合件,2:零件</param>
        /// <param name="barcode">要验证的条码</param>
        /// <param name="materialfiled">字段名</param>
        public bool ValidateScanIsExist(int Type, string BarCode, string Filed)
        {
            Stopwatch existWatch = new Stopwatch();

            try
            {
                /*
                 * 人物:xudy
                 * 时间:2015-01-18
                 * 内容:修改了条件,讲userid、barcode换为tid
                 */
                if (Opt.GlobalNetStatus())//从服务器获取数据
                {
                    existWatch.Start();
                    //string requestUrl = BaseVariable.RequestURL + "Result.ashx";
                    //Dictionary<string, object> dict = new Dictionary<string, object>();
                    //dict.Add("do", "validate");
                    //dict.Add("Type", Type);
                    //dict.Add("TableName", BaseVariable.ResultTableName);
                    //dict.Add("BarCode", BarCode);
                    //dict.Add("ProductCode", this.productModel.ProductCode);
                    //dict.Add("Filed", Filed);

                    //string str = Http.POST(requestUrl, dict);
                    //var obj = JsonHelper.JsonDeSerializer<ReturnInfo>(str);
                    //ReturnInfo ReturnData = (ReturnInfo)obj;
                    //if (ReturnData != null && ReturnData.Code == "1")
                    //{
                    //    return true;
                    //}

                    return(ResultDAL.Validate(BaseVariable.ResultTableName, BarCode, this.productModel.ProductCode, Type, Filed));
                }
                else//从本地获取数据
                {
                    string sql = "";
                    switch (Type)
                    {
                    case 1:    //合件
                        sql = string.Format("select tid from {0} where barcode='{1}' and productcode='{2}'", BaseVariable.ResultTableName, BarCode, this.productModel.ProductCode);
                        break;

                    case 2:    //子件
                        sql = string.Format("select tid from {0} where {2}='{1}'", BaseVariable.ResultTableName, BarCode, Filed);
                        break;
                    }
                    object obj = LocalDbDAL.ExecuteScaler(sql);
                    if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
                    {
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                CLog.WriteErrLog(ex.Message);
                return(false);
            }
            finally
            {
                LogType ty = LogType.Y1;
                switch (Type)
                {
                case 1:        //合件
                    ty = LogType.Y1;
                    break;

                case 2:        //子件
                    ty = LogType.Y2;
                    break;
                }
                this.WirteTimeSpanLog(new TimeSpan(0, 0, 0, 0, (int)existWatch.ElapsedMilliseconds), ty);
                existWatch.Stop();
            }
        }