private void comboBox3_SelectionChangeCommitted(object sender, EventArgs e) { panel1.Controls.Clear(); DataRowView row = cbCuenta.SelectedItem as DataRowView; txtCuenta.Text = row["Codigo"].ToString(); txtTipo.Text = row["Tipo"].ToString(); Clases.Requisicion.Cuenta = row["Codigo"].ToString(); __Type = row["Tipo"].ToString(); if (row["Tipo"].ToString().Equals("GENERAL")) { ctrG = new ctrlGeneral(); ctrG.Dock = DockStyle.Fill; panel1.Controls.Add(ctrG); } if (row["Tipo"].ToString().Equals("ESPECIFICA")) { ctrE = new ctrlEspecifico(); ctrE.Dock = DockStyle.Fill; panel1.Controls.Add(ctrE); } }
public void Save(ctrlGeneral ctrGrl) { ctrGrl = panel1.Controls[0] as ctrlGeneral; DataGridView dgv = ctrGrl.Controls["panel1"].Controls["dgvDetalle"] as DataGridView; if (!string.IsNullOrEmpty(ctrGrl.prov[0].CardCode == "0" ? string.Empty : ctrGrl.prov[0].CardCode)) { if (!string.IsNullOrEmpty(ctrGrl.prov[1].CardCode == "0" ? string.Empty : ctrGrl.prov[1].CardCode)) { if (!string.IsNullOrEmpty(ctrGrl.prov[2].CardCode == "0" ? string.Empty : ctrGrl.prov[2].CardCode)) { Clases.Requisicion.Estatus = "0"; Clases.Requisicion.ID = 0; Clases.Requisicion.Fecha = DateTime.Now; Clases.Requisicion.Cuenta = string.Empty; Clases.Requisicion.Tipo = string.Empty; Clases.Requisicion.Modificacion = DateTime.Now; Clases.Requisicion.Fecha = dateTimePicker1.Value; Clases.Requisicion.Cuenta = cbCuenta.SelectedValue.ToString(); Clases.Requisicion.Tipo = txtTipo.Text == "ESPECIFICA" ? "E" : "G"; Clases.Requisicion.Modificacion = DateTime.Now; if (ValidarGrid(dgv)) { if (dgv.Rows.Count > 1) { Clases.Requisicion.ExecuteReader(); txtFolio.Text = Clases.Requisicion.ID.ToString(); for (int j = 1; j <= 3; j++) { for (int i = 0; i < dgv.Rows.Count - 1; i++) { Clases.Objetos.DetalleRequisicion dreq = new Clases.Objetos.DetalleRequisicion(); dreq.ID = Clases.Requisicion.ID; dreq.NumProv = j; dreq.Proveedor = ctrGrl.prov[j - 1].CardCode; dreq.Linea = Convert.ToInt32(dgv.Rows[i].Cells["Linea"].Value); dreq.Sugerencia = Convert.ToBoolean(dgv.Rows[i].Cells["Sugerido" + j].Value == DBNull.Value ? false : dgv.Rows[i].Cells["Sugerido" + j].Value); dreq.Articulo = null; dreq.Descripcion = Convert.ToString(dgv.Rows[i].Cells["ItemName"].Value); dreq.Cantidad = Convert.ToDecimal(dgv.Rows[i].Cells["Quantity"].Value); dreq.Precio = Convert.ToDecimal(dgv.Rows[i].Cells["Price" + j].Value); dreq.LineTotal = Convert.ToDecimal(dgv.Rows[i].Cells["LineTotal" + j].Value); dreq.ExecuteNonQuery(dreq); } } lblEstatus.Text = "Listo"; } else { lblEstatus.Text = "Error: Debe ingresar al menos un artículo o servicio"; } } else { lblEstatus.Text = "Algunas lineas contien errores, corrijalos para poder continuar."; } } else { lblEstatus.Text = "Seleccione un proveedor [Proveedor 3]"; } } else { lblEstatus.Text = "Seleccione un proveedor [Proveedor 2]"; } } else { lblEstatus.Text = "Seleccione un proveedor [Proveedor 1]"; } }