Exemplo n.º 1
0
        private void LoadStudentData()
        {
            using (StudentRepo rep = new StudentRepo())
            {
                students = rep.GetAll();
            }
            using (CardRepo rep = new CardRepo())
            {
                cards = rep.GetAll();
            }

            cboStudent.DisplayMember = "FullName";
            cboStudent.ValueMember   = "StudentId";
            cboStudent.DataSource    = students;
            student.FullName         = ((Student)cboStudent.SelectedItem).FullName;
            student.Gender           = ((Student)cboStudent.SelectedItem).Gender;
            student.StudentId        = (int)cboStudent.SelectedValue;
            //
            txtIssue.ReadOnly  = true;
            txtIssue.Text      = DateTime.Now.ToShortDateString();
            txtExpire.ReadOnly = true;
            txtExpire.Text     = DateTime.Now.AddYears(1).ToShortDateString();
            string code;

            if (cards.Count == 0)
            {
                code = "0";
            }
            else
            {
                code = cards.Last().CardNum.Substring(4);
            }
            txtCardNum.Text = "LIB-" + (int.Parse(code) + 1).ToString();
        }
Exemplo n.º 2
0
        private void btnIssue_Click(object sender, EventArgs e)
        {
            Card card = new Card();

            using (StudentRepo rep = new StudentRepo())
            {
                student.HasCard = true;
                rep.Update(student);
            }
            student.FullName = cboStudent.SelectedItem.ToString();
            card.CardNum     = txtCardNum.Text;
            card.IssueDate   = DateTime.Parse(txtIssue.Text);
            card.ExpireDate  = DateTime.Parse(txtExpire.Text);
            card.StudentId   = (int)cboStudent.SelectedValue;
            using (CardRepo rep = new CardRepo())
            {
                rep.Add(card);
            }
            student.HasCard = true;
            using (StudentRepo rep = new StudentRepo())
            {
                rep.Update(student);
            }
            MessageBox.Show("Card Added Successfully!");
            LoadStudentData();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            var rep     = new CardRepo();
            var cardBll = new CardBLL(rep);

            cardBll.PrintAllCards();
            var card = cardBll.GetCardById(1);

            Console.WriteLine(card.CardId + " " + card.Title + " " + card.Description);
        }
Exemplo n.º 4
0
        public static string RepoRoute(string key, string arg = null)
        {
            string str = null;

            var arr = key.Split('.');

            if (arr[0] != "repo")
            {
                return(str);
            }

            using (var ctx = new SqliteDbContext())
            {
                if (arr[1] == "building")
                {
                    str = new BaseRepo <Building>(ctx).ParseCmd(arr[2], arg);
                }
                else if (arr[1] == "device")
                {
                    str = new BaseRepo <Device>(ctx).ParseCmd(arr[2], arg);
                }
                else if (arr[1] == "userinfo")
                {
                    str = new BaseRepo <UserInfo>(ctx).ParseCmd(arr[2], arg);
                }
                else if (arr[1] == "cardinfo")
                {
                    var repo = new CardRepo(ctx);
                    if (arr[2] == "fetchByCardNo")
                    {
                        str = JsonUtil.Stringify(repo.FindByCardNo(arg));
                    }
                    else if (arr[2] == "queryUserCard")
                    {
                        str = JsonUtil.Stringify(repo.QueryUserCard(arg));
                    }
                }
                if (arr[2].StartsWith("fetch") == false)
                {
                    ctx.SaveChanges();
                }
            }

            return(str);
        }
Exemplo n.º 5
0
 public CardBLL()
 {
     _cardRepo = new CardRepo();
 }
Exemplo n.º 6
0
 public SaleRepoImplBase(CardRepo cardRepo)
 {
     this.cardRepo = cardRepo;
 }
Exemplo n.º 7
0
 public cartaoDadosForm()
 {
     InitializeComponent();
     currentCarrinho = Session.getCarrinho();
     cardDB          = new CardRepo();
 }
Exemplo n.º 8
0
 public ActionResult Donate(CardDetails cardDetails)
 {
     CardRepo.Insert(cardDetails);
     ViewBag.Success = "Success";
     return(View());
 }