public void Fill_Letter(Donation e) { LabelName.Text = e.People.Name; LabelDOB.Text = e.People.DOBToString; LabelPackCode.Text = e.DIN; LabelAddress.Text = e.People.FullResidentalAddress; LabelHIV.Text = e.Markers.HIV; //if (e.Markers.HIV == TR.na.Name) // LabelHIV.Text = "Không có"; //else if (e.Markers.HIV == TR.neg.Name) // LabelHIV.Text = "Âm tính"; //else if (e.Markers.HIV == TR.pos.Name) // LabelHIV.Text = "Dương tính"; //else // LabelHIV.Text = e.Markers.HIV; LabelHCV.Text = e.Markers.HCV_Ab; //if (e.Markers.HCV_Ab == TR.na.Name) // LabelHCV.Text = TR.na.Name; //else if (e.Markers.HCV_Ab == TR.neg.Name) // LabelHCV.Text = "Âm tính"; //else if (e.Markers.HCV_Ab == TR.pos.Name) // LabelHCV.Text = "Dương tính"; //else // LabelHCV.Text = e.Markers.HCV_Ab; LabelHBsAg.Text = e.Markers.HBs_Ag; //if (e.Markers.HBs_Ag == TR.na.Name) // LabelHBsAg.Text = "Không có"; //else if (e.Markers.HBs_Ag == TR.neg.Name) // LabelHBsAg.Text = "Âm tính"; //else if (e.Markers.HBs_Ag == TR.pos.Name) // LabelHBsAg.Text = "Dương tính"; //else // LabelHBsAg.Text = e.Markers.HBs_Ag; LabelMalaria.Text = e.Markers.Malaria; //if (e.Markers.Malaria == TR.na.Name) // LabelMalaria.Text = "Không có"; //else if (e.Markers.Malaria == TR.neg.Name) // LabelMalaria.Text = "Âm tính"; //else if (e.Markers.Malaria == TR.pos.Name) // LabelMalaria.Text = "Dương tính"; //else // LabelMalaria.Text = e.Markers.Malaria; LabelSyphilis.Text = e.Markers.Syphilis; //if (e.Markers.Syphilis == TR.na.Name) // LabelSyphilis.Text = "Không có"; //else if (e.Markers.Syphilis == TR.neg.Name) // LabelSyphilis.Text = "Âm tính"; //else if (e.Markers.Syphilis == TR.pos.Name) // LabelSyphilis.Text = "Dương tính"; //else // LabelSyphilis.Text = e.Markers.Syphilis; LabelABO_Rh.Text = BloodGroupBLL.GetDescription(e.BloodGroup); }
public void Fill_Letter(Donation e) { lblName.Text = e.People.Name; lblName.Style.Apply(PrintSettingBLL.Card.Name); lblDOB.Text = e.People.DOBToString; lblDOB.Style.Apply(PrintSettingBLL.Card.DOB); imgAutonum.ImageUrl = BarcodeBLL.Url4People(e.People.Autonum); imgAutonum.Style.Apply(PrintSettingBLL.Card.Autonum); lblBloodGroup.Text = e.BloodGroupDesc; lblBloodGroup.Style.Apply(PrintSettingBLL.Card.BloodGroup); lblAddress.Text = e.People.FullResidentalAddress; lblAddress.Style.Apply(PrintSettingBLL.Card.Address); lblDonation1.Style.Apply(PrintSettingBLL.Card.lbl1); lblDonationDate1.Text = e.CollectedDate.ToStringVN(); lblDonationDate1.Style.Apply(PrintSettingBLL.Card.Date1); lblTotalText.Style.Apply(PrintSettingBLL.Card.lblTotal); lblTotal.Text = e.People.Donations.Count.ToString(); lblTotal.Style.Apply(PrintSettingBLL.Card.Total); divLabel.Style.Apply(PrintSettingBLL.Card.CardSize); }
protected void btnSubmit_Click(object sender, EventArgs e) { PassCodeGenerator pg = new PassCodeGenerator(); int passcode = pg.GetPasscode(); Customer c = new Customer(); Donation d = new Donation(); PasswordHash ph = new PasswordHash(); c.LastName = txtLastName.Text; c.FirstName = txtFirstName.Text; c.Email = txtEmail.Text; c.Password = txtPassword.Text; //c.passcode = passcode; //c.PasswordHash = ph.HashIt(txtPassword.Text, passcode.ToString()); try { ManagePerson mp = new ManagePerson(d, c); mp.WriteRegisteredCustomer(); mp.WriteDonation(); lblResult.Text = "Thank you for registering!"; LinkButton1.Visible = true; } catch (Exception ex) { lblResult.Text = ex.ToString(); } }
void AddDINLabelControl(Donation item, Panel panel) { DonationCardUserControl uc = new DonationCardUserControl(); uc = (DonationCardUserControl)LoadControl("~/Collect/DonationCardUserControl.ascx"); uc.Fill_Letter(item); panel.Controls.Add(uc); }
void AddControl(Donation item, Panel panel) { DINCertUserControl uc = new DINCertUserControl(); uc = (DINCertUserControl)LoadControl("~/Collect/DINCertUserControl.ascx"); uc.Fill_Letter(item); panel.Controls.Add(uc); }
void AddControl(Donation item, Panel panel) { EnvelopeUserControl uc = new EnvelopeUserControl(); uc = (EnvelopeUserControl)LoadControl("~/Collect/EnvelopeUserControl.ascx"); uc.Fill_Letter(item.People); panel.Controls.Add(uc); }
void AddDINLabelControl(Donation item, PrintSetting ps, Panel panel) { DINLabelUserControl uc = new DINLabelUserControl(); uc = (DINLabelUserControl)LoadControl("~/Collect/DINLabelUserControl.ascx"); uc.Fill_Letter(item.DIN); uc.ResizeLabel(ps); panel.Controls.Add(uc); }
public DonationStatusLog(Donation e, Donation.StatusX from, Donation.StatusX to, string actor, string note) { DIN = e.DIN; FromStatus = from; ToStatus = to; Actor = actor; Note = note; Date = DateTime.Now; }
public void Fill_Letter(Donation e) { LabelName.Text = e.People.Name; LabelDOB.Text = e.People.DOBToString; LabelPackCode.Text = e.DIN; LabelAddress.Text = e.People.FullResidentalAddress; LabelCollectedDate.Text = e.CollectedDate.ToStringVN(); LabelDate.Text = DateTime.Now.AddMonthsAvoidWeekend(1).ToStringVN(); }
protected void Button1_Click(object sender, EventArgs e) { Donation d = new Donation(); int personkey= int.Parse(DropDownList1.SelectedValue.ToString()); d.WriteDonation(personkey, decimal.Parse(TextBox1.Text)); TextBox1.Text=""; TextBox1.Focus(); }
public void Donate(Donation d) { Donation donate = new Donation(); donate.DonationDate = DateTime.Now; donate.DonationAmount = d.DonationAmount; donate.PersonKey = d.PersonKey; communityAssistDb.Donations.Add(donate); communityAssistDb.SaveChanges(); }
public static bool CanUpdateTestResult(Donation e) { if (e == null) throw new Exception(DonationErrEnum.NonExist.Message); if (e.Packs.Count == 0) return false; if (e.Packs.Count(r => r.Status == Pack.StatusX.Delivered) > 0) return false; return true; }
protected void btnDonateMore_Click(object sender, EventArgs e) { CommunityAssistEntities entities = new CommunityAssistEntities(); int pk = (int)Session["Person"]; Donation d = new Donation(); d.DonationAmount = Convert.ToDecimal(txtDonate.Text); d.DonationAmount = pk; entities.Donations.Add(d); //entities.SaveChanges(); Response.Redirect("TYDonation.aspx"); }
protected void btnSubmit_Click(object sender, EventArgs e) { try { CommunityAssistEntities cae = new CommunityAssistEntities(); Person p = new Person(); p.FirstName = txtFirstname.Text; p.LastName = txtLastName.Text; cae.People.Add(p); PersonAddress pa = new PersonAddress(); pa.Person = p; pa.Street = txtAddress.Text; pa.City = txtCity.Text; pa.State = txtState.Text; pa.Zip = txtZipCode.Text; cae.PersonAddresses.Add(pa); PersonContact pc = new PersonContact(); pc.Person = p; pc.ContactInfo = txtEmail.Text; pc.ContactTypeKey = 6; cae.PersonContacts.Add(pc); PersonContact phone = new PersonContact(); phone.Person = p; phone.ContactInfo = txtHomePhone.Text; phone.ContactTypeKey = 1; cae.PersonContacts.Add(phone); Donation d = new Donation(); d.DonationDate = DateTime.Now; d.Person = p; d.DonationAmount = decimal.Parse(txtDonation.Text); cae.Donations.Add(d); cae.SaveChanges(); txtError.Text = "Donation Submitted"; } catch (Exception ex) { txtError.Text = ex.Message; } }
public void Fill_Letter(Donation e) { LabelName.Text = e.People.Name; LabelDOB.Text = e.People.DOBToString; LabelPackCode.Text = e.DIN; LabelAddress.Text = e.People.FullResidentalAddress; LabelHIV.Text = e.TR_HIV.Description(); LabelHCV.Text = e.TR_HCV_Ab.Description(); LabelHBsAg.Text = e.TR_HBs_Ag.Description(); LabelMalaria.Text = e.TR_Malaria.Description(); LabelSyphilis.Text = e.TR_Syphilis.Description(); LabelABO_Rh.Text = BloodGroupBLL.GetDescription(e.BloodGroup); }
public static void Insert(RedBloodDataContext db, Donation p, string propertyName, string note) { DonationTestLog e = new DonationTestLog(); e.DIN = p.DIN; e.Type = propertyName; PropertyInfo prop = p.GetType().GetProperty(propertyName); if (prop != null) { e.Result = prop.GetValue(p, null).ToString(); } e.Date = DateTime.Now; e.Actor = RedBloodSystem.CurrentActor; e.Note = note; db.DonationTestLogs.InsertOnSubmit(e); }
public static DonationStatusLog UpdateStatus(RedBloodDataContext db, string DIN, Donation.StatusX to, string note) { var e = Get(db, DIN); DonationStatusLog l = null; if (e == null || e.Status == to) { } else { l = new DonationStatusLog(e.Status, to, RedBloodSystem.CurrentActor, note); e.DonationStatusLogs.Add(l); e.Status = to; //db.DonationStatusLogs.InsertOnSubmit(l); //db.SubmitChanges(); } return l; }
protected void btnSubmit_Click(object sender, EventArgs e) { try { CommunityAssistEntities1 cae = new CommunityAssistEntities1(); Donation d = new Donation(); int pk = (int)Session["personKey"]; d.DonationAmount = Decimal.Parse(txtDonation.Text); d.DonationDate = DateTime.Now; d.PersonKey = pk; cae.Donations.Add(d); cae.SaveChanges(); Response.Redirect("Confirmation.aspx"); } catch (Exception ex) { lblError.Text = ex.Message; } }
partial void OnStatusChanging(Donation.StatusX value);
public Guid Insert(Donation donation) { Console.WriteLine("POST REPOSITORY"); using (NpgsqlConnection con = new NpgsqlConnection(connectionString)) { con.Open(); //Inicia a transação using (var trans = con.BeginTransaction()) { try { donation.DonationId = Guid.NewGuid(); donation.Address.AddressId = Guid.NewGuid(); NpgsqlCommand cmd = new NpgsqlCommand(); cmd.Connection = con; cmd.Transaction = trans; cmd.CommandText = @"INSERT Into address (address_id,cep,avenue,number,neighborhood,city,state)values(@address_id,@cep,@avenue,@number,@neighborhood,@city,@state)"; cmd.Parameters.AddWithValue("address_id", donation.Address.AddressId); cmd.Parameters.AddWithValue("cep", donation.Address.CEP); cmd.Parameters.AddWithValue("avenue", donation.Address.Avenue); cmd.Parameters.AddWithValue("number", donation.Address.Number); cmd.Parameters.AddWithValue("neighborhood", donation.Address.Neighborhood); cmd.Parameters.AddWithValue("city", donation.Address.City); cmd.Parameters.AddWithValue("state", donation.Address.State); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); cmd.CommandText = @"INSERT Into public.donation (donation_id,user_id,title,description,quantity,takeDonation,address_id)values(@donation_id,@user_id,@title,@description,@quantity,@takeDonation,@address_id)"; cmd.Parameters.AddWithValue("donation_id", donation.DonationId); cmd.Parameters.AddWithValue("user_id", donation.UserId); cmd.Parameters.AddWithValue("title", donation.Title); cmd.Parameters.AddWithValue("description", donation.Description); cmd.Parameters.AddWithValue("quantity", donation.Quantity); cmd.Parameters.AddWithValue("takeDonation", donation.TakeDonation); cmd.Parameters.AddWithValue("address_id", donation.Address.AddressId); cmd.ExecuteNonQuery(); foreach (var affinity in donation.Affinities) { cmd.Parameters.Clear(); cmd.CommandText = @"INSERT Into donation_affinity (donation_id, affinity_id) VALUES (@donation_id, @affinity_id)"; cmd.Parameters.AddWithValue("donation_id", donation.DonationId); cmd.Parameters.AddWithValue("affinity_id", affinity.AffinityId); cmd.ExecuteNonQuery(); } //commit na transação trans.Commit(); return(donation.DonationId); } catch (Exception ex) { //rollback da transação trans.Rollback(); throw ex; } } } }
public void MyTestCleanup() { _targetDonation = null; }
public ThankMail(Donation donation) { _donation = donation; }
public static void Importing() { //Validate database before insert List <string> importedGeo = new List <string>(); RedBloodDataContext importDB; try { importDB = new RedBloodDataContext(ConfigurationManager.ConnectionStrings["ImportingRedBlood_DBConnectionString"].ConnectionString); //try to load whatever data to test connection importDB.Sexes.ToList(); } catch (Exception ex) { throw ex; } string strImportWithInDays = ConfigurationManager.AppSettings["ImportWithInDays"]; int importWithInDays = 1; if (!string.IsNullOrEmpty(strImportWithInDays)) { importWithInDays = strImportWithInDays.ToInt(); } if (importWithInDays < 1) { importWithInDays = 1; } List <Donation> importDINList = importDB.Donations .Where(r => r.CollectedDate.HasValue && (DateTime.Now.Date - r.CollectedDate.Value.Date).Days <= importWithInDays - 1 && r.PeopleID.HasValue && r.CampaignID.HasValue ) .ToList(); RedBloodDataContext db = new RedBloodDataContext(); foreach (Donation item in importDINList) { //Validate DIN Donation innerDIN = DonationBLL.Get(item.DIN); if (innerDIN == null || innerDIN.CollectedDate.HasValue || innerDIN.PeopleID.HasValue ) { continue; } //Campaign Campaign innerCam = CampaignBLL.Get(item.CampaignID.Value); if (innerCam == null) { continue; } //People if (item.People == null) { continue; } Guid?peopleID = ImportPeople(db, item.People); if (!peopleID.HasValue || peopleID.Value == Guid.Empty) { continue; } //Import DIN DonationBLL.Assign(innerDIN.DIN, peopleID.Value, innerCam.ID, item.CollectedDate, item.Actor); //PackBLL.CreateOriginal(innerDIN.DIN, item.Pack.ProductCode, item.Volume.Value); DonationBLL.Update(innerDIN.DIN, item.BloodGroup, "ImportingFromMDF"); DonationBLL.UpdateCollector(innerDIN.DIN, item.Collector); } }
public DesiredPage(Donation donation) { InitializeComponent(); }
public static DonationStatusLog UpdateStatus(RedBloodDataContext db, Donation e, Donation.StatusX to, string note) { return UpdateStatus(db, e, to, RedBloodSystem.CurrentActor, note); }
public Donation Add(Donation donation, IEnumerable <Category> categories) { using var transaction = _dbContext.Database.BeginTransaction(); try { _dbContext.Donations.Add(donation); _dbContext.SaveChanges(); } catch (Exception) { transaction.Rollback(); throw; } if (donation.DonationCategories is null) { donation.DonationCategories = new List <CategoriesDonationsRelation>(); } foreach (var item in categories) { Category category = null; try { category = CreateCategory(category); } catch (Exception) { transaction.Rollback(); throw; } if (category.DonationCategories is null) { category.DonationCategories = new List <CategoriesDonationsRelation>(); } CategoriesDonationsRelation relation = null; try { relation = CreateRelation(donation, category); } catch (Exception) { transaction.Rollback(); throw; } try { AddRelationToDonationAndCategory(donation, category, relation); } catch (Exception) { transaction.Rollback(); throw; } } transaction.Commit(); return(donation); }
public ActionResult DonationEdit(int?id) { Donation donation = db.Donations.Find(id); return(View(donation)); }
public void Fill_Letter(Donation e) { LabelName.Text = e.People.Name; LabelDOB.Text = e.People.DOBToString; LabelPackCode.Text = e.DIN; LabelAddress.Text = e.People.FullResidentalAddress; if (e.Markers.HIV == TR.na.Name) { LabelHIV.Text = "Không có"; } else if (e.Markers.HIV == TR.neg.Name) { LabelHIV.Text = "Âm tính"; } else if (e.Markers.HIV == TR.pos.Name) { LabelHIV.Text = "Dương tính"; } else { LabelHIV.Text = e.Markers.HIV; } if (e.Markers.HCV_Ab == TR.na.Name) { LabelHCV.Text = "Không có"; } else if (e.Markers.HCV_Ab == TR.neg.Name) { LabelHCV.Text = "Âm tính"; } else if (e.Markers.HCV_Ab == TR.pos.Name) { LabelHCV.Text = "Dương tính"; } else { LabelHCV.Text = e.Markers.HCV_Ab; } if (e.Markers.HBs_Ag == TR.na.Name) { LabelHBsAg.Text = "Không có"; } else if (e.Markers.HBs_Ag == TR.neg.Name) { LabelHBsAg.Text = "Âm tính"; } else if (e.Markers.HBs_Ag == TR.pos.Name) { LabelHBsAg.Text = "Dương tính"; } else { LabelHBsAg.Text = e.Markers.HBs_Ag; } if (e.Markers.Malaria == TR.na.Name) { LabelMalaria.Text = "Không có"; } else if (e.Markers.Malaria == TR.neg.Name) { LabelMalaria.Text = "Âm tính"; } else if (e.Markers.Malaria == TR.pos.Name) { LabelMalaria.Text = "Dương tính"; } else { LabelMalaria.Text = e.Markers.Malaria; } if (e.Markers.Syphilis == TR.na.Name) { LabelSyphilis.Text = "Không có"; } else if (e.Markers.Syphilis == TR.neg.Name) { LabelSyphilis.Text = "Âm tính"; } else if (e.Markers.Syphilis == TR.pos.Name) { LabelSyphilis.Text = "Dương tính"; } else { LabelSyphilis.Text = e.Markers.Syphilis; } LabelABO_Rh.Text = BloodGroupBLL.GetDescription(e.BloodGroup); }
public static void Add(string DIN, string productCode, int?volume, Pack orgPack = null, DateTime?packDate = null) { RedBloodDataContext db = new RedBloodDataContext(); Donation d = null; if (orgPack == null) { d = DonationBLL.Get4CreateOriginal(db, DIN); } else { d = DonationBLL.Get(DIN); } Product product = ProductBLL.Get(productCode); if (IsExist(DIN, productCode)) { throw new Exception(PackErrEnum.Existed.Message); } //TODO: Check to see valid product code in collection //Code will be here //TODO: Check to see if the pack is collector too late //Code check will be here. Pack pack = new Pack(); pack.DIN = DIN; pack.ProductCode = productCode; pack.Status = Pack.StatusX.Product; pack.Actor = RedBloodSystem.CurrentActor; //pack.Volume = product.OriginalVolume.HasValue ? product.OriginalVolume : defaultVolume; pack.Volume = volume; if (orgPack != null && product.CreatedDateFromOrgPack.HasValue && product.CreatedDateFromOrgPack.Value) { pack.Date = orgPack.Date; } else { if (packDate != null) { pack.Date = packDate; } else { pack.Date = DateTime.Now; } } pack.ExpirationDate = pack.Date.Value.Add(product.Duration.Value - RedBloodSystem.RootTime); db.Packs.InsertOnSubmit(pack); db.SubmitChanges(); PackTransactionBLL.Add(pack.ID, Pack.StatusX.Non, Pack.StatusX.Product, orgPack == null ? PackTransaction.TypeX.In_Collect : PackTransaction.TypeX.In_Product); if (orgPack == null) { DonationBLL.SetOriginalPack(DIN, pack.ID); } }
public void Update(Donation donation) { repository.Update(donation); }
public void Insert(Donation donation) { repository.Insert(donation); }
partial void InsertDonation(Donation instance);
partial void DeleteDonation(Donation instance);
public async Task <bool> AddDonation(Donation donation) { _context.Add(donation); return(await _context.SaveChangesAsync() > 0); }
public static DonationErr UpdateTestResultStatus(Donation e) { //RedBloodDataContext db = new RedBloodDataContext(); //Donation e = Get(db, DIN); if (e == null || !CanUpdateTestResult(e)) return DonationErrEnum.TRLocked; if (string.IsNullOrEmpty(e.BloodGroup)) e.TestResultStatus = Donation.TestResultStatusX.Non; else e.TestResultStatus = e.Markers.Status; return DonationErrEnum.Non; }
public async Task <bool> UpdateDonationStatusAsync(Donation donation) { _context.Donations.Update(donation); return(await _context.SaveChangesAsync() > 0); }
public bool givingGift(Donation don1) { return(don1.Sum > 5000); }
public ActionResult <Student> CreateDonation(Donation donation) { donation = _donationRepository.createDonation(donation); return(Ok(donation)); }
/// <summary> /// Get full information of User /// #Note: If you add new field to UserBasicInfoDTO model - /// Please write code to set that information in this function /// </summary> /// <param name="userId"></param> /// <returns>UserBasicInfoDTO</returns> public UserBasicInfoDTO GetFullInforOfUserAsBasicUser(int userId) { UserBasicInfoDTO currentUser = new UserBasicInfoDTO(); int numberEventDonatedIn = 0; decimal totalMoneyDonatedIn = 0; decimal lastDonateMoney = 0; string lastDonateDate = ""; int numberOfPost = 0; try { Ws_User wsUser = GetUserById(userId); User_Information userInformation = GetUserInformation(userId); //Get infomation about donation of this user using (var db = new DonationDAL()) { numberEventDonatedIn = db.GetNumberEventDonatedInByUsingUserId(userId); totalMoneyDonatedIn = db.GetTotalMoneyDonatedInByUsingUserId(userId); Donation lastDonation = db.GetLastDonateInformation(userId); if (lastDonation != null) { lastDonateMoney = lastDonation.DonatedMoney; lastDonateDate = lastDonation.DonatedDate.ToString("H:mm:ss dd/MM/yy"); } } //Get number of post for current user using (var db = new ThreadDAL()) { numberOfPost = db.GetNumberOfPostPerUser(userId); } using (var db = new OrganizationDAL()) { Organization org = db.GetOrganizationById(userId); if (org != null) { currentUser.OrganazationName = org.OrganizationName; } if (currentUser.OrganazationName == "") { currentUser.OrganazationName = "Chưa có"; } } using (var db = new Ws_DataContext()) { currentUser.JoinedDate = db.Ws_User.Where(x => x.UserID == userId).SingleOrDefault().CreatedDate.ToString("dd/mm/yyyy"); } //get ranking information WsRanking ranking = new WsRanking(); RankingDTO rank = new RankingDTO(); //Set information for user which want to get currentUser.UserId = userId; currentUser.UserName = wsUser.UserName; currentUser.AccountType = wsUser.AccountType; currentUser.IsActive = wsUser.IsActive; currentUser.IsVerify = wsUser.IsVerify; currentUser.Email = wsUser.Email; if (userInformation != null) { rank = ranking.RankingWithPoint(userInformation.Point); currentUser.FacebookUri = userInformation.FacebookUrl; currentUser.FullName = userInformation.FullName; currentUser.ProfileImage = userInformation.ProfileImage; currentUser.Gender = userInformation.Gender; currentUser.Phone = userInformation.Phone; currentUser.Address = userInformation.UserAddress; currentUser.UserSignature = userInformation.UserSignature; if (userInformation.DoB != null) { currentUser.DOB = userInformation.DoB.Value.ToString("dd/MM/yyyy"); } currentUser.Country = userInformation.Country; currentUser.FacebookUri = userInformation.FacebookUrl; currentUser.CreateDate = wsUser.CreatedDate.ToString("dd/MM/yyyy"); currentUser.Point = userInformation.Point; } currentUser.NumberOfPost = numberOfPost; if (rank.CurrentRank == 0) { currentUser.CurrentRank = "Mới"; } else if (rank.CurrentRank == 200) { currentUser.CurrentRank = "Đồng"; } else if (rank.CurrentRank == 500) { currentUser.CurrentRank = "Bạc"; } else if (rank.CurrentRank == 2000) { currentUser.CurrentRank = "Vàng"; } else if (rank.CurrentRank == 5000) { currentUser.CurrentRank = "Bạch Kim"; } else if (rank.CurrentRank == 10000) { currentUser.CurrentRank = "Kim Cương"; } currentUser.RankPercent = rank.RankPercent; currentUser.NumberEventDonatedIn = numberEventDonatedIn; currentUser.TotalMoneyDonatedIn = totalMoneyDonatedIn; currentUser.LastDonateMoney = lastDonateMoney; currentUser.LastDonateDate = lastDonateDate; } catch (Exception) { //throw; } return(currentUser); }
public async Task <ActionResult> CreateToken(Donation donation) { return(View(donation)); }
public async Task AddDonation(Donation donation) { _dbContext.Add(donation); await _dbContext.SaveChangesAsync(); }
public void Save(Donation donation) { _dbContext.Donations.Add(donation); _dbContext.SaveChanges(); }
private void detach_Donations(Donation entity) { this.SendPropertyChanging(); entity.Campaign = null; }
public IActionResult Edit(DonationFormViewModel model) { if (ModelState.IsValid) { Account s = _saveRepo.Accounts.Where(x => x.TypeID == _saveTypeRepo.AccountTypes.Where(y => y.Name.Equals("Personal")).FirstOrDefault().ID).FirstOrDefault(); CreditBalance c = _payRepo.PaymentMethods.Where(x => x.ID == model.Donation.PaymentMethodID).First().CreditBalance; if (model.Donation.ID == 0) { if (_payRepo.PaymentMethods.Where(x => x.ID == model.Donation.PaymentMethodID).FirstOrDefault().IsCredit) { c.Amount = Math.Round(c.Amount + model.Donation.Amount, 2); } else { s.Amount = Math.Round(s.Amount - model.Donation.Amount, 2); } } else { Donation i = _repo.Donations.Where(x => x.ID == model.Donation.ID).FirstOrDefault(); if (_payRepo.PaymentMethods.Where(x => x.ID == model.Donation.PaymentMethodID).FirstOrDefault().IsCredit) { c.Amount = Math.Round(c.Amount + model.Donation.Amount - i.Amount, 2); } else { s.Amount = Math.Round(s.Amount + i.Amount - model.Donation.Amount, 2); } } int id = _repo.Save(model.Donation); if (s != null) { _saveRepo.Save(s); } if (c != null) { _creditRepo.Save(c); } TempData["message"] = $"{model.Donation.Description} has been saved"; return(RedirectToAction("MonthlyReport")); } else { if (model.Donation.ID == 0) { ViewBag.FormTitle = "Create Donation"; } else { ViewBag.FormTitle = "Edit Donation"; } model.Charities = new SelectList(_catRepo.Charities.ToList(), "ID", "Name"); model.PaymentMethods = new SelectList(_payRepo.PaymentMethods.ToList(), "ID", "Method"); return(View(model)); } }
public void Seed() { if (_context.Department.Any() || _context.Seller.Any() || _context.SalesRecord.Any() || _context.Donation.Any()) //testa se tem registro no banco de dados { return; //banco de dados foi populado } Department d1 = new Department(1, "Computers"); Department d2 = new Department(2, "Electronics"); Department d3 = new Department(3, "Fashion"); Department d4 = new Department(4, "Books"); Seller s1 = new Seller(1, "Bob Brown", "*****@*****.**", new DateTime(1998, 4, 21), 1000.0, d1); Seller s2 = new Seller(2, "Maria Green", "*****@*****.**", new DateTime(1979, 12, 31), 3500.0, d2); Seller s3 = new Seller(3, "Alex Grey", "*****@*****.**", new DateTime(1988, 1, 15), 2200.0, d1); Seller s4 = new Seller(4, "Martha Red", "*****@*****.**", new DateTime(1993, 11, 30), 3000.0, d4); Seller s5 = new Seller(5, "Donald Blue", "*****@*****.**", new DateTime(2000, 1, 9), 4000.0, d3); Seller s6 = new Seller(6, "Alex Pink", "*****@*****.**", new DateTime(1997, 3, 4), 3000.0, d2); SalesRecord r1 = new SalesRecord(1, new DateTime(2018, 09, 25), 11000.0, SaleStatus.Billed, s1); SalesRecord r2 = new SalesRecord(2, new DateTime(2018, 09, 4), 7000.0, SaleStatus.Billed, s5); SalesRecord r3 = new SalesRecord(3, new DateTime(2018, 09, 13), 4000.0, SaleStatus.Canceled, s4); SalesRecord r4 = new SalesRecord(4, new DateTime(2018, 09, 1), 8000.0, SaleStatus.Billed, s1); SalesRecord r5 = new SalesRecord(5, new DateTime(2018, 09, 21), 3000.0, SaleStatus.Billed, s3); SalesRecord r6 = new SalesRecord(6, new DateTime(2018, 09, 15), 2000.0, SaleStatus.Billed, s1); SalesRecord r7 = new SalesRecord(7, new DateTime(2018, 09, 28), 13000.0, SaleStatus.Billed, s2); SalesRecord r8 = new SalesRecord(8, new DateTime(2018, 09, 11), 4000.0, SaleStatus.Billed, s4); SalesRecord r9 = new SalesRecord(9, new DateTime(2018, 09, 14), 11000.0, SaleStatus.Pending, s6); SalesRecord r10 = new SalesRecord(10, new DateTime(2018, 09, 7), 9000.0, SaleStatus.Billed, s6); SalesRecord r11 = new SalesRecord(11, new DateTime(2018, 09, 13), 6000.0, SaleStatus.Billed, s2); SalesRecord r12 = new SalesRecord(12, new DateTime(2018, 09, 25), 7000.0, SaleStatus.Pending, s3); SalesRecord r13 = new SalesRecord(13, new DateTime(2018, 09, 29), 10000.0, SaleStatus.Billed, s4); SalesRecord r14 = new SalesRecord(14, new DateTime(2018, 09, 4), 3000.0, SaleStatus.Billed, s5); SalesRecord r15 = new SalesRecord(15, new DateTime(2018, 09, 12), 4000.0, SaleStatus.Billed, s1); SalesRecord r16 = new SalesRecord(16, new DateTime(2018, 10, 5), 2000.0, SaleStatus.Billed, s4); SalesRecord r17 = new SalesRecord(17, new DateTime(2018, 10, 1), 12000.0, SaleStatus.Billed, s1); SalesRecord r18 = new SalesRecord(18, new DateTime(2018, 10, 24), 6000.0, SaleStatus.Billed, s3); SalesRecord r19 = new SalesRecord(19, new DateTime(2018, 10, 22), 8000.0, SaleStatus.Billed, s5); SalesRecord r20 = new SalesRecord(20, new DateTime(2018, 10, 15), 8000.0, SaleStatus.Billed, s6); SalesRecord r21 = new SalesRecord(21, new DateTime(2018, 10, 17), 9000.0, SaleStatus.Billed, s2); SalesRecord r22 = new SalesRecord(22, new DateTime(2018, 10, 24), 4000.0, SaleStatus.Billed, s4); SalesRecord r23 = new SalesRecord(23, new DateTime(2018, 10, 19), 11000.0, SaleStatus.Canceled, s2); SalesRecord r24 = new SalesRecord(24, new DateTime(2018, 10, 12), 8000.0, SaleStatus.Billed, s5); SalesRecord r25 = new SalesRecord(25, new DateTime(2018, 10, 31), 7000.0, SaleStatus.Billed, s3); SalesRecord r26 = new SalesRecord(26, new DateTime(2018, 10, 6), 5000.0, SaleStatus.Billed, s4); SalesRecord r27 = new SalesRecord(27, new DateTime(2018, 10, 13), 9000.0, SaleStatus.Pending, s1); SalesRecord r28 = new SalesRecord(28, new DateTime(2018, 10, 7), 4000.0, SaleStatus.Billed, s3); SalesRecord r29 = new SalesRecord(29, new DateTime(2018, 10, 23), 12000.0, SaleStatus.Billed, s5); SalesRecord r30 = new SalesRecord(30, new DateTime(2018, 10, 12), 5000.0, SaleStatus.Billed, s2); Donation don1 = new Donation(1, "Zé", 1000.0); Donation don2 = new Donation(2, "Ivonete", 5000.0); Donation don3 = new Donation(3, "Marinete", 3000.0); _context.Department.AddRange(d1, d2, d3, d4); _context.Seller.AddRange(s1, s2, s3, s4, s5, s6); _context.SalesRecord.AddRange( r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18, r19, r20, r21, r22, r23, r24, r25, r26, r27, r28, r29, r30 ); _context.Donation.AddRange(don1, don2, don3); _context.SaveChanges(); }
public static List <Donation> getDonations(string Username, string Password, string serviceURL, string Action, DateTime DateFrom, DateTime DateTo) { List <Donation> donations = new List <Donation>(); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceURL); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; StringBuilder data = new StringBuilder(); data.Append("Username="******"&Password="******"&Action=" + HttpUtility.UrlEncode(Action)); data.Append("&DateFrom=" + HttpUtility.UrlEncode(DateFrom.ToString("M/d/yyyy"))); data.Append("&DateTo=" + HttpUtility.UrlEncode(DateTo.ToString("M/d/yyyy"))); data.Append("&Order=Date"); request.ContentLength = data.Length; StreamWriter requestWriter = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII); requestWriter.Write(data); requestWriter.Close(); try { WebResponse webResponse = request.GetResponse(); if (!webResponse.ContentType.Contains("csv")) { Donation rtn = new Donation(); rtn.DonorName = "Authentication/Connection Error. <a href=\"javascript: $('#divAddCountry').dialog('open');\">Click here</a> to reauthenticate."; rtn.PeopleId = -1; StaffBrokerFunctions.EventLog("MPD-ServiceError downloading Transaction for " + Username, rtn.DonorName, 1); donations.Add(rtn); return(donations); } Stream webStream = webResponse.GetResponseStream(); StreamReader responseReader = new StreamReader(webStream); string response = responseReader.ReadToEnd(); //Console.Out.WriteLine(response); responseReader.Close(); CSVHelper csv = new CSVHelper(response, ","); bool first = true; foreach (string[] line in csv) { if (first) { first = false; } else { try { Donation don = new Donation(); don.account = int.Parse(line[0]); don.PeopleId = int.Parse(line[1]); don.DonorName = line[2].Replace("\"", ""); IFormatProvider culture = new System.Globalization.CultureInfo("en-US"); don.DonationDate = DateTime.Parse(line[3], culture); don.DonationId = line[4]; don.Payment_Method = line[6]; try { don.Amount = double.Parse(line[10], new System.Globalization.CultureInfo("")); } catch (Exception) { don.Amount = double.Parse(line[9], new System.Globalization.CultureInfo("")); } don.FiscalPeriod = don.DonationDate.ToString("yyyyMM"); don.MonthName = don.DonationDate.ToString("MMM yy"); donations.Add(don); } catch (Exception e) { Donation rtn = new Donation(); StaffBrokerFunctions.EventLog("MPD-Service Error downloading a donation for " + Username, e.Message, 1); rtn.DonorName = "There was an error downloading one or more of your donations: this list may not be complete."; rtn.PeopleId = -3; donations.Add(rtn); } } } return(donations); } catch (Exception e) { Donation rtn = new Donation(); StaffBrokerFunctions.EventLog("MPD-Service Error Downloading Donations for " + Username, e.Message, 1); rtn.DonorName = "There was an error downloading your transations from the remote server."; rtn.PeopleId = -2; donations.Add(rtn); return(donations); } }
private void attach_Donations(Donation entity) { this.SendPropertyChanging(); entity.People = this; }
public List <Donation> FindAll() { Console.WriteLine("GET ALL REPOSITORY"); List <Donation> donations = new List <Donation>(); using (NpgsqlConnection con = new NpgsqlConnection(connectionString)) { con.Open(); NpgsqlCommand cmd = new NpgsqlCommand(); cmd.Connection = con; cmd.CommandText = @"SELECT * FROM donation"; var reader = cmd.ExecuteReader(); while (reader.Read()) { Donation donation = new Donation(); donation.DonationId = Guid.Parse(reader["donation_id"].ToString()); donation.UserId = Guid.Parse(reader["user_id"].ToString()); donation.Title = reader["Title"].ToString(); donation.Description = reader["Description"].ToString(); donation.Quantity = reader["Quantity"].ToString(); donation.TakeDonation = (bool)reader["TakeDonation"]; donation.Address = new Address() { AddressId = Guid.Parse(reader["address_id"].ToString()) }; donations.Add(donation); } //para cada doação localizada, encontra os dados relacionados foreach (Donation donation in donations) { reader.Close(); cmd.Parameters.Clear(); cmd.CommandText = @"SELECT * FROM public.user WHERE user_id=@user_id"; cmd.Parameters.AddWithValue("user_id", donation.UserId.ToString()); reader = cmd.ExecuteReader(); while (reader.Read()) { donation.UserId = Guid.Parse(reader["user_id"].ToString()); donation.IsApproved = (bool)reader["is_approved"]; donation.IsEntity = (bool)reader["is_entity"]; donation.IsVoluntary = (bool)reader["is_voluntary"]; donation.IsModerator = (bool)reader["is_moderator"]; donation.Email = reader["email"].ToString(); donation.Password = reader["password"].ToString(); } reader.Close(); cmd.Parameters.Clear(); cmd.CommandText = @"SELECT * FROM address WHERE address_id=@Id"; cmd.Parameters.AddWithValue("Id", donation.Address.AddressId.ToString()); reader = cmd.ExecuteReader(); while (reader.Read()) { donation.Address.CEP = reader["cep"].ToString(); donation.Address.Avenue = reader["avenue"].ToString(); donation.Address.Number = reader["number"].ToString(); donation.Address.Neighborhood = reader["neighborhood"].ToString(); donation.Address.City = reader["city"].ToString(); donation.Address.State = reader["state"].ToString(); } reader.Close(); cmd.Parameters.Clear(); cmd.CommandText = @"SELECT * FROM affinity AF join donation_affinity da on af.affinity_id = da.affinity_id join donation do on do.donation_id = da.donation_id WHERE do.voluntary_id = @Id"; cmd.Parameters.AddWithValue("Id", donation.DonationId.ToString()); reader = cmd.ExecuteReader(); donation.Affinities = new List <Affinity>(); while (reader.Read()) { Console.WriteLine("encontrou as afinidades das doações"); donation.Affinities.Add(new Affinity() { AffinityId = Guid.Parse(reader["voluntary_id"].ToString()), Name = reader["name"].ToString() }); } donations.Add(donation); } } return(donations); }
private void detach_Donations(Donation entity) { this.SendPropertyChanging(); entity.ST_General = null; }
public async Task AddAsync(Donation donation) { await _crowdfundingOnLineDBContext.Donations.AddAsync(donation); await _crowdfundingOnLineDBContext.SaveChangesAsync(); }
partial void OnTestResultStatusChanging(Donation.TestResultStatusX value);
private void OnItemAccepted(PickupItemDetailViewModel sender, Donation item) { viewModel.Items.Remove(item); }
partial void UpdateDonation(Donation instance);
public bool Create(Donation donation) { _context.Donations.Add(donation); return(_context.SaveChanges() > 0); }
public static List<Donation> New(RedBloodDataContext db, int count) { Facility f = FacilityBLL.GetFirst(db); int autonum = f.CountingNumber.Value; Donation[] l = new Donation[count]; for (int i = 0; i < l.Length; i++) { l[i] = new Donation(); autonum++; l[i].DIN = f.FIN + f.CountingYY + autonum.ToString("D6"); l[i].Status = Donation.StatusX.Init; l[i].InfectiousMarkers = 0.ToString("D" + BarcodeBLL.InfectiousMarkersLength.ToString()); } f.CountingNumber = autonum; db.Donations.InsertAllOnSubmit(l); return l.ToList(); }
public bool Update(Donation donation) { _context.Donations.Update(donation); return(_context.SaveChanges() > 0); }
public static DonationStatusLog UpdateStatus(RedBloodDataContext db, Donation e, Donation.StatusX to, string actor, string note) { if (e.Status == to) return null; Donation.StatusX from = e.Status; e.Status = to; DonationStatusLog l = new DonationStatusLog(e, from, to, actor, note); db.DonationStatusLogs.InsertOnSubmit(l); return l; }
public IActionResult CreateCampaign(DonationViewModel donation) { try { var agent = Request.Headers["User-Agent"]; ViewBag.Browser = agent.ToString(); donation.DonationCycles = GetDonationCycles; if (donation.SelectedAmount == 0) //Could be better { ModelState.AddModelError("amount", _localizer["Please select a gift amount."]); return(View("Campaign", donation)); } if (Math.Abs((decimal)donation.DonationAmount) < 1) { ModelState.AddModelError("amount", _localizer["Please enter a gift amount greater than zero."]); return(View("Campaign", donation)); } if (!ModelState.IsValid) { return(View("Campaign", donation)); } var model = new Donation { CycleId = donation.CycleId, DonationAmount = donation.DonationAmount, SelectedAmount = donation.SelectedAmount, Currency = "", TransactionDate = DateTime.Now, Reason = donation.Reason, IsCustom = donation.IsCustom }; _donationService.Save(model); // If user is not authenticated, lets save the details on the session cache and we get them after authentication if (!User.Identity.IsAuthenticated) { var value = HttpContext.Session.GetString(SessionKey); if (string.IsNullOrEmpty(value)) { var donationJson = JsonConvert.SerializeObject(model); HttpContext.Session.SetString(SessionKey, donationJson); } return(RedirectToAction("Login", "Account", new { returnUrl = Request.Path })); } return(Redirect("/Donation/Payment/campaign/" + model.Id)); } catch (Exception ex) { log = new EventLog() { EventId = (int)LoggingEvents.GENERATE_ITEMS, LogLevel = LogLevel.Error.ToString(), Message = ex.Message, StackTrace = ex.StackTrace, Source = ex.Source }; _loggerService.SaveEventLogAsync(log); return(RedirectToAction("Error", "Error500", new ErrorViewModel() { Error = ex.Message })); } }
private void HandleDonation(Donation donation) { Debug.Log($"Donation received: From: {donation.message[0].from} Message: {donation.message[0].message} Amount: {donation.message[0].formattedAmount}"); }
public Donation Find(Guid id) { Console.WriteLine("FIND ONE - REPOSITORY"); Donation donation = null; using (NpgsqlConnection con = new NpgsqlConnection(connectionString)) { con.Open(); //localiza a doação NpgsqlCommand cmd = new NpgsqlCommand(); cmd.Connection = con; cmd.CommandText = @"SELECT * FROM donation WHERE donation_id=@donation_id"; cmd.Parameters.AddWithValue("donation_id", id.ToString()); var reader = cmd.ExecuteReader(); while (reader.Read()) { donation = new Donation(); donation.DonationId = Guid.Parse(reader["donation_id"].ToString()); donation.UserId = Guid.Parse(reader["user_id"].ToString()); donation.Title = reader["Title"].ToString(); donation.Description = reader["Description"].ToString(); donation.Quantity = reader["Quantity"].ToString(); donation.TakeDonation = (bool)reader["TakeDonation"]; donation.Address = new Address() { AddressId = Guid.Parse(reader["address_id"].ToString()) }; } reader.Close(); cmd.Parameters.Clear(); //localiza o usuário que realizou a doação cmd.CommandText = @"SELECT * FROM public.user WHERE user_id=@user_id"; cmd.Parameters.AddWithValue("user_id", donation.UserId.ToString()); reader = cmd.ExecuteReader(); while (reader.Read()) { donation.UserId = Guid.Parse(reader["user_id"].ToString()); donation.IsApproved = (bool)reader["is_approved"]; donation.IsEntity = (bool)reader["is_entity"]; donation.IsVoluntary = (bool)reader["is_voluntary"]; donation.IsModerator = (bool)reader["is_moderator"]; donation.Email = reader["email"].ToString(); donation.Password = reader["password"].ToString(); } reader.Close(); cmd.Parameters.Clear(); //localiza o endereço da doação cmd.CommandText = @"SELECT * FROM address WHERE address_id=@Id"; cmd.Parameters.AddWithValue("Id", donation.Address.AddressId.ToString()); reader = cmd.ExecuteReader(); while (reader.Read()) { donation.Address.CEP = reader["cep"].ToString(); donation.Address.Avenue = reader["avenue"].ToString(); donation.Address.Number = reader["number"].ToString(); donation.Address.Neighborhood = reader["neighborhood"].ToString(); donation.Address.City = reader["city"].ToString(); donation.Address.State = reader["state"].ToString(); } reader.Close(); cmd.Parameters.Clear(); } return(donation); }