public static DonationErr Assign(string DIN, Guid peopleID, int campaignID, DateTime? collectedDate, string actor)
        {
            RedBloodDataContext db = new RedBloodDataContext();

            //Donation d = (from c in db.Donations
            //              where c.DIN == DIN && c.PeopleID == null && c.CampaignID == null
            //              select c).FirstOrDefault();

            var re = DonationErrEnum.Non;

            var existingPeople = db.Donations
                .FirstOrDefault(r => r.PeopleID == peopleID && r.CampaignID == campaignID);

            if (existingPeople == null)
            {
                var d = db.Donations
                    .FirstOrDefault(r => r.DIN == DIN && r.PeopleID == null && r.CampaignID == null);

                if (d == null)
                {
                    re = DonationErrEnum.NonExist;
                }
                else
                {
                    try
                    {
                        d.PeopleID = peopleID;
                        d.CollectedDate = collectedDate;
                        d.CampaignID = campaignID;
                        d.Actor = actor;

                        DonationDAL.UpdateStatus(db, d.DIN, Donation.StatusX.Assigned, "Assign peopleID=" + peopleID.ToString() + "&CampaignID=" + campaignID.ToString());

                        db.SubmitChanges();
                    }
                    catch (Exception ex)
                    {
                        re = new DonationErr(ex.Message);
                    }
                }
            }
            else
            {
                re = DonationErrEnum.PeopleCollected;
            }

            return re;
        }
Beispiel #2
0
    private void DINEnter(string code)
    {
        string tempDIN = BarcodeBLL.ParseDIN(code);

        RedBloodDataContext db = new RedBloodDataContext();
        Donation            d  = DonationBLL.Get(tempDIN);

        if (d == null)
        {
            this.Alert(DonationErrEnum.NonExist.Message);
            return;
        }

        if (d.PeopleID != null)
        {
            DIN            = tempDIN;
            ucPDL.PeopleID = d.PeopleID.Value;
            return;
        }

        if (ucPeople.PeopleID == Guid.Empty)
        {
            this.Alert("Chưa nhập thông tin người cho máu.");
            return;
        }
        if (CamDetailLeft.CampaignID == 0)
        {
            this.Alert("Chưa nhập thông tin đợt thu máu.");
            return;
        }

        DIN = tempDIN;

        DonationErr err = DonationBLL.Assign(DIN, ucPeople.PeopleID, CamDetailLeft.CampaignID);

        if (err != DonationErrEnum.Non)
        {
            this.Alert("Túi máu: " + err.Message);
        }
        else
        {
            ucPDL.ShowLog();
        }

        return;
    }