Exemplo n.º 1
0
        private string MaTuTang()
        {
            string             s     = "";
            DateTime           time  = DateTime.Now;
            string             ngay  = time.ToString("dd");
            string             thang = time.ToString("MM");
            string             nam   = time.ToString("yy");
            string             date  = ngay + thang + nam;
            List <NhanVienDTO> ds    = myNhanVienBUL.LayThongTinNhanVien();

            if (ds.Count <= 0)
            {
                s = "NV_" + date + "_001";
            }
            else
            {
                string newstt   = "";
                int    k        = ds.Count;
                int    stt      = Convert.ToInt32(ds[k - 1].MaNhanVien.ToString().Substring(10, 3));
                string checkday = ds[k - 1].MaNhanVien.ToString().Substring(3, 6);
                if (date == checkday)
                {
                    int tempstt = stt + 1;
                    if (tempstt <= 9)
                    {
                        newstt = "00" + tempstt.ToString();
                    }
                    if (tempstt >= 10 && tempstt < 100)
                    {
                        newstt = "0" + tempstt.ToString();
                    }
                    if (tempstt == 100)
                    {
                        newstt = "100";
                    }
                    s = "NV_" + date + "_" + newstt;
                }
                else
                {
                    s = "NV_" + date + "_001";
                }
            }
            return(s);
        }