public bool Insertar(BE_TEMPUS_MOSTRAR entCabecera) { bool booResult = false; DatosMySql xMiFuncion = new DatosMySql(); MySqlTransaction trans; trans = mysConec.BeginTransaction(); try { booResult = xMiFuncion.StoreEjecutar("tempus_mostrar_insertar", entCabecera, mysConec, 1); if (booResult == false) { booOcurrioError = xMiFuncion.booOcurrioError; StrErrorMensaje = xMiFuncion.StrErrorMensaje; IntErrorNumber = xMiFuncion.IntErrorNumber; trans.Rollback(); return(booResult); } trans.Commit(); return(booResult); } catch (Exception exc) { // SI SUCEDE UN ERROR DEVOLVEMOS FALSO booOcurrioError = xMiFuncion.booOcurrioError; StrErrorMensaje = xMiFuncion.StrErrorMensaje; IntErrorNumber = xMiFuncion.IntErrorNumber; trans.Rollback(); return(booResult); } }
public bool Insertar(List <BE_TEMPUS_MOSTRAR> lst_empleados) { CD_TEMPUS_mostrar miFun = new CD_TEMPUS_mostrar(); bool booOk = false; miFun.mysConec = mysConec; foreach (BE_TEMPUS_MOSTRAR element in lst_empleados) { BE_TEMPUS_MOSTRAR ent_empleados = new BE_TEMPUS_MOSTRAR(); ent_empleados.c_codemp = element.c_codemp; ent_empleados.c_idemp = element.c_idemp; ent_empleados.n_mostrar = element.n_mostrar; booOk = miFun.Insertar(ent_empleados); } booOcurrioError = miFun.booOcurrioError; StrErrorMensaje = miFun.StrErrorMensaje; IntErrorNumber = miFun.IntErrorNumber; return(booOk); }
private void CmdOk_Click(object sender, EventArgs e) { int n_fila = 0; List <BE_TEMPUS_MOSTRAR> lstEmpleados = new List <BE_TEMPUS_MOSTRAR>(); CN_TEMPUS_mostrar objFun = new CN_TEMPUS_mostrar(); objFun.mysConec = mysConec; objFun.Eliminar(c_CodEmpresa); for (n_fila = 2; n_fila <= FgEmpleados.Rows.Count - 1; n_fila++) { BE_TEMPUS_MOSTRAR ent_empleado = new BE_TEMPUS_MOSTRAR(); ent_empleado.c_idemp = c_CodEmpresa; ent_empleado.c_codemp = FgEmpleados.GetData(n_fila, 4).ToString(); if (FgEmpleados.GetData(n_fila, 3).ToString() == "True") { ent_empleado.n_mostrar = 1; } else { ent_empleado.n_mostrar = 0; } lstEmpleados.Add(ent_empleado); } if (objFun.Insertar(lstEmpleados) == true) { MessageBox.Show("El datos se actualizaron con exito", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } else { MessageBox.Show("No se pudieron actualizar los registros por el siguiente motivo :" + objFun.StrErrorMensaje, "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } b_Grabo = true; this.Hide(); }