public static void Create(DETALLE_RECEPCION_MATERIAL rec_mat_det_new)
 {
     using (BODEXDataContext ctx = new BODEXDataContext())
     {
         ctx.ListaRecepcionMaterialDetalle.InsertOnSubmit(rec_mat_det_new);
         ctx.SubmitChanges();
     }
 }
        public static void Delete(DETALLE_RECEPCION_MATERIAL rec_mat_det_del)
        {
            using (BODEXDataContext ctx = new BODEXDataContext())
            {
                DETALLE_RECEPCION_MATERIAL borrar = (from rec_mat_det in ctx.ListaRecepcionMaterialDetalle
                                   where rec_mat_det.RM_ID.Equals(rec_mat_det_del.RM_ID)
                                   && rec_mat_det.M_ID.Equals(rec_mat_det_del.M_ID)
                                   select rec_mat_det).First<DETALLE_RECEPCION_MATERIAL>();

                ctx.ListaRecepcionMaterialDetalle.DeleteOnSubmit(borrar);
                ctx.SubmitChanges();
            }
        }
        public static void Update(DETALLE_RECEPCION_MATERIAL rec_mat_det_upd)
        {
            using (BODEXDataContext ctx = new BODEXDataContext())
            {
                DETALLE_RECEPCION_MATERIAL recepcion_mat_det = (from rec_mat_det in ctx.ListaRecepcionMaterialDetalle
                                     where rec_mat_det.RM_ID.Equals(rec_mat_det_upd.RM_ID)
                                     && rec_mat_det.M_ID.Equals(rec_mat_det_upd.M_ID)
                                     select rec_mat_det).First<DETALLE_RECEPCION_MATERIAL>();

                recepcion_mat_det.DRM_CANTIDAD= rec_mat_det_upd.DRM_CANTIDAD;

                ctx.SubmitChanges();
            }
        }
        protected void Ingresar(object sender, EventArgs e)
        {
            ASPxButton boton = (ASPxButton)sender;
            Control main = boton.Parent;

            string encargado = "Bodega";
            Label usuario = (Label)main.Parent.Parent.FindControl("lblUsuario");
            if (usuario != null)
                encargado = usuario.Text;

            ASPxListBox list = (ASPxListBox)main.FindControl("ASPxListBox1");
            ASPxComboBox combo = (ASPxComboBox)main.FindControl("ASPxComboBox1");
            string id_compra = ASPxComboBox1.SelectedItem.Value.ToString();

            if (list.Items.Count == 0)
                return;

            SOLICITUD_COMPRA compra = CRUD_SolicitudCompra.Read(Int32.Parse(id_compra));

            RECEPCION_MATERIAL recepcion = new RECEPCION_MATERIAL();
            recepcion.RM_ENCARGADO_RECEPCION = encargado;
            recepcion.RM_FECHA = DateTime.Now;
            CRUD_RecepcionMaterial.Create(recepcion);

            int id_recep = (Int32)CRUD_RecepcionMaterial.getEnd().RM_ID;

            foreach (ListEditItem item in list.Items)
            {
                MATERIAL material = CRUD_Material.Read(Int32.Parse(item.GetValue("M_ID").ToString()));
                DETALLE_RECEPCION_MATERIAL detalle = new DETALLE_RECEPCION_MATERIAL();
                detalle.RM_ID = id_recep;
                detalle.M_ID = material.M_ID;
                detalle.DRM_CANTIDAD = Int32.Parse(item.GetValue("D_CANTIDAD").ToString());

                CRUD_RecepcionMaterialDetalle.Create(detalle);
            }

            compra.E_ID = 2;
                CRUD_SolicitudCompra.Update(compra);

            COMPRA_RECEPCION ligar = new COMPRA_RECEPCION();
            ligar.SC_ID = compra.SC_ID;
            ligar.RM_ID = id_recep;
            CRUD_CompraRecepcion.Create(ligar);

            Response.Redirect("~/RecepcionMaterial.aspx");
        }
 partial void DeleteDETALLE_RECEPCION_MATERIAL(DETALLE_RECEPCION_MATERIAL instance);
 partial void InsertDETALLE_RECEPCION_MATERIAL(DETALLE_RECEPCION_MATERIAL instance);