コード例 #1
0
        private void taoMaHoaDon(string ban)
        {
            DataTable dt = new DataTable();

            dt = bd.laybangHoaDon(ban);
            if (dt.Rows.Count <= 0)
            {
                mahd = "001";
            }
            else
            {
                int i = dt.Rows.Count;
                //mahd = (Convert.ToInt16(dt.Rows[i - 1]["MaHD"])+1).ToString();
                i = Convert.ToInt16(dt.Rows[i - 1]["MaHD"].ToString().Substring(3, 3)) + 1;
                //mahd = (Convert.ToInt16(mahd) + 1).ToString();
                if (i < 10)
                {
                    mahd = "00";
                }
                else
                if (i < 100)
                {
                    mahd = "0";
                }
                else
                {
                    mahd = "";
                }
                mahd = mahd + i.ToString();
            }
            mahd          = ban + mahd;
            lbl_MaHD.Text = "Mã HD: " + mahd;
        }