Ejemplo n.º 1
0
        public string GenerateNewLotNo(string moCode, string itemCode, int nextSeq)
        {
            string sql = string.Empty;

            sql = " SELECT NVL(MAX(LOTNO),'') AS LOTNO FROM TBLMO2LOTLINK WHERE MOCODE = '" + moCode + "'";
            object[] mo2LotLink = this.DataProvider.CustomQuery(typeof(MO2LotLink), new SQLCondition(sql));
            if (mo2LotLink != null)
            {
                ItemLotFacade itemLotFacade = new ItemLotFacade(this._domainDataProvider);
                object        item2LotCheck = itemLotFacade.GetItem2LotCheck(itemCode);
                if (item2LotCheck != null)
                {
                    NumberScale scale = NumberScale.Scale34;
                    if (((Item2LotCheck)item2LotCheck).CreateType == CreateType.CREATETYPE_DECIMAL)
                    {
                        scale = NumberScale.Scale10;
                    }
                    else if (((Item2LotCheck)item2LotCheck).CreateType == CreateType.CREATETYPE_HEXADECIMAL)
                    {
                        scale = NumberScale.Scale16;
                    }
                    else if (((Item2LotCheck)item2LotCheck).CreateType == CreateType.CREATETYPE_THIRTYFOUR)
                    {
                        scale = NumberScale.Scale34;
                    }
                    int    prefixLength = ((Item2LotCheck)item2LotCheck).SNPrefix.Length;
                    int    lotLength    = ((Item2LotCheck)item2LotCheck).SNLength;
                    long   maxLotNo     = long.Parse(NumberScaleHelper.ChangeNumber(((MO2LotLink)mo2LotLink[0]).LotNo.Substring(prefixLength), scale, NumberScale.Scale10));
                    string newLotNo     = NumberScaleHelper.ChangeNumber((maxLotNo + nextSeq).ToString(), NumberScale.Scale10, scale).PadLeft(lotLength - prefixLength, '0');
                    if (newLotNo.Length > lotLength - prefixLength)
                    {
                        return("False$CS_LotNoLength_ERROR");
                    }
                    return(((Item2LotCheck)item2LotCheck).SNPrefix + newLotNo);
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
        private static bool CheckLetter(string numberString, NumberScale scale)
        {
            string letters = string.Empty;

            switch (scale)
            {
            case NumberScale.Scale10:
                letters = _Letters10;
                break;

            case NumberScale.Scale16:
                letters = _Letters16;
                break;

            case NumberScale.Scale34:
                letters = _Letters34;
                break;

            case NumberScale.Scale36:
                letters = _Letters36;
                break;

            default:
                throw new Exception("$Error_InvalidSourceScale");
                break;
            }

            numberString = numberString.ToUpper();
            for (int i = 0; i < numberString.Length; i++)
            {
                if (letters.IndexOf(numberString.Substring(i, 1)) < 0)
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
        public static string ChangeNumber(string sourceNumberString, NumberScale sourceScale, NumberScale targetScale)
        {
            sourceNumberString = sourceNumberString.Trim().ToUpper();

            int    sourceBase    = 0;
            int    targetBase    = 0;
            string sourceLetters = string.Empty;
            string targetLetters = string.Empty;
            long   m             = 0;
            int    pos           = 0;
            string returnValue   = string.Empty;

            switch (sourceScale)
            {
            case NumberScale.Scale10:
                sourceBase    = 10;
                sourceLetters = _Letters10;
                break;

            case NumberScale.Scale16:
                sourceBase    = 16;
                sourceLetters = _Letters16;
                break;

            case NumberScale.Scale34:
                sourceBase    = 34;
                sourceLetters = _Letters34;
                break;

            case NumberScale.Scale36:
                sourceBase    = 36;
                sourceLetters = _Letters36;
                break;

            default:
                throw new Exception("$Error_InvalidSourceScale");
                break;
            }

            switch (targetScale)
            {
            case NumberScale.Scale10:
                targetBase    = 10;
                targetLetters = _Letters10;
                break;

            case NumberScale.Scale16:
                targetBase    = 16;
                targetLetters = _Letters16;
                break;

            case NumberScale.Scale34:
                targetBase    = 34;
                targetLetters = _Letters34;
                break;

            case NumberScale.Scale36:
                targetBase    = 36;
                targetLetters = _Letters36;
                break;

            default:
                throw new Exception("$Error_InvalidTargetScale");
                break;
            }

            if (sourceNumberString.Length < 1 || sourceNumberString.Length > 10)
            {
                throw new Exception("$Error_InvalidSourceNumberString");
            }

            if (!CheckLetter(sourceNumberString, sourceScale))
            {
                throw new Exception("$Error_InvalidSourceNumberString");
            }

            for (int i = 0; i < sourceNumberString.Length; i++)
            {
                m = m * sourceBase + sourceLetters.IndexOf(sourceNumberString[i]);
            }

            while (m >= targetBase)
            {
                pos         = (int)(m % targetBase);
                returnValue = targetLetters.Substring(pos, 1) + returnValue;
                m           = m / targetBase;
            }
            pos         = (int)m;
            returnValue = targetLetters.Substring(pos, 1) + returnValue;
            return(returnValue);
        }
Ejemplo n.º 4
0
 public void SetMetricMode()
 {
     CurrentNumberScale = NumberScale.Metric;
     Multiplier         = 1.0;
 }
Ejemplo n.º 5
0
 public void SetImperialMode()
 {
     CurrentNumberScale = NumberScale.Imperial;
     Multiplier         = 25.4;
 }
Ejemplo n.º 6
0
        public void ProcessRequest(HttpContext context)
        {
            string itemCodeValue    = context.Request.QueryString["itemCodeValue"].Trim().ToUpper();
            string snPrefix         = context.Request.QueryString["snPrefix"].Trim().ToUpper();
            string StartSnCodeValue = context.Request.QueryString["StartSnCodeValue"].Trim().ToUpper();
            string actionType       = context.Request.QueryString["Action"].Trim().ToUpper();
            string EndSnValue       = context.Request.QueryString["EndSnValue"].Trim().ToUpper();
            string SnSeqValue       = context.Request.QueryString["SnSeqValue"].Trim().ToUpper();
            string CheckedValue     = context.Request.QueryString["CheckedValue"].Trim().ToUpper();

            try
            {
                _facade = new MaterialFacade(this.DataProvider);
                string returnValue = "false";
                string _scale      = string.Empty;

                NumberScale scale = NumberScale.Scale34;
                _scale = "34";

                if (CheckedValue == "10")
                {
                    scale  = NumberScale.Scale10;
                    _scale = "10";
                }
                else if (CheckedValue == "16")
                {
                    scale  = NumberScale.Scale16;
                    _scale = "16";
                }
                else if (CheckedValue == "34")
                {
                    scale  = NumberScale.Scale34;
                    _scale = "34";
                }
                else
                {
                    scale  = NumberScale.Scale34;
                    _scale = "34";
                }


                int length = StartSnCodeValue.Trim().Length;

                if (StartSnCodeValue.Trim() != "" && EndSnValue.Trim() != "")
                {
                    long startSN = 0;
                    try
                    {
                        startSN = long.Parse(NumberScaleHelper.ChangeNumber(StartSnCodeValue.Trim(), scale, NumberScale.Scale10));
                    }
                    catch (Exception ex)
                    {
                        //throw ex;
                        //txtMORCardStartEdit.Focus();
                        returnValue = "false";
                    }

                    long endSN = 0;
                    try
                    {
                        endSN = long.Parse(NumberScaleHelper.ChangeNumber(EndSnValue.Trim(), scale, NumberScale.Scale10));
                    }
                    catch (Exception ex)
                    {
                        returnValue = "false";
                    }

                    if ((startSN.ToString().Length + snPrefix.Trim().Length) > 40)
                    {
                        returnValue = "false";
                    }

                    if (startSN > endSN)
                    {
                        returnValue = "false";
                    }

                    bool needUpdateDetail = true;

                    if (actionType == "UPDATE")
                    {
                        MKeyPart oldMKeyPart = (MKeyPart)_facade.GetMKeyPart(Convert.ToDecimal(SnSeqValue), itemCodeValue);

                        if (oldMKeyPart != null &&
                            oldMKeyPart.RCardPrefix.Trim().ToUpper() == snPrefix.Trim().ToUpper() &&
                            oldMKeyPart.RunningCardStart.Trim().ToUpper() == StartSnCodeValue.Trim().ToUpper() &&
                            oldMKeyPart.RunningCardEnd.Trim().ToUpper() == EndSnValue.Trim().ToUpper() &&
                            oldMKeyPart.SNScale.Trim().ToUpper() == _scale)
                        {
                            needUpdateDetail = false;
                        }
                    }

                    //if (actionType == "ADD")
                    //{
                    //检查需要插入的detail数据量是否太多

                    if (needUpdateDetail)
                    {
                        if (endSN - startSN > 4999)
                        {
                            returnValue = "true";
                        }
                        else
                        {
                            returnValue = "false";
                        }
                    }
                    else
                    {
                        returnValue = "false";
                    }


                    //}

                    //if (actionType == "UPDATE")
                    //{
                    //    long count = endSN - startSN + 1;  //当前界面上算出来的数量

                    //    try
                    //    {

                    //        long checkCount = _facade.CheckMKeyPartDetail(SnSeqValue, itemCodeValue, StartSnCodeValue, EndSnValue, snPrefix.Trim().ToUpper());


                    //        if (checkCount == 0)
                    //        {
                    //            if (endSN - startSN > 4999)
                    //            {
                    //                returnValue = "true";
                    //            }
                    //            else
                    //            {
                    //                returnValue = "false";
                    //            }


                    //        }
                    //        else
                    //        {

                    //            if (count - checkCount < 0 || count - checkCount == 0) //会删掉数据库的序列号,所以速度比较快。
                    //            {
                    //                returnValue = "false";

                    //            }
                    //            else
                    //            {
                    //                if (count - checkCount > 4999)  //为4999 //会insert into 序列号到数据库,所以要判断inset into的数量是否大于4999
                    //                {
                    //                    returnValue = "true";

                    //                }
                    //                else
                    //                {
                    //                    returnValue = "false";

                    //                }
                    //            }
                    //        }
                    //    }
                    //    catch (Exception ex)
                    //    {
                    //        returnValue = "false";

                    //    }


                    //}
                }
                else
                {
                    returnValue = "false";
                }

                context.Response.Write(returnValue);
            }
            catch (Exception ex)
            {
                context.Response.Write(ex.Message);
            }
        }