private void frmPrincipal_Load(object sender, EventArgs e) { cmbUsuarios.DataSource = null; cmbUsuarios.ValueMember = "idUser"; cmbUsuarios.DisplayMember = "username"; cmbUsuarios.DataSource = AppUserDAO.GetLista(); cmbNegociosProd.DataSource = null; cmbNegociosProd.ValueMember = "idBusiness"; cmbNegociosProd.DisplayMember = "name"; cmbNegociosProd.DataSource = BusinessDAO.GetLista(); cmbNegocios.DataSource = null; cmbNegocios.ValueMember = "idBusiness"; cmbNegocios.DisplayMember = "name"; cmbNegocios.DataSource = BusinessDAO.GetLista(); cmbProds.DataSource = null; cmbProds.ValueMember = "idProduct"; cmbProds.DisplayMember = "name"; cmbProds.DataSource = ProducDAO.GetProdsNeg(); dgUsuarios.DataSource = null; dgUsuarios.DataSource = AppUserDAO.GetLista(); dgNegocios.DataSource = null; dgNegocios.DataSource = BusinessDAO.GetLista(); }
public ActionResult Login(string username, string password) { UserDAO userDAO = new UserDAO(); if (userDAO.checkIfDontHaveUserThenCreate() == true) { ViewBag.Error = "Đã khởi tạo Admin"; return(View()); } string passwordMD5 = Encryptor.MD5Hash(password); var user = userDAO.getUser(username, passwordMD5); if (user != null) { if (user.Status == true) { Session["Username"] = user.Username; Session["Fullname"] = user.Fullname; Session["Image"] = user.Image; Session["Menu"] = new BusinessDAO().getListBusinessOfUser(username); return(RedirectToAction("Index")); } else { ViewBag.Error = "Tài khoản đã khóa"; return(View()); } } ViewBag.Error = "Username hoặc Password không xác định"; return(View()); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { if (HttpContext.Current.Session["Username"] == null) { filterContext.Result = new RedirectResult("/Admin/Home/Login"); return; } string username = HttpContext.Current.Session["Username"].ToString(); //get action string controllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName + "Controller"; BookStoreDbContext db = new BookStoreDbContext(); var admin = db.Administrators.Where(x => x.Username == username && x.isAdmin == true).FirstOrDefault(); if (admin != null) { return; } var listBusiness = new BusinessDAO().getListBusinessOfUser(username); if (!listBusiness.Select(x => x.ID).Contains(controllerName)) { filterContext.Result = new RedirectResult("/Admin/Home/_404"); return; } }
private void actualizarControlesCommon() { List <Address> listaA = AddressDAO.getLista(user.id_User); cmbAddressId.DataSource = null; cmbAddressId.DisplayMember = "idAddress"; cmbAddressId.ValueMember = "idAddress"; cmbAddressId.DataSource = listaA; cmbAiD.DataSource = null; cmbAiD.DisplayMember = "idAddress"; cmbAiD.ValueMember = "idAddress"; cmbAiD.DataSource = listaA; List <Business> listaB = BusinessDAO.getLista(); cmbBiD2.DataSource = null; cmbBiD2.DisplayMember = "idBusiness"; cmbBiD2.ValueMember = "idBusiness"; cmbBiD2.DataSource = listaB; List <Product> listaP = ProductDAO.getLista(); cmbPiD.DataSource = null; cmbPiD.DisplayMember = "idProduct"; cmbPiD.ValueMember = "idProduct"; cmbPiD.DataSource = listaP; List <AppOrder> listaO = AppOrderDAO.getListaUser(user.id_User); cmbOrderiD.DataSource = null; cmbOrderiD.DisplayMember = "idOrder"; cmbOrderiD.ValueMember = "idOrder"; cmbOrderiD.DataSource = listaO; }
private void btnBusiAction_Click(object sender, EventArgs e) { if (txtBusiName.Text.Length != 0 && txtBusiDesc.Text.Length != 0) { if (!isBusiSelected) { var business = new Business(); business.name = txtBusiName.Text; business.description = txtBusiDesc.Text; BusinessDAO.createBusiness(business); refreshBusinessFields(); fillControls(); mostrarMensajeExito(); } else { var business = new Business(); business.idBusiness = Convert.ToInt32(idBusiSelected); business.name = txtBusiName.Text; business.description = txtBusiDesc.Text; BusinessDAO.modify(business); refreshBusinessFields(); fillControls(); mostrarMensajeExito(); isBusiSelected = false; changeBusiControlState(); } } else { mostrarFuncionLlenadoCampos(); } }
private void btnAdd_Click(object sender, EventArgs e) { try { if (txtNombre.Text.Length >= 5 && txtDescripcion.Text.Length >= 5) { BusinessDAO.CrearNuevoNeg(txtNombre.Text, txtDescripcion.Text); MessageBox.Show( "Negocio agregado con éxito", "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Information); txtNombre.Clear(); txtDescripcion.Clear(); actualizarDatos(); } else { MessageBox.Show("Verifique que los datos ingresados sean válidos", "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception) { MessageBox.Show("Verifique que los datos ingresados sean válidos", "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button2_Click(object sender, EventArgs e) { Business b = new Business(); b.name = textBox3.Text; b.description = textBox5.Text; try { BusinessDAO.addBusiness(b); MessageBox.Show($"Negocio agregado exitosamente", "HugoApp - Food Delivery", MessageBoxButtons.OK, MessageBoxIcon.Information); btnClearBusiness_Click(sender, e); actualizarControlesAdmin(); actualizarTablasAdmin(); } catch (Exception exception) { MessageBox.Show("Error: " + exception.Message, "Error dialog", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void actualizarControlesAdmin() { // Realizar consulta a la base de datos List <AppUser> listaU = AppUserDAO.getLista(); cmbUserId.DataSource = null; cmbUserId.ValueMember = "id_User"; cmbUserId.DisplayMember = "id_User"; cmbUserId.DataSource = listaU; List <Business> listaB = BusinessDAO.getLista(); cmbBusinessiD.DataSource = null; cmbBusinessiD.DisplayMember = "idBusiness"; cmbBusinessiD.ValueMember = "idBusiness"; cmbBusinessiD.DataSource = listaB; cmbBiD.DataSource = null; cmbBiD.DisplayMember = "idBusiness"; cmbBiD.ValueMember = "idBusiness"; cmbBiD.DataSource = listaB; List <Product> listaP = ProductDAO.getLista(); cmbProductId.DataSource = null; cmbProductId.DisplayMember = "idProduct"; cmbProductId.ValueMember = "idProduct"; cmbProductId.DataSource = listaP; }
private void btnAddBusiness_Click(object sender, EventArgs e) { Business b = new Business(); b.Name = txtAddBusiness.Text; b.Description = rtbAddBusinessDesc.Text; try { BusinessDAO.addBusiness(b); MessageBox.Show("Negocio agregado exitosamente", "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Information); // Limpiar la vista, los eventos se pueden invocar desde codigo btnAddBusinesClear_Click(sender, e); // Actualizar la vista, los ComboBox de la primer pestana actualizarControles(); } catch (Exception exception) { MessageBox.Show("Error: " + exception.Message, "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button4_Click(object sender, EventArgs e) { try { if (textBox3.Text.Length > 0 && textBox4.Text.Length > 0) { BusinessDAO.crearNuevo(textBox3.Text, textBox4.Text); MessageBox.Show("¡Negocio agregado exitosamente!", "SourceCode", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox3.Clear(); actualizarControles(); } else { MessageBox.Show("No deje espacios en blanco", "SourceCode", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception) { MessageBox.Show("El Negocio que ha digitado, no se encuentra disponible.", "SourceCode", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public JsonResult getBusiness(string username) { BusinessDAO businessDAO = new BusinessDAO(); var listBusiness = businessDAO.getListBusiness(); var listOfUser = businessDAO.getListBusinessOfUser(username); var list = new List <BusinessViewModel>(); foreach (var item in listBusiness) { var b = new BusinessViewModel(); if (listOfUser.Contains(item)) { b.ID = item.ID; b.Name = item.Name; b.Url = item.Url; b.Status = true; } else { b.ID = item.ID; b.Name = item.Name; b.Url = item.Url; b.Status = false; } list.Add(b); } return(Json(new { username = username, data = list.OrderByDescending(x => x.Status) }, JsonRequestBehavior.AllowGet)); }
public string getDetail(string id) { var model = new BusinessDAO().getBusinessByID(id); var json = JsonConvert.SerializeObject(model, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); return(json); }
void actualizarDatos() { cmbUsuarios.DataSource = AppUserDAO.GetLista(); dgUsuarios.DataSource = AppUserDAO.GetLista(); cmbNegociosProd.DataSource = BusinessDAO.GetLista(); dgNegocios.DataSource = BusinessDAO.GetLista(); cmbNegocios.DataSource = BusinessDAO.GetLista(); dgOrdenes.DataSource = AppOrderDAO.GetLista(); cmbProds.DataSource = ProducDAO.GetProdsNeg(); }
private void poblarGrafico() { graficoProductos.Series[0].Values.Clear(); graficoProductos.AxisX[0].Labels.Clear(); foreach (BusinessxCantidad unNegocio in BusinessDAO.businxcantidad()) { graficoProductos.Series[0].Values.Add(unNegocio.Cantidad); graficoProductos.AxisX[0].Labels.Add(unNegocio.Name); } }
public string loadData() { var model = new BusinessDAO().getListBusiness(); ViewBag.CountBusiness = model; var json = JsonConvert.SerializeObject(model, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); return(json); }
private void dgvBusi_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { DataGridViewRow row = dgvBusi.Rows[e.RowIndex]; string selectedBusi = row.Cells[0].Value.ToString(); BusinessDAO.drop(selectedBusi); mostrarMensajeExito(); isBusiSelected = false; changeBusiControlState(); fillControls(); refreshBusinessFields(); }
private void button5_Click(object sender, EventArgs e) { if (MessageBox.Show("¿Seguro que desea eliminar el Negocio " + comboBox2.Text + "?", "SourceCode", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { BusinessDAO.eliminar(comboBox2.Text); MessageBox.Show("¡Negocio eliminado exitosamente!", "SourceCode", MessageBoxButtons.OK, MessageBoxIcon.Information); actualizarControles(); } }
private void btnRemoveBusiness_Click(object sender, EventArgs e) { Business b = (Business)cmbRemoveBusiness.SelectedItem; if (MessageBox.Show("¿Seguro que desea eliminar el negocio ?", "Hugo App", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { BusinessDAO.delete(b.IdBusiness); MessageBox.Show("¡Negocio eliminado exitosamente!", "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Information); } actualizarControles(); }
private void actualizarTablasAdmin() { dGUser.DataSource = null; dGUser.DataSource = AppUserDAO.getLista(); dGBusiness.DataSource = null; dGBusiness.DataSource = BusinessDAO.getLista(); dGProduct.DataSource = null; dGProduct.DataSource = ProductDAO.getLista(); dGTotalOrders.DataSource = null; dGTotalOrders.DataSource = AppOrderDAO.getLista(); }
private void btnDeleteBusiness_Click(object sender, EventArgs e) { try { BusinessDAO.removeBusiness(comboBox3.Text); MessageBox.Show("Business deleted successfully.", "HUGO", MessageBoxButtons.OK, MessageBoxIcon.Information); updateAdminControls(); } catch (Exception exception) { MessageBox.Show("Error: " + exception.Message, "Error dialog", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public JsonResult updateDescription(string businessStr) { JavaScriptSerializer serializer = new JavaScriptSerializer(); Business business = serializer.Deserialize <Business>(businessStr); bool status = false; status = new BusinessDAO().updateName(business); return(Json(new { status = true })); }
private void btnEliminarBusiness_Click(object sender, EventArgs e) { try { BusinessDAO.removeBusiness((int)cmbBusinessiD.SelectedValue); MessageBox.Show("Negocio eliminado exitosamente", "HugoApp - Food Delivery", MessageBoxButtons.OK, MessageBoxIcon.Information); actualizarControlesAdmin(); actualizarTablasAdmin(); } catch (Exception exception) { MessageBox.Show("Error: " + exception.Message, "Error dialog", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void updateAdminControls() { List <AppUser> listU = AppUserDAO.getList(); List <Business> listB = BusinessDAO.getList(); List <Product> listP = ProductDAO.getList(); List <FullOrder> listf = OrderDAO.consultOrders(); comboBox1.DataSource = null; comboBox1.DisplayMember = "username"; comboBox1.DataSource = listU; comboBox2.DataSource = null; comboBox2.DisplayMember = "username"; comboBox2.DataSource = listU; comboBox3.DataSource = null; comboBox3.DisplayMember = "name"; comboBox3.DataSource = listB; comboBox4.DataSource = null; comboBox4.DisplayMember = "name"; comboBox4.DataSource = listP; comboBox5.DataSource = null; comboBox5.DisplayMember = "name"; comboBox5.ValueMember = "idbusiness"; comboBox5.DataSource = listB; dataGridView1.DataSource = null; dataGridView1.DataSource = listU; dataGridView2.DataSource = null; dataGridView2.DataSource = listB; dataGridView3.DataSource = null; dataGridView3.DataSource = listP; dataGridView4.DataSource = null; dataGridView4.DataSource = listf; poblarGrafico(); }
private void fillControls() { List <UserDirections> directions = UserDirectionsDAO.getDirections(loggedUser.idUser.ToString()); if (loggedUser.userType) { List <User> lista = UserDAO.GetUsers(); List <Business> businesses = BusinessDAO.getBusiness(); List <Product> products = ProductDAO.getAll(); cmbProBusi.DataSource = null; cmbProBusi.ValueMember = "idbusiness"; cmbProBusi.DisplayMember = "name"; cmbProBusi.DataSource = businesses; // Tabla (data grid view) dtvUsers.DataSource = null; dtvUsers.DataSource = lista; //Escondiendo la columna de la clave dtvUsers.Columns[3].Visible = false; dtvUsers.Columns[0].Visible = false; dgvBusi.DataSource = null; dgvBusi.DataSource = businesses; dgvPro.DataSource = null; dgvPro.DataSource = products; } else { if (!hasCheckedUserType) { tabControl1.TabPages[0].Parent = null; tabControl1.TabPages[1].Parent = null; hasCheckedUserType = true; } } dgvDirections.DataSource = null; dgvDirections.DataSource = directions; }
private void actualizarControlesUsuario() { // cmbUsOrderBussines cmbUsOrderBussines.DataSource = null; cmbUsOrderBussines.ValueMember = "IdBusiness"; cmbUsOrderBussines.DisplayMember = "Name"; cmbUsOrderBussines.DataSource = BusinessDAO.getLista(); // cmbUsOrderProduct cmbUsOrderProduct.DataSource = null; cmbUsOrderProduct.ValueMember = "IdProduct"; cmbUsOrderProduct.DisplayMember = "Name"; cmbUsOrderProduct.DataSource = ProductDAO.getLista(); // cmbUsOrderAddr cmbUsOrderAddr.DataSource = null; cmbUsOrderAddr.ValueMember = "IdAddress"; cmbUsOrderAddr.DisplayMember = "Addr"; cmbUsOrderAddr.DataSource = AddressDAO.getLista(user); //tabla dgvUserOrders.DataSource = null; dgvUserOrders.DataSource = AppOrderDAO.getLista(user); }
public ActionResult UpdateBusiness() { MyReflectionController rc = new MyReflectionController(); List <Type> listControllerType = rc.GetControllers("BookStore.Areas.Admin"); List <string> listControllerOld = new BusinessDAO().getListBusiness().Select(x => x.ID).ToList(); foreach (var item in listControllerType) { if (!listControllerOld.Contains(item.Name) && item.Name != "CommonController") { var url = "/Admin/" + item.Name.Replace("Controller", "") + "/Index"; Business b = new Business() { ID = item.Name, Name = "Empty", Url = url }; db.Businesses.Add(b); } } db.SaveChanges(); ViewBag.Success = true; return(RedirectToAction("Index")); }
private void actualizarControles() { // cmbUsOrderBussines cmbUsOrderBussines.DataSource = null; cmbUsOrderBussines.ValueMember = "IdBusiness"; cmbUsOrderBussines.DisplayMember = "Name"; cmbUsOrderBussines.DataSource = BusinessDAO.getLista(); // cmbUsOrderProduct cmbUsOrderProduct.DataSource = null; cmbUsOrderProduct.ValueMember = "IdProduct"; cmbUsOrderProduct.DisplayMember = "Name"; cmbUsOrderProduct.DataSource = ProductDAO.getLista(); // cmbUsOrderAddr cmbUsOrderAddr.DataSource = null; cmbUsOrderAddr.ValueMember = "IdUsuario"; cmbUsOrderAddr.DisplayMember = "Nombres"; cmbUsOrderAddr.DataSource = AddressDAO.getLista(); /*// cmbProductoPedido * cmbProductoPedido.DataSource = null; * cmbProductoPedido.ValueMember = "IdProducto"; * cmbProductoPedido.DisplayMember = "Nombres"; * cmbProductoPedido.DataSource = InventarioDAO.getLista(); * // Menu desplegable (combo box) * cmbUsuario.DataSource = null; * cmbUsuario.ValueMember = "IdUsuario"; * cmbUsuario.DisplayMember = "Nombres"; * cmbUsuario.DataSource = UsuarioDAO.getLista(); * // cmbProdMantenimiento * cmbProdMantenimiento.DataSource = null; * cmbProdMantenimiento.ValueMember = "IdProducto"; * cmbProdMantenimiento.DisplayMember = "Nombres"; * cmbProdMantenimiento.DataSource = InventarioDAO.getLista(); * //nudStockMantenimiento * Inventario i = (Inventario) cmbProdMantenimiento.SelectedItem; * nudStockMantenimiento.Value = i.Stock; * nudPrecioMantenimiento.Value = Convert.ToDecimal(i.Precio);*/ }
private void actualizarControles() { //tabla negocios dgvBusiness.DataSource = null; dgvBusiness.DataSource = BusinessDAO.getLista(); //dgvProducts dgvProducts.DataSource = null; dgvProducts.DataSource = ProductDAO.getLista(); //cmbRemoveBusiness cmbRemoveBusiness.DataSource = null; cmbRemoveBusiness.ValueMember = "IdBusiness"; cmbRemoveBusiness.DisplayMember = "Name"; cmbRemoveBusiness.DataSource = BusinessDAO.getLista(); //cmbAddProductBusiness cmbAddProductBusiness.DataSource = null; cmbAddProductBusiness.ValueMember = "IdBusiness"; cmbAddProductBusiness.DisplayMember = "Name"; cmbAddProductBusiness.DataSource = BusinessDAO.getLista(); //cmbRmvProdc Business b = (Business)cmbAddProductBusiness.SelectedItem; cmbRmvProdc.DataSource = null; cmbRmvProdc.ValueMember = "IdProduct"; cmbRmvProdc.DisplayMember = "Name"; cmbRmvProdc.DataSource = ProductDAO.getLista(b); //cmbAlterAppuser cmbAlterAppuser.DataSource = null; cmbAlterAppuser.ValueMember = "IdUser"; cmbAlterAppuser.DisplayMember = "Username"; cmbAlterAppuser.DataSource = AppuserDAO.getLista(); //dgvAdminOrders dgvAdminOrders.DataSource = null; dgvAdminOrders.DataSource = AppuserDAO.getLista(); poblarGrafico(); }
private void btnAddBusiness_Click(object sender, EventArgs e) { Business b = new Business(); b.name = textBox5.Text; b.description = richTextBox1.Text; try { BusinessDAO.addBusiness(b); MessageBox.Show("Business added successfully.", "HUGO", MessageBoxButtons.OK, MessageBoxIcon.Information); btnClearBusiness_Click_1(sender, e); updateAdminControls(); } catch (Exception exception) { MessageBox.Show("Error: " + exception.Message, "Error dialog", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void actualizarControles() { List <AppUser> lista = AppUserDAO.getLista(); dataGridView1.DataSource = null; dataGridView1.DataSource = lista; comboBox1.DataSource = null; comboBox1.DisplayMember = "iduser"; comboBox1.DataSource = lista; List <Business> list = BusinessDAO.getLista(); comboBox2.DataSource = null; comboBox2.DisplayMember = "idbusiness"; comboBox2.DataSource = list; List <Product> lis = ProductDAO.getLista(); comboBox3.DataSource = null; comboBox3.DisplayMember = "idbusiness"; comboBox3.DataSource = list; comboBox4.DataSource = null; comboBox4.DisplayMember = "idbusiness"; comboBox4.DataSource = list; List <Adress> listAdress = AdressDAO.getLista(); comboBox6.DataSource = null; comboBox6.DisplayMember = "idbusiness"; comboBox6.DataSource = list; List <AppOrder> listOrders = AppOrderDAO.getLista(); comboBox8.DataSource = null; comboBox8.DisplayMember = "idorder"; comboBox8.DataSource = listOrders; dataGridView2.DataSource = null; dataGridView2.DataSource = listOrders; comboBox7.DataSource = null; comboBox7.DisplayMember = "idproduct"; comboBox7.DataSource = lis; comboBox5.DataSource = null; comboBox5.DisplayMember = "idadress"; comboBox5.DataSource = listAdress; List <Adress> listaAdress = AdressDAO.getListaAdress(appuser.iduser); dataGridView3.DataSource = null; dataGridView3.DataSource = listaAdress; List <AppOrder> listaAppOrders = AppOrderDAO.getListaAppOrder(appuser.iduser); dataGridView5.DataSource = null; dataGridView5.DataSource = listaAppOrders; }