public HttpResponseMessage Delete(int id) { int check = new SessionHelper().checkSession(Constants.USERS, Constants.ACTION_DELETE); if (check > 0) { ProductsModel model = new ProductsModel(); bool resultQuery = model.delete(id); if (resultQuery) { JArray result = new JArray(); var data = model.GetAll(); result = JArray.FromObject(data); var exception = JObject.FromObject(new { err = Constants.PROCESS_OK, data = result }); return(Request.CreateResponse(HttpStatusCode.OK, exception)); } else { JObject exception = JObject.FromObject(new { err = Constants.PROCESS_FAILED, msg = Constants.DELETE_FAIL }); return(Request.CreateResponse(HttpStatusCode.OK, exception)); } } else { string message = (check == Constants.PERMISSION_LOGIN_CODE) ? Constants.PERMISSION_LOGIN_MSG : Constants.PERMISSION_DENIED_MSG; JObject exception = JObject.FromObject(new { err = check, msg = message }); return(Request.CreateResponse(HttpStatusCode.OK, exception)); } }
public HttpResponseMessage Get() { int check = new SessionHelper().checkSession(Constants.USERS, Constants.ACTION_VIEW); if (check > 0) { JArray result = new JArray(); ProductsModel model = new ProductsModel(); var resultQuery = model.GetAll(); result = JArray.FromObject(resultQuery); var exception = JObject.FromObject(new { err = 1, data = result }); return(Request.CreateResponse(HttpStatusCode.OK, exception)); } else { string message = (check == Constants.PERMISSION_LOGIN_CODE) ? Constants.PERMISSION_LOGIN_MSG : Constants.PERMISSION_DENIED_MSG; JObject exception = JObject.FromObject(new { err = check, msg = message }); return(Request.CreateResponse(HttpStatusCode.OK, exception)); } }
public void ListProducts() { try { dataProducts.DefaultCellStyle.Font = new Font("Yu Gothic UI", 9); dataProducts.DataSource = product.GetAll(); dataProducts.ReadOnly = true; dataProducts.Columns[0].HeaderText = "IdProd"; dataProducts.Columns[0].Visible = false; dataProducts.Columns[1].HeaderText = "Código"; dataProducts.Columns[2].HeaderText = "Nombre"; dataProducts.Columns[3].HeaderText = "Precio por Mayor $"; dataProducts.Columns[4].HeaderText = "Precio por Menor $"; dataProducts.Columns[5].HeaderText = "Cantidad"; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }