private void barButtonItem6_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try {
                Cursor.Current = Cursors.WaitCursor;

                int           r = Tabla.GetSelectedRows()[0];
                GpoMateriales s = new GpoMateriales();
                s.numGpo = Int16.Parse(Tabla.GetRowCellValue(r, "numGpo").ToString());

                Object item = g.borrarGrupo(s);

                System.Reflection.PropertyInfo m = item.GetType().GetProperty("message");
                System.Reflection.PropertyInfo c = item.GetType().GetProperty("code");
                String message = (String)(m.GetValue(item, null));
                int    code    = (int)(c.GetValue(item, null));

                if (code == 1)
                {
                    vaciarCamposBusq();
                    Recargar();
                    MessageBox.Show(message, "OK", MessageBoxButtons.OK, MessageBoxIcon.None);
                }
                else if (code == 2)
                {
                    MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
        public Object editarGrupo(GpoMateriales grupo, int numGpo)
        {
            try
            {
                Object result = "";
                grupo.numGpo = (Int16)numGpo;
                using (var bd = new AlmacenEntities())
                {
                    bd.Entry(grupo).State = System.Data.Entity.EntityState.Modified;
                    bd.SaveChanges();
                    result = new { message = "Se edito correctamente", code = 1 };

                    return(result);
                }
            }
            catch (SqlException odbcEx)
            {
                Object result = new { message = "Error: " + odbcEx.Message.ToString(), code = 2 };
                return(result);
            }
            catch (Exception ex)
            {
                Object result = new { message = "Error: " + ex.Message.ToString(), code = 2 };
                return(result);
            }
        }
Esempio n. 3
0
 public Object borrarGrupo(GpoMateriales grupo)
 {
     try
     {
         string s;
         var    context    = new AlmacenEntities();
         var    connection = context.Database.Connection;
         using (SqlConnection con = new SqlConnection(connection.ConnectionString))
         {
             string query = "DELETE FROM GpoMateriales WHERE numGpo=@numGpo";
             query += " SELECT SCOPE_IDENTITY()";
             using (SqlCommand cmd = new SqlCommand(query))
             {
                 cmd.Connection = con;
                 con.Open();
                 cmd.Parameters.AddWithValue("@numGpo", grupo.numGpo);
                 s = cmd.ExecuteScalar().ToString();
                 con.Close();
             }
         }
         Object result = new { message = "Se borro correctamente", code = 1 };
         return(result);
     }
     catch (SqlException odbcEx)
     {
         Object result = new { message = "Error: " + odbcEx.Message.ToString(), code = 2 };
         return(result);
     }
     catch (Exception ex)
     {
         Object result = new { message = "Error: " + ex.Message.ToString(), code = 2 };
         return(result);
     }
 }
Esempio n. 4
0
 public Object guardarGrupo(GpoMateriales grupo)
 {
     try
     {
         Object result = "";
         using (var db = new AlmacenEntities())
         {
             var us = db.GpoMateriales.Where(u => u.numGpo == grupo.numGpo).FirstOrDefault();
             if (us == null)
             {
                 db.GpoMateriales.Add(grupo);
                 db.SaveChanges();
                 result = new { message = "Se guardo correctamente", code = 1 };
             }
             else
             {
                 result = new { message = "Ya existe este grupo: " + grupo.numGpo, code = 2 };
             }
             return(result);
         }
     }
     catch (SqlException odbcEx)
     {
         Object result = new { message = "Error: " + odbcEx.Message.ToString(), code = 2 };
         return(result);
     }
     catch (Exception ex)
     {
         Object result = new { message = "Error: " + ex.Message.ToString(), code = 2 };
         return(result);
     }
 }
        private void btnGuardar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try {
                Cursor.Current = Cursors.WaitCursor;
                if (tipo.Equals('N'))
                {
                    CheckControls(tabPage3);
                    if (contT == 0)
                    {
                        vaciarCamposBusq();
                        GpoMateriales s = new GpoMateriales();
                        s.numGpo             = Int16.Parse(editNumeroG.Text);
                        s.descripcion        = editDescripcion.Text;
                        s.cuenta_F_Z         = Int32.Parse(editCuFZ.Text);
                        s.aplicaCentCost_F_Z = editApliCeFZ.Checked;
                        s.subCuenta_F_Z      = Int32.Parse(editSubCuFZ.Text);
                        s.subSubCuenta_F_Z   = Int32.Parse(editSubSCuFZ.Text);
                        s.cuenta_A_Z         = Int32.Parse(editCuAZ.Text);
                        s.aplicaCentCost_A_Z = editApliCeAZ.Checked;
                        s.subCuenta_A_Z      = Int32.Parse(editSubCuAZ.Text);
                        s.subSubCuenta_A_Z   = Int32.Parse(editSubSCuAZ.Text);
                        s.cuenta_C_Z         = Int32.Parse(editCuCZ.Text);
                        s.aplicaCentCost_C_Z = editApliCeCZ.Checked;
                        s.subCuenta_C_Z      = Int32.Parse(editSubCuCZ.Text);
                        s.subSubCuenta_C_Z   = Int32.Parse(editSubCuCZ.Text);
                        s.cuenta_D_Z         = Int32.Parse(editCuDZ.Text);
                        s.aplicaCentCost_D_Z = editApliCeDZ.Checked;
                        s.subCuenta_D_Z      = Int32.Parse(editSubCuDZ.Text);
                        s.subSubCuenta_D_Z   = Int32.Parse(editSubSCuDZ.Text);
                        s.cuenta_F_R         = Int32.Parse(editCuFR.Text);
                        s.aplicaCentCost_F_R = editApliCeFR.Checked;
                        s.subCuenta_F_R      = Int32.Parse(editSubCuFR.Text);
                        s.subSubCuenta_F_R   = Int32.Parse(editSubSCuFR.Text);
                        s.cuenta_A_R         = Int32.Parse(editCuAR.Text);
                        s.aplicaCentCost_A_R = editApliCeAR.Checked;
                        s.subCuenta_A_R      = Int32.Parse(editSubCuAR.Text);
                        s.subSubCuenta_A_R   = Int32.Parse(editSubSCuAR.Text);
                        s.cuenta_C_R         = Int32.Parse(editCuCR.Text);
                        s.aplicaCentCost_C_R = editApliCeCR.Checked;
                        s.subCuenta_C_R      = Int32.Parse(editSubCuCR.Text);
                        s.subSubCuenta_C_R   = Int32.Parse(editSubSCuCR.Text);
                        s.cuenta_D_R         = Int32.Parse(editCuDR.Text);
                        s.aplicaCentCost_D_R = editApliCeDR.Checked;
                        s.subCuenta_D_R      = Int32.Parse(editSubCuDR.Text);
                        s.subSubCuenta_D_R   = Int32.Parse(editSubSCuDR.Text);
                        s.cantidad           = decimal.Parse(editCantidad.Text);
                        s.importe            = decimal.Parse(editImporte.Text);

                        Object item = g.guardarGrupo(s);

                        System.Reflection.PropertyInfo m = item.GetType().GetProperty("message");
                        System.Reflection.PropertyInfo c = item.GetType().GetProperty("code");
                        String message = (String)(m.GetValue(item, null));
                        int    code    = (int)(c.GetValue(item, null));

                        if (code == 1)
                        {
                            ResetControls(tabPage3);
                            DisableControls(tabPage3);
                            tipo = 's';
                            Recargar();
                            this.tabControl1.SelectTab(0);
                            MessageBox.Show(message, "OK", MessageBoxButtons.OK, MessageBoxIcon.None);
                        }
                        else if (code == 2)
                        {
                            MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Se deben de llenar todos los campos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    contT = 0;
                }
                else if (tipo.Equals('E'))
                {
                    CheckControls(tabPage3);
                    if (contT == 0)
                    {
                        vaciarCamposBusq();
                        GpoMateriales s = new GpoMateriales();
                        s.numGpo             = Int16.Parse(editNumeroG.Text);
                        s.descripcion        = editDescripcion.Text;
                        s.cuenta_F_Z         = Int32.Parse(editCuFZ.Text);
                        s.aplicaCentCost_F_Z = editApliCeFZ.Checked;
                        s.subCuenta_F_Z      = Int32.Parse(editSubCuFZ.Text);
                        s.subSubCuenta_F_Z   = Int32.Parse(editSubSCuFZ.Text);
                        s.cuenta_A_Z         = Int32.Parse(editCuAZ.Text);
                        s.aplicaCentCost_A_Z = editApliCeAZ.Checked;
                        s.subCuenta_A_Z      = Int32.Parse(editSubCuAZ.Text);
                        s.subSubCuenta_A_Z   = Int32.Parse(editSubSCuAZ.Text);
                        s.cuenta_C_Z         = Int32.Parse(editCuCZ.Text);
                        s.aplicaCentCost_C_Z = editApliCeCZ.Checked;
                        s.subCuenta_C_Z      = Int32.Parse(editSubCuCZ.Text);
                        s.subSubCuenta_C_Z   = Int32.Parse(editSubCuCZ.Text);
                        s.cuenta_D_Z         = Int32.Parse(editCuDZ.Text);
                        s.aplicaCentCost_D_Z = editApliCeDZ.Checked;
                        s.subCuenta_D_Z      = Int32.Parse(editSubCuDZ.Text);
                        s.subSubCuenta_D_Z   = Int32.Parse(editSubSCuDZ.Text);
                        s.cuenta_F_R         = Int32.Parse(editCuFR.Text);
                        s.aplicaCentCost_F_R = editApliCeFR.Checked;
                        s.subCuenta_F_R      = Int32.Parse(editSubCuFR.Text);
                        s.subSubCuenta_F_R   = Int32.Parse(editSubSCuFR.Text);
                        s.cuenta_A_R         = Int32.Parse(editCuAR.Text);
                        s.aplicaCentCost_A_R = editApliCeAR.Checked;
                        s.subCuenta_A_R      = Int32.Parse(editSubCuAR.Text);
                        s.subSubCuenta_A_R   = Int32.Parse(editSubSCuAR.Text);
                        s.cuenta_C_R         = Int32.Parse(editCuCR.Text);
                        s.aplicaCentCost_C_R = editApliCeCR.Checked;
                        s.subCuenta_C_R      = Int32.Parse(editSubCuCR.Text);
                        s.subSubCuenta_C_R   = Int32.Parse(editSubSCuCR.Text);
                        s.cuenta_D_R         = Int32.Parse(editCuDR.Text);
                        s.aplicaCentCost_D_R = editApliCeDR.Checked;
                        s.subCuenta_D_R      = Int32.Parse(editSubCuDR.Text);
                        s.subSubCuenta_D_R   = Int32.Parse(editSubSCuDR.Text);
                        s.cantidad           = decimal.Parse(editCantidad.Text);
                        s.importe            = decimal.Parse(editImporte.Text);

                        Object item = g.editarGrupo(s, numGpoA);

                        System.Reflection.PropertyInfo m = item.GetType().GetProperty("message");
                        System.Reflection.PropertyInfo c = item.GetType().GetProperty("code");
                        String message = (String)(m.GetValue(item, null));
                        int    code    = (int)(c.GetValue(item, null));

                        if (code == 1)
                        {
                            ResetControls(tabPage3);
                            DisableControls(tabPage3);
                            tipo = 's';
                            Recargar();
                            this.tabControl1.SelectTab(0);
                            MessageBox.Show(message, "OK", MessageBoxButtons.OK, MessageBoxIcon.None);
                        }
                        else if (code == 2)
                        {
                            MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Se deben de llenar todos los campos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    contT = 0;
                }
                else if (tipo.Equals('s'))
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }