Example #1
0
 /// <summary>
 /// Create a new tsysbillcode object.
 /// </summary>
 /// <param name="bcrid">Initial value of the bcrid property.</param>
 /// <param name="basevalue">Initial value of the basevalue property.</param>
 /// <param name="timevalue">Initial value of the timevalue property.</param>
 /// <param name="currentseqvalue">Initial value of the currentseqvalue property.</param>
 /// <param name="lastmodifieduser">Initial value of the lastmodifieduser property.</param>
 /// <param name="lastmodifiedtime">Initial value of the lastmodifiedtime property.</param>
 public static tsysbillcode Createtsysbillcode(global::System.String bcrid, global::System.String basevalue, global::System.String timevalue, global::System.Decimal currentseqvalue, global::System.String lastmodifieduser, global::System.DateTime lastmodifiedtime)
 {
     tsysbillcode tsysbillcode = new tsysbillcode();
     tsysbillcode.bcrid = bcrid;
     tsysbillcode.basevalue = basevalue;
     tsysbillcode.timevalue = timevalue;
     tsysbillcode.currentseqvalue = currentseqvalue;
     tsysbillcode.lastmodifieduser = lastmodifieduser;
     tsysbillcode.lastmodifiedtime = lastmodifiedtime;
     return tsysbillcode;
 }
Example #2
0
 public void DoInsertBillCode(ContextInfo contextInfo, tsysbillcode billCode)
 {
     contextInfo.Action = MES_ActionType.Insert;
     BillCodeBll bll = new BillCodeBll(contextInfo);
     bll.CallAccessControl();
     bll.DoInsert(billCode);
     GC.Collect();
 }
Example #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the tsysbillcode EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTotsysbillcode(tsysbillcode tsysbillcode)
 {
     base.AddObject("tsysbillcode", tsysbillcode);
 }
Example #4
0
        public List<string> SubGetBillNoBatch(string bcrid, int batchNum, string lockRefId,
            string baseValue, List<MESParameterInfo> lstVariablesParameters)
        {
            #region prepare
            List<string> lstBillNo = new List<string>();

            if (bcrid.Trim() == string.Empty)
            {
                return lstBillNo;
            }

            decimal prevseqvalue = 0;
            #endregion

            try
            {
                //get system config
                string sysConfig = new SystemConfigBll(CurrentContextInfo).GetSystemConfigValue("SYS_CONTBILLNO");

                #region get objects
                List<MESParameterInfo> lstParameters = new List<MESParameterInfo>();
                lstParameters.Add(new MESParameterInfo()
                {
                    ParamName = "bcrid",
                    ParamValue = bcrid,
                    ParamType = "string"
                });

                //get rule object
                tsysbillcoderule rule = GetSingleObject<tsysbillcoderule>(lstParameters);

                if (rule == null) return lstBillNo;

                //get time format
                string timeformat = rule.timeformat;
                if (timeformat == null || timeformat.Trim() == string.Empty)
                    timeformat = "yyyyMMdd";//default

                string currentTimeValue = Function.GetCurrentTime().ToString(timeformat);

                currentTimeValue = ConvertSpecialTimeFormat(currentTimeValue, timeformat);

                if (rule.basevalue == MES_BillCodeRule_BCRBaseValue.TimeFormat.ToString())
                {
                    lstParameters.Add(new MESParameterInfo()
                    {
                        ParamName = "basevalue",
                        ParamValue = currentTimeValue,
                        ParamType = "string"
                    });
                }
                else if(rule.basevalue == MES_BillCodeRule_BCRBaseValue.Parameter.ToString())
                {
                    lstParameters.Add(new MESParameterInfo()
                    {
                        ParamName = "basevalue",
                        ParamValue = baseValue,
                        ParamType = "string"
                    });
                }
                else
                {
                    lstParameters.Add(new MESParameterInfo()
                    {
                        ParamName = "basevalue",
                        ParamValue = baseValue,
                        ParamType = "string"
                    });

                    lstParameters.Add(new MESParameterInfo()
                    {
                        ParamName = "timevalue",
                        ParamValue = currentTimeValue,
                        ParamType = "string"
                    });
                }

                //get bill code object
                tsysbillcode billCode = localDal.GetSingleObject<tsysbillcode>(lstParameters, string.Empty, false);
                #endregion

                if (billCode != null)
                {
                    #region if exists,update

                    if (sysConfig == MES_Misc.Y.ToString())
                    {
                        //check lock flag first
                        if (billCode.islocked == MES_Misc.Y.ToString())
                        {
                            if (billCode.lockrefid != null && billCode.lockrefid == lockRefId)
                            {
                            }
                            else
                            {
                                throw new UtilException("-200015");
                            }
                        }
                    }

                    prevseqvalue = billCode.currentseqvalue;

                    for (int i = 0; i < batchNum; i++)
                    {
                        #region check max & min value & iscycle
                        if (billCode.currentseqvalue < rule.maxvalue && billCode.currentseqvalue >= rule.minvalue)
                        {
                            billCode.currentseqvalue = billCode.currentseqvalue + (rule.incrementby == null ? 1 : (rule.incrementby <= 0 ? 1 : rule.incrementby));
                            billCode.lastmodifiedtime = Function.GetCurrentTime();
                            billCode.lastmodifieduser = CurrentContextInfo.CurrentUser;
                            
                            if (rule.billformat==null || rule.billformat.Trim()==string.Empty)
                            {
                                billCode.fullbillnotext = rule.ffchars + currentTimeValue + billCode.currentseqvalue.ToString().PadLeft(Int16.Parse(rule.seqvaluelength.ToString()), '0');
                            }
                            else
                            {
                                billCode.fullbillnotext = ParseVariables(rule, currentTimeValue,
                                    billCode.currentseqvalue.ToString().PadLeft(Int16.Parse(rule.seqvaluelength.ToString()), '0'),
                                    lstVariablesParameters);
                            }
                        }
                        else
                        {
                            if (rule.iscycle == MES_Misc.Y.ToString())
                            {
                                //reset
                                billCode.currentseqvalue = rule.startwith.HasValue ? 1 : (rule.startwith.Value < 0 ? 1 : rule.startwith.Value);
                                billCode.lastmodifiedtime = Function.GetCurrentTime();
                                billCode.lastmodifieduser = CurrentContextInfo.CurrentUser;
                                //billCode.fullbillnotext = rule.ffchars + currentTimeValue + billCode.currentseqvalue.ToString().PadLeft(Int16.Parse(rule.seqvaluelength.ToString()), '0');

                                if (rule.billformat == null || rule.billformat.Trim() == string.Empty)
                                {
                                    billCode.fullbillnotext = rule.ffchars + currentTimeValue + billCode.currentseqvalue.ToString().PadLeft(Int16.Parse(rule.seqvaluelength.ToString()), '0');
                                }
                                else
                                {
                                    billCode.fullbillnotext = ParseVariables(rule, currentTimeValue,
                                        billCode.currentseqvalue.ToString().PadLeft(Int16.Parse(rule.seqvaluelength.ToString()), '0'),
                                        lstVariablesParameters);
                                }
                            }
                            else
                            {
                                //error
                                //billCode.fullbillnotext = "-1";
                                throw new Exception("-200028");
                            }
                        }
                        #endregion

                        lstBillNo.Add(billCode.fullbillnotext);
                    }

                    if (sysConfig == MES_Misc.Y.ToString() && lockRefId!=string.Empty)
                    {
                        billCode.islocked = MES_Misc.Y.ToString();
                    }

                    billCode.lockrefid = lockRefId;
                    billCode.prevseqvalue = prevseqvalue;

                    localDal.DoUpdate<tsysbillcode>(billCode);
                    #endregion
                }
                else
                {
                    if (rule.basevalue == MES_BillCodeRule_BCRBaseValue.TimeFormat.ToString())
                    {
                        //close the last one first
                        ClosePrevBill(bcrid);
                    }

                    #region if new, insert
                    billCode = new tsysbillcode();
                    billCode.bcrid = bcrid;

                    prevseqvalue = billCode.currentseqvalue;

                    for (int i = 0; i < batchNum; i++)
                    {
                        if (rule.basevalue == MES_BillCodeRule_BCRBaseValue.TimeFormat.ToString())
                        {
                            billCode.basevalue = currentTimeValue;
                        }
                        else
                        {
                            billCode.basevalue = baseValue;
                        }
                        billCode.timevalue = currentTimeValue;
                        if (i == 0)
                        {
                            //first one
                            billCode.currentseqvalue = rule.startwith.HasValue ? 1 : (rule.startwith.Value < 0 ? 1 : rule.startwith.Value);
                        }
                        else
                        {
                            #region check max & min value & iscycle
                            if (billCode.currentseqvalue < rule.maxvalue && billCode.currentseqvalue >= rule.minvalue)
                            {
                                billCode.currentseqvalue = billCode.currentseqvalue + (rule.incrementby == null ? 1 : (rule.incrementby <= 0 ? 1 : rule.incrementby));
                                billCode.lastmodifiedtime = Function.GetCurrentTime();
                                billCode.lastmodifieduser = CurrentContextInfo.CurrentUser;
                                //billCode.fullbillnotext = rule.ffchars + currentTimeValue + billCode.currentseqvalue.ToString().PadLeft(Int16.Parse(rule.seqvaluelength.ToString()), '0');

                                if (rule.billformat == null || rule.billformat.Trim() == string.Empty)
                                {
                                    billCode.fullbillnotext = rule.ffchars + currentTimeValue + billCode.currentseqvalue.ToString().PadLeft(Int16.Parse(rule.seqvaluelength.ToString()), '0');
                                }
                                else
                                {
                                    billCode.fullbillnotext = ParseVariables(rule, currentTimeValue,
                                        billCode.currentseqvalue.ToString().PadLeft(Int16.Parse(rule.seqvaluelength.ToString()), '0'),
                                        lstVariablesParameters);
                                }
                            }
                            else
                            {
                                if (rule.iscycle == MES_Misc.Y.ToString())
                                {
                                    //reset
                                    billCode.currentseqvalue = rule.startwith.HasValue ? 1 : (rule.startwith.Value < 0 ? 1 : rule.startwith.Value);
                                    billCode.lastmodifiedtime = Function.GetCurrentTime();
                                    billCode.lastmodifieduser = CurrentContextInfo.CurrentUser;
                                    //billCode.fullbillnotext = rule.ffchars + currentTimeValue + billCode.currentseqvalue.ToString().PadLeft(Int16.Parse(rule.seqvaluelength.ToString()), '0');

                                    if (rule.billformat == null || rule.billformat.Trim() == string.Empty)
                                    {
                                        billCode.fullbillnotext = rule.ffchars + currentTimeValue + billCode.currentseqvalue.ToString().PadLeft(Int16.Parse(rule.seqvaluelength.ToString()), '0');
                                    }
                                    else
                                    {
                                        billCode.fullbillnotext = ParseVariables(rule, currentTimeValue,
                                            billCode.currentseqvalue.ToString().PadLeft(Int16.Parse(rule.seqvaluelength.ToString()), '0'),
                                            lstVariablesParameters);
                                    }
                                }
                                else
                                {
                                    //error
                                    //billCode.fullbillnotext = "-1";
                                    throw new Exception("-200028");
                                }
                            }
                            #endregion
                        }

                        billCode.lastmodifiedtime = Function.GetCurrentTime();
                        billCode.lastmodifieduser = CurrentContextInfo.CurrentUser;
                        //billCode.fullbillnotext = rule.ffchars + currentTimeValue + billCode.currentseqvalue.ToString().PadLeft(Int16.Parse(rule.seqvaluelength.ToString()), '0');

                        if (rule.billformat == null || rule.billformat.Trim() == string.Empty)
                        {
                            billCode.fullbillnotext = rule.ffchars + currentTimeValue + billCode.currentseqvalue.ToString().PadLeft(Int16.Parse(rule.seqvaluelength.ToString()), '0');
                        }
                        else
                        {
                            billCode.fullbillnotext = ParseVariables(rule, currentTimeValue,
                                billCode.currentseqvalue.ToString().PadLeft(Int16.Parse(rule.seqvaluelength.ToString()), '0'),
                                lstVariablesParameters);
                        }

                        lstBillNo.Add(billCode.fullbillnotext);
                    }

                    billCode.prevseqvalue = prevseqvalue;
                    if (sysConfig == MES_Misc.Y.ToString() && lockRefId != string.Empty)
                    {
                        billCode.islocked = MES_Misc.Y.ToString();
                        billCode.isclosed = MES_Misc.N.ToString();
                    }

                    billCode.lockrefid = lockRefId;
                    
                    localDal.DoInsert<tsysbillcode>(billCode);
                    #endregion
                }

                #region update rule's status
                if (rule.bcrstatus == MES_BillCodeRule_BCRStatus.Unused.ToString())
                {
                    //update rule status to used
                    rule.bcrstatus = MES_BillCodeRule_BCRStatus.Used.ToString();
                    rule.lastmodifiedtime = Function.GetCurrentTime();
                    rule.lastmodifieduser = CurrentContextInfo.CurrentUser;

                    localDal.DoUpdate<tsysbillcoderule>(rule);
                }
                #endregion

            }
            catch (Exception ex)
            {
                throw ex;
            }

            return lstBillNo;
        }