Пример #1
0
        public static string GenDelID(TextBox txtDeliveryNo)
        {
            int    iicount = 0;
            string ID      = "";

            db = new db_MiletecDataContext();
            var query = db.sp_GetDeliveryID();

            foreach (sp_GetDeliveryIDResult count in query)
            {
                iicount = count.Count.Value;
                iicount = iicount++;
            }
            ++iicount;
            if (iicount.ToString().Length.Equals(1))
            {
                ID = "DeliveryID-" + iicount.ToString().PadLeft(4, '0').ToString();
            }
            else if (iicount.ToString().Length.Equals(2))
            {
                ID = "DeliveryID-" + iicount.ToString().PadLeft(3, '0').ToString();
            }
            else
            {
                ID = "DeliveryID-" + iicount.ToString().PadLeft(2, '0').ToString();
            }

            return(txtDeliveryNo.Text = ID);
        }