private void btdn_Click(object sender, EventArgs e) { if (PK_TaiKhoan(TK.Text) == false) { con.Open(); SqlCommand cmd = new SqlCommand("select dsthi.msts,dsthisinh.cmnd" + " from DSTHISINH, dsthi " + " where dsthisinh.msts = dsthi.msts" + " and dsthi.msts='" + TK.Text + "'", con); SqlDataReader reader = cmd.ExecuteReader(); reader.Read(); if (reader.GetValue(1).ToString() == CM.Text) { DDN = true; MSTS = TK.Text; this.Close(); } else if (reader.GetValue(0).ToString() != CM.Text) { MessageBox.Show("Sai Mật Khẩu", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); CM.Focus(); con.Close(); return; } else { MessageBox.Show("Tài Khoản Không Tồn Tại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); TK.Focus(); con.Close(); return; } con.Close(); } }
private async void BtnGuardarDimensiones_Clicked(object sender, EventArgs e) { string connectionString = ConfigurationManager.AppSettings["ipServer"]; try { var USAV = USA.Text; var UKV = UK.Text; var EUROV = EURO.Text; var CMV = CM.Text; var CategoriaSizeV = pickerCategoriaSizes.SelectedIndex + 1; if (string.IsNullOrEmpty(USAV)) { await DisplayAlert("Validacion", "Ingrese el Size de USA", "Aceptar"); USA.Focus(); return; } if (string.IsNullOrEmpty(UKV)) { await DisplayAlert("Validacion", "Ingrese el Size de UK", "Aceptar"); UK.Focus(); return; } if (string.IsNullOrEmpty(EUROV)) { await DisplayAlert("Validacion", "Ingrese el Size de EURO", "Aceptar"); EURO.Focus(); return; } if (string.IsNullOrEmpty(CMV)) { await DisplayAlert("Validacion", "Ingrese el Size por CM", "Aceptar"); CM.Focus(); return; } if (string.IsNullOrEmpty(CategoriaSizeV.ToString())) { await DisplayAlert("Validacion", "Seleccione la Categoria del Sizes", "Aceptar"); pickerCategoriaSizes.Focus(); return; } HttpClient client = new HttpClient(); client.BaseAddress = new Uri(connectionString); var sizes = new Sizes() { SizeID = 0, USA = USAV, UK = UKV, EURO = EUROV, CM = CMV, CategoriaSizeID = CategoriaSizeV }; //Convetir a Json var json = JsonConvert.SerializeObject(sizes); StringContent stringContent = new StringContent(json, Encoding.UTF8, "application/json"); //Ejecutar el api el introduces el metodo var request = await client.PostAsync("/api/Size/registrar", stringContent); if (request.IsSuccessStatusCode) { var responseJson = await request.Content.ReadAsStringAsync(); var respuesta = JsonConvert.DeserializeObject <Request>(responseJson); //Status if (respuesta.status) { await MaterialDialog.Instance.AlertAsync(message : "Sizes registrado correctamente", title : "Registro", acknowledgementText : "Aceptar"); } else { await MaterialDialog.Instance.AlertAsync(message : "Sizes no pudo registrarse correctamente", title : "Registro", acknowledgementText : "Aceptar"); } } else { await MaterialDialog.Instance.AlertAsync(message : "Error", title : "Error", acknowledgementText : "Aceptar"); } } catch (Exception ex) { await MaterialDialog.Instance.AlertAsync(message : ex.Message, title : "Error", acknowledgementText : "Aceptar"); } await Navigation.PushAsync(new Dimensiones.GestionarDimensiones()); }