public static void SetNavyRunningNumber(string number, Label lbBatt, Label lbCom, Label lbPlt, Label lbPseq) { NavyRunNumber num = Function.GenRunningNumber(Convert.ToInt16(number)); lbBatt.Text = num.batt; lbCom.Text = num.company; lbPlt.Text = num.platoon; lbPseq.Text = num.pseq; }
public static NavyRunNumber GenRunningNumber(int number) { NavyRunNumber result = new NavyRunNumber(); int batt = 0; int com = 0; int pltn = 0; int seq = 0; try { batt = (int)(Math.Floor(((float)(number % 24) / 6.0) + 0.90)); batt = batt == 0 ? 4 : batt; com = ((number % 24) % 6); com = com == 0 ? 6 : com; pltn = number % (4 * 6 * 3); pltn = pltn == 0 ? (4 * 6 * 3) : pltn; pltn = ((pltn - 1) / (4 * 6)) + 1; seq = ((number - 1) / (4 * 6 * 3)) + 1; } catch (DivideByZeroException) { batt = 0; com = 0; pltn = 0; seq = 0; } catch (OverflowException) { batt = -1; com = -1; pltn = -1; seq = -1; } result.batt = batt.ToString(); result.company = com.ToString(); result.platoon = pltn.ToString(); result.pseq = seq.ToString(); return(result); }
public static string GetNavyRunningNumber(NavyRunNumber result) { return(result.batt + result.company + result.platoon + result.pseq); }