private async void btnDelete_Click(object sender, System.EventArgs e) { // Lay tai khoan admin dang duoc chon trong bang Profile profile = GetSelectedProfile(); // Neu hien tai khong co tai khoan nao duoc chon thi hien thong bao if (profile == null) { MessageBox.Show("You must choose an account to edit!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } // Neu co tai khoan dang duoc chon thi sua cot IsActive lai thanh False profile.IsActive = false; // Gui len server de cap nhat lai cot IsActive trong CSDL ProfileWrapper profileWrapper = new ProfileWrapper(); bool isSuccess = await profileWrapper.Put(Convert.ToInt32(profile.ID), profile); // Kiem tra ket qua tra ve if (isSuccess) { // Neu ket qua la thanh cong, hien thong bao thanh cong MessageBox.Show("Account status was set to inactive!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); // Load lai bang LoadDataGridView(); } else { // Neu ket qua that bai, hien thong bao loi MessageBox.Show("An error has occurred!", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void GetAlignmentAndProfile() { string message = "\nSelect alignment: "; _wrappedAlignment = new AlignmentWrapper( Active.Editor.GetEntity <Alignment>(message, OpenMode.ForRead)); _wrappedProfile = _wrappedAlignment.GetWrappedProfile(); }
private async void btnSubmit_Click(object sender, System.EventArgs e) { // Lay gia tri tren form gan vao account profile.UserID = txtUserID.Text; profile.Password = txtPassword.Text; profile.FirstName = txtFirstName.Text; profile.LastName = txtLastName.Text; profile.Address = txtAddress.Text; profile.PhoneNumber = txtPhoneNumber.Text; profile.EmailAddress = txtEmailAddress.Text; profile.Age = Convert.ToInt32(numAge); profile.CreditCard = txtCreditCard.Text; profile.SkyMiles = Convert.ToInt32(numSkyMiles); profile.Sex = rbtnMale.Checked; profile.IsActive = rbtnActive.Checked; // Neu dang o che do tao account moi thi phai lay gia tri trong o password gan vao account. // Neu dang o che do chinh sua ma gia tri trong o password khac voi gia tri password cua account // nghia la nguoi dung da thay doi password, phai cap nhat luon password if (mode == FormMode.CREATE || txtPassword.Text != profile.Password) { profile.Password = ARSUtilities.Md5Hash(txtPassword.Text); } // Tao mot API ProfileWrapper profileWrapper = new ProfileWrapper(); // Tao bien luu ket qua tra ve bool isSuccess; // Kiem tra xem dang o che do nao if (mode == FormMode.CREATE) { // Neu dang o che do them moi (CREATE) // POST account len server isSuccess = await profileWrapper.Post(profile); } else { // Neu dang o che do chinh sua (EDIT) // PUT account len server isSuccess = await profileWrapper.Put(Convert.ToInt32(profile.ID), profile); } // Kiem tra ket qua tra ve if (isSuccess) { // Neu thanh cong MessageBox.Show("Operation completed successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); // Tat form CE this.Close(); } else { // Neu that bai, hien thong bao loi MessageBox.Show("An error has occurred:\n" + profileWrapper.GetErrorMessage(), "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public IActionResult Index() { if (!CheckLoggedIn()) { return(RedirectToAction("Index", "Home")); } int? id = HttpContext.Session.GetInt32("LOGGED_IN_USER"); User LoggedIn = _context.Users.SingleOrDefault(user => user.userid == id); List <Invite> UserInvites = _context.Invites.Include(u => u.sender).Where(i => i.userid == LoggedIn.userid).ToList(); List <Friendship> UserFriends = _context.Friends.Include(u => u.friend).Where(i => i.userid == LoggedIn.userid).ToList(); ProfileWrapper model = new ProfileWrapper(LoggedIn, UserInvites, UserFriends); return(View(model)); }
private void UpdateParameters(ProfileWrapper profile) { var panels = ToolTabs.TabPages.OfType <TabPage>().SelectMany(x => x.Controls.OfType <BuildParametersPanel>()).ToList(); foreach (var panel in panels) { if (string.Equals(panel.Tool.Name, "Shared", StringComparison.InvariantCultureIgnoreCase)) { panel.Arguments = String.Join(" ", panels.Select(x => profile.GetArguments(x.Tool.Name))); } else { panel.Arguments = profile.GetArguments(panel.Tool.Name); } } }
private async void FormTicketCE_Load(object sender, System.EventArgs e) { ProfileWrapper profileWrapper = new ProfileWrapper(); List <Profile> lstProfile = await profileWrapper.List(); AirplaneClassWrapper airplaneClassWrapper = new AirplaneClassWrapper(); List <AirplaneClass> lstAirplaneClass = await airplaneClassWrapper.List(); FlightScheduleWrapper flightScheduleWrapper = new FlightScheduleWrapper(); //List<FlightSchedule> lstFlightSchedule = await flightScheduleWrapper.List(); cboSeatClass.DataSource = lstAirplaneClass; cboSeatClass.DisplayMember = "Class"; if (formMode == FormMode.EDIT) { ticket.AirplaneClass = lstAirplaneClass.Find(ac => ac.ID == ticket.AirplaneClassID); ticket.FlightSchedules = await flightScheduleWrapper.List(ticket.ID); ticket.Profile = lstProfile.Find(p => p.ID == ticket.ProfileID); lbTicketCode.Text = "Ticket Code: " + ticket.TicketCode; txtPassengerName.Text = ticket.Profile.FirstName + " " + ticket.Profile.LastName; numChildrenCount.Value = ticket.ChildrenCount; numAdultCount.Value = ticket.AdultCount; numSeniorCount.Value = ticket.SeniorCount; cboSeatClass.SelectedItem = ticket.AirplaneClass; dpOrderDate.Value = ticket.OrderDate; cboStatus.SelectedItem = ticket.Status; numTotalCost.Value = Convert.ToDecimal(ticket.TotalCost); LoadDataGridView(ticket.FlightSchedules.ToList()); // If the ticket status is cancelled, not allow to edit if (ticket.Status == "Cancelled") { DisableEditMode(); } } else { ticket = new Ticket(); } }
public void UpdateData(ProfileWrapper newData) { newData.UpdateProfile(); }
protected UserContext(HttpContext context) { _session = new SessionWrapper(new HttpSessionStateWrapper(context.Session)); _profile = new ProfileWrapper(context.Profile); }
protected UserContext(HttpContextBase context) { _session = new SessionWrapper(context.Session); _profile = new ProfileWrapper(context.Profile); }
public async void LoadDataGridView() { // Luu lai dong hien tai dang chon int currentRowIndex; // Neu hien tai khong co dong nao duoc chon thi mac dinh la dong so 0 if (dgvTicket.SelectedRows.Count == 0) { currentRowIndex = 0; } else { currentRowIndex = dgvTicket.Rows.IndexOf(dgvTicket.SelectedRows[0]); } // Luu lai dong hien tai dang o dau` bang? trong dataGridView int firstRowIndex = dgvTicket.FirstDisplayedScrollingRowIndex; if (firstRowIndex == -1) { firstRowIndex = 0; } // Goi API lay du lieu ve ProfileWrapper profileWrapper = new ProfileWrapper(); List <Profile> lstProfile = await profileWrapper.List(); TicketWrapper ticketWrapper = new TicketWrapper(); List <Ticket> lstTicket = await ticketWrapper.List(); AirplaneClassWrapper airplaneClassWrapper = new AirplaneClassWrapper(); List <AirplaneClass> lstAirplaneClass = await airplaneClassWrapper.List(); FlightScheduleWrapper flightScheduleWrapper = new FlightScheduleWrapper(); //List<FlightSchedule> lstFlightSchedule = await flightScheduleWrapper.List(); RouteWrapper routeWrapper = new RouteWrapper(); List <Route> lstRoute = await routeWrapper.List(); CityWrapper cityWrapper = new CityWrapper(); List <City> lstCity = await cityWrapper.List(); // Tao bang de chua du lieu tra ve tu API DataTable table = new DataTable(); table.Columns.Add("ID"); table.Columns.Add("TicketCode"); table.Columns.Add("ProfileID"); table.Columns.Add("PassengerName"); table.Columns.Add("From"); table.Columns.Add("To"); table.Columns.Add("Status"); table.Columns.Add("ChildrenCount"); table.Columns.Add("AdultCount"); table.Columns.Add("SeniorCount"); table.Columns.Add("AirplaneClassID"); table.Columns.Add("AirplaneClassName"); table.Columns.Add("OrderDate"); table.Columns.Add("TotalCost"); // Kiem tra xem ket qua goi API co thanh cong hay khong if (lstTicket != null) { // Lap qua tung "dong` du lieu" foreach (Ticket ticket in lstTicket) { // Gan them du lieu len cho day du ticket.AirplaneClass = lstAirplaneClass.Find(ac => ac.ID == ticket.AirplaneClassID); ticket.FlightSchedules = await flightScheduleWrapper.List(ticket.ID); ticket.Profile = lstProfile.Find(p => p.ID == ticket.ProfileID); foreach (FlightSchedule fs in ticket.FlightSchedules) { fs.Route = lstRoute.Find(r => r.ID == fs.RouteID); fs.Route.CityA = lstCity.Find(c => c.ID == fs.Route.CityAID); fs.Route.CityB = lstCity.Find(c => c.ID == fs.Route.CityBID); } // Tao mot dong` trong bang winForm DataRow row = table.NewRow(); // Gan du lieu len dong moi tao row["ID"] = ticket.ID; row["TicketCode"] = ticket.TicketCode; row["ProfileID"] = ticket.ProfileID; row["PassengerName"] = ticket.Profile.FirstName + " " + ticket.Profile.LastName; row["From"] = ticket.FlightSchedules.First().Route.CityA.Name; row["To"] = ticket.FlightSchedules.Last().Route.CityB.Name; row["Status"] = ticket.Status; row["ChildrenCount"] = ticket.ChildrenCount; row["AdultCount"] = ticket.AdultCount; row["SeniorCount"] = ticket.SeniorCount; row["AirplaneClassID"] = ticket.AirplaneClassID; row["AirplaneClassName"] = ticket.AirplaneClass.Class; row["OrderDate"] = ticket.OrderDate; row["TotalCost"] = ticket.TotalCost; // Gan dong moi tao vao bang table.Rows.Add(row); } // Sau khi lap qua het cac dong du lieu // Ta co bang WinForm hoan chinh // Gan bang WinForm len DataGridView dgvTicket.DataSource = table; // An cac cot khong can thiet hien thi dgvTicket.Columns["ID"].Visible = false; dgvTicket.Columns["ProfileID"].Visible = false; dgvTicket.Columns["ChildrenCount"].Visible = false; dgvTicket.Columns["AdultCount"].Visible = false; dgvTicket.Columns["SeniorCount"].Visible = false; dgvTicket.Columns["AirplaneClassID"].Visible = false; // Chon lai dong ban dau duoc chon truoc khi reload if (dgvTicket.Rows.Count > 0) { dgvTicket.Rows[currentRowIndex].Selected = true; } // Cuon. toi' dong` duoc. chon. if (dgvTicket.Rows.Count > 0) { dgvTicket.FirstDisplayedScrollingRowIndex = firstRowIndex; } } }
public async void LoadDataGridView() { // Luu lai dong hien tai dang chon int currentRowIndex; // Neu hien tai khong co dong nao duoc chon thi mac dinh la dong so 0 if (dgvProfile.SelectedRows.Count == 0) { currentRowIndex = 0; } else { currentRowIndex = dgvProfile.Rows.IndexOf(dgvProfile.SelectedRows[0]); } // Luu lai dong hien tai dang o dau` bang? trong dataGridView int firstRowIndex = dgvProfile.FirstDisplayedScrollingRowIndex; if (firstRowIndex == -1) { firstRowIndex = 0; } // Goi API lay du lieu ve ProfileWrapper profileWrapper = new ProfileWrapper(); List <Profile> lstProfile = await profileWrapper.List(); // Tao bang de chua du lieu tra ve tu API DataTable table = new DataTable(); table.Columns.Add("ID"); table.Columns.Add("UserID"); table.Columns.Add("Password"); table.Columns.Add("FirstName"); table.Columns.Add("LastName"); table.Columns.Add("Address"); table.Columns.Add("PhoneNumber"); table.Columns.Add("EmailAddress"); table.Columns.Add("Sex"); table.Columns.Add("Gender"); table.Columns.Add("Age"); table.Columns.Add("CreditCard"); table.Columns.Add("SkyMiles"); table.Columns.Add("IsActive"); // Kiem tra xem ket qua goi API co thanh cong hay khong if (lstProfile != null) { // Lap qua tung "dong` du lieu" foreach (Profile profile in lstProfile) { // Tao mot dong` trong bang winForm DataRow row = table.NewRow(); // Gan du lieu len dong moi tao row["ID"] = profile.ID; row["UserID"] = profile.UserID; row["Password"] = profile.Password; row["FirstName"] = profile.FirstName; row["LastName"] = profile.LastName; row["Address"] = profile.Address; row["PhoneNumber"] = profile.PhoneNumber; row["EmailAddress"] = profile.EmailAddress; row["Sex"] = profile.Sex; row["Gender"] = profile.Sex ? "Male" : "Female"; row["Age"] = profile.Age; row["CreditCard"] = profile.CreditCard; row["SkyMiles"] = profile.SkyMiles; row["IsActive"] = profile.IsActive; // Gan dong moi tao vao bang table.Rows.Add(row); } // Sau khi lap qua het cac dong du lieu // Ta co bang WinForm hoan chinh // Gan bang WinForm len DataGridView dgvProfile.DataSource = table; // An di mot so cot trong bang dgvProfile.Columns["Password"].Visible = false; dgvProfile.Columns["Sex"].Visible = false; // Chon lai dong ban dau duoc chon truoc khi reload if (dgvProfile.Rows.Count > 0) { dgvProfile.Rows[currentRowIndex].Selected = true; } // Cuon. toi' dong` duoc. chon. if (dgvProfile.Rows.Count > 0) { dgvProfile.FirstDisplayedScrollingRowIndex = firstRowIndex; } } }