コード例 #1
0
        //Lấy Contract ID tự động
        public string loadIDContract()
        {
            string    Texti      = null;
            DataTable dtcontract = new DataTable();
            CONTRACTs contract   = new CONTRACTs();

            Layer.MEMBERs mem = new MEMBERs();
            dtcontract = contract.getCONTRACTS();
            int countRowContract = dtcontract.Rows.Count;
            int i = 1;
            int j = 0;

            if (countRowContract < 10)
            {
                while (i <= countRowContract && j < countRowContract)
                {
                    Texti  = "CONT0";
                    Texti += i;
                    if (Texti == dtcontract.Rows[j][0].ToString())
                    {
                        j++;
                        i++;
                    }
                    else
                    {
                        return(Texti);
                    }
                }
                if (i > countRowContract)
                {
                    Texti  = "CONT0";
                    Texti += i;
                }
                return(Texti);
            }
            else
            {
                i = 10;
                j = 9;
                while (i <= dtcontract.Rows.Count && j < dtcontract.Rows.Count)
                {
                    Texti  = "CONT";
                    Texti += i;
                    if (Texti == dtcontract.Rows[j][0].ToString())
                    {
                        j++;
                        i++;
                    }
                    else
                    {
                        return(Texti);
                    }
                }
                if (i > countRowContract)
                {
                    Texti  = "CONT";
                    Texti += i;
                }
                return(Texti);
            }
        }