public Boolean GrabarDB(cp_orden_giro_x_com_ordencompra_local_det_Info info, ref string mensaje)
        {
            try
            {
                using (EntitiesCuentasxPagar context = new EntitiesCuentasxPagar())
                {
                    EntitiesCuentasxPagar EDB = new EntitiesCuentasxPagar();

                    var address = new cp_orden_giro_x_com_ordencompra_local_det();

                    address.IdEmpresa_Ogiro  = info.IdEmpresa_Ogiro;
                    address.IdCbteCble_Ogiro = info.IdCbteCble_Ogiro;
                    address.IdTipoCbte_Ogiro = info.IdTipoCbte_Ogiro;
                    address.IdEmpresa_OC     = info.IdEmpresa_OC;
                    address.IdSucursal_OC    = info.IdSucursal_OC;
                    address.IdOrdenCompra    = info.IdOrdenCompra;
                    address.Secuencia_OC     = info.Secuencia_OC;
                    address.Observacion      = info.Observacion == null ? "" : info.Observacion;
                    address.Secuencia_reg    = info.Secuencia_reg;
                    context.cp_orden_giro_x_com_ordencompra_local_det.Add(address);
                    context.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.ToString() + " " + ex.Message;
                throw new Exception(ex.ToString());
            }
        }
        public List <cp_orden_giro_x_com_ordencompra_local_det_Info> Get_List_orden_giro_x_com_ordencompra_local_det(int IdEmpresa_Ogiro, decimal IdCbteCble_Ogiro, int IdTipoCbte_Ogiro, ref string mensaje)
        {
            try
            {
                List <cp_orden_giro_x_com_ordencompra_local_det_Info> lista = new List <cp_orden_giro_x_com_ordencompra_local_det_Info>();

                using (EntitiesCuentasxPagar CxP = new EntitiesCuentasxPagar())
                {
                    var Consulta = from q in CxP.vwcp_orden_giro_x_com_ordencompra_local_det_consulta
                                   where q.IdEmpresa_Ogiro == IdEmpresa_Ogiro &&
                                   q.IdCbteCble_Ogiro == IdCbteCble_Ogiro &&
                                   q.IdTipoCbte_Ogiro == IdTipoCbte_Ogiro
                                   select q;

                    foreach (var item in Consulta)
                    {
                        cp_orden_giro_x_com_ordencompra_local_det_Info info = new cp_orden_giro_x_com_ordencompra_local_det_Info();

                        info.IdEmpresa_Ogiro  = item.IdEmpresa_Ogiro;
                        info.IdCbteCble_Ogiro = item.IdCbteCble_Ogiro;
                        info.IdTipoCbte_Ogiro = item.IdTipoCbte_Ogiro;
                        info.IdEmpresa_OC     = item.IdEmpresa;
                        info.IdSucursal_OC    = item.IdSucursal;
                        info.IdOrdenCompra    = item.IdOrdenCompra;
                        info.Secuencia_OC     = item.Secuencia;
                        info.Observacion      = item.Observacion;

                        info.IdProducto      = item.IdProducto;
                        info.do_Cantidad     = item.do_Cantidad;
                        info.do_precioCompra = item.do_precioCompra;
                        info.do_porc_des     = item.do_porc_des;
                        info.do_descuento    = item.do_descuento;
                        info.do_subtotal     = item.do_subtotal;
                        info.do_iva          = item.do_iva;
                        info.do_total        = item.do_total;
                        info.producto        = item.pr_descripcion;
                        info.nom_medida      = item.nom_medida;

                        lista.Add(info);
                    }
                }

                return(lista);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "",
                                                                                          "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.ToString() + " " + ex.Message;
                throw new Exception(ex.ToString());
            }
        }
Ejemplo n.º 3
0
        private void gridView_OC_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            try
            {
                Info = (com_ordencompra_local_det_Info)this.gridView_OC.GetFocusedRow();

                e.HitInfo.Column.FieldName = gridView_OC.FocusedColumn.FieldName;

                if (e.HitInfo.Column.FieldName == "Checked")
                {
                    if ((Boolean)gridView_OC.GetFocusedRowCellValue(colChecked))
                    {
                        gridView_OC.SetFocusedRowCellValue(colChecked, false);

                        var item = List_OG_x_OCdet_AUX.FirstOrDefault(q => q.IdEmpresa_OC == Info.IdEmpresa && q.IdOrdenCompra == Info.IdOrdenCompra && q.IdSucursal_OC == Info.IdSucursal && q.Secuencia_OC == Info.Secuencia);

                        List_OG_x_OCdet_AUX.Remove(item);
                    }
                    else
                    {
                        gridView_OC.SetFocusedRowCellValue(colChecked, true);

                        info = new cp_orden_giro_x_com_ordencompra_local_det_Info();

                        info.IdOrdenCompra   = Convert.ToDecimal(gridView_OC.GetFocusedRowCellValue(colIdOrdenCompra));
                        info.IdEmpresa_OC    = Convert.ToInt32(gridView_OC.GetFocusedRowCellValue(colIdEmpresa_oc));
                        info.IdSucursal_OC   = Convert.ToInt32(gridView_OC.GetFocusedRowCellValue(colIdSucursal_oc));
                        info.Secuencia_OC    = Convert.ToInt32(gridView_OC.GetFocusedRowCellValue(colSecuencia_oc));
                        info.IdProducto      = Convert.ToDecimal(gridView_OC.GetFocusedRowCellValue(colIdProducto));
                        info.do_Cantidad     = Convert.ToDouble(gridView_OC.GetFocusedRowCellValue(coldo_Cantidad));
                        info.do_precioCompra = Convert.ToDouble(gridView_OC.GetFocusedRowCellValue(coldo_precioCompra));
                        info.do_porc_des     = Convert.ToDouble(gridView_OC.GetFocusedRowCellValue(coldo_porc_des));
                        info.do_descuento    = Convert.ToDouble(gridView_OC.GetFocusedRowCellValue(coldo_descuento));
                        info.do_subtotal     = Convert.ToDouble(gridView_OC.GetFocusedRowCellValue(coldo_subtotal));
                        info.do_iva          = Convert.ToDouble(gridView_OC.GetFocusedRowCellValue(coldo_iva));
                        info.do_total        = Convert.ToDouble(gridView_OC.GetFocusedRowCellValue(coldo_total));
                        info.Observacion     = Convert.ToString(gridView_OC.GetFocusedRowCellValue(coldo_observacion));
                        info.IdUnidadMedida  = Convert.ToString(gridView_OC.GetFocusedRowCellValue(colIdUnidadMedida));
                        info.producto        = Convert.ToString(gridView_OC.GetFocusedRowCellValue(colproducto));
                        info.nom_medida      = Convert.ToString(gridView_OC.GetFocusedRowCellValue(colnom_medida));

                        List_OG_x_OCdet_AUX.Add(info);
                    }
                }
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public Boolean GrabarDB(cp_orden_giro_x_com_ordencompra_local_det_Info info, ref string mensaje)
 {
     try
     {
         return(data.GrabarDB(info, ref mensaje));
     }
     catch (Exception ex)
     {
         Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message);
         throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "GrabarDB", ex.Message), ex)
               {
                   EntityType = typeof(cp_orden_giro_x_com_ordencompra_local_det_Bus)
               };
     }
 }
        public Boolean GuardarDB(cp_Aprobacion_Ing_Bod_x_OC_Info Info, ref decimal id, ref string msg)
        {
            try
            {
                Boolean res = true;

                if (Validar_objeto_AprobIngEgrxOC(Info, ref msg))
                {
                    //cabecera
                    res = odata.GuardarDB(Info, ref id, ref msg);

                    if (res == false)
                    {
                        return(res);
                    }

                    Info.IdAprobacion = id;

                    if (res = Generar_Orden_Giro(Info, ref msg))
                    {
                        if (res == false)
                        {
                            return(res);
                        }
                        else
                        {
                            //Info.IdEmpresa_Ogiro = 2;
                            //Info.IdCbteCble_Ogiro = 170;
                            //Info.IdTipoCbte_Ogiro = 7;
                            // actualizar campos cp_aprobacion
                            res = odata.ModificarDB(Info, ref msg);
                            if (res == false)
                            {
                                return(res);
                            }

                            // grabar tabla intermedia cp_orden_giro_x_com_ordencompra_local_det
                            int sec = 1;
                            foreach (var item in Info.listDetalle)
                            {
                                cp_orden_giro_x_com_ordencompra_local_det_Info info = new cp_orden_giro_x_com_ordencompra_local_det_Info();

                                info.IdEmpresa_Ogiro  = Convert.ToInt32(Info.IdEmpresa_Ogiro);
                                info.IdCbteCble_Ogiro = Convert.ToDecimal(Info.IdCbteCble_Ogiro);
                                info.IdTipoCbte_Ogiro = Convert.ToInt32(Info.IdTipoCbte_Ogiro);

                                info.IdEmpresa_OC  = item.IdEmpresa_Ing_Egr_Inv;
                                info.IdSucursal_OC = item.IdSucursal_OC;
                                info.IdOrdenCompra = item.IdOrdenCompra;
                                info.Secuencia_OC  = item.Secuencia_OC;
                                info.Secuencia_reg = sec;
                                sec++;
                                string msje = "";
                                cp_orden_giro_x_com_ordencompra_local_det_Bus bus = new cp_orden_giro_x_com_ordencompra_local_det_Bus();
                                if (bus.GrabarDB(info, ref msje))
                                {
                                }
                            }
                        }
                    }
                }
                else
                {
                    res = false;
                }

                return(res);
            }
            catch (Exception ex)
            {
                Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message);
                throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "GuardarDB", ex.Message), ex)
                      {
                          EntityType = typeof(cp_Aprobacion_Ing_Bod_x_OC_Bus)
                      };
            }
        }