//*************************************************ENCABEZADO DEL TRASPASO********************************************************************************

        public void EncabezadoTras()
        {
            if (CB_destino.SelectedIndex == -1)
            {
                MessageBox.Show("Debes seleccionar un destino de traspaso");
            }
            else if (TB_motivo.Text.Equals(""))
            {
                MessageBox.Show("Justifica el traspaso agregando un motivo");
            }
            else if (TB_origen.Text.Equals(CB_destino.SelectedItem.ToString()))
            {
                MessageBox.Show("El origen y el destino es el mismo, favor de cambiar el destino");
            }
            else
            {
                //crea el traspaso en rd_traspaso

                MySqlCommand cmd   = new MySqlCommand("insert into rd_traspaso(fecha, usuario, origen, destino, estatus, motivo) values(?fecha, ?usuario, ?origen, ?destino, ?status, ?motivo)", BDConexicon.conectar());
                DateTime     fecha = DT_fecha.Value;
                cmd.Parameters.AddWithValue("?fecha", fecha.ToString("yyyy,MM,dd"));
                cmd.Parameters.AddWithValue("?usuario", Usuario);
                cmd.Parameters.AddWithValue("?origen", TB_origen.Text);
                cmd.Parameters.AddWithValue("?destino", CB_destino.SelectedItem);
                cmd.Parameters.AddWithValue("?status", "SOLICITADO");
                cmd.Parameters.AddWithValue("?motivo", TB_motivo.Text.ToUpper());
                cmd.ExecuteNonQuery();
                //MessageBox.Show("Traspaso creado");
                BDConexicon.ConectarClose();
            }
        }
예제 #2
0
        //################################### GUARDA DATOS DE LA CUENTA X PAGAR Y LOS MANDA AL FORM DE DESGLOSE PARA PASARSELOS A LOS TEXTBOXS ########

        //public void datoCuenta(string id,string importe, string saldo)
        //{
        //    this.id = id;
        //    //this.des= des;
        //    this.importe = importe;
        //    this.saldo = saldo;
        //}
        private void Desglose_Load(object sender, EventArgs e)
        {
            //    TB_id.Text = id;
            //    //TB_descrip.Text = des;
            //    TB_importe.Text = string.Format("{0:C2}", importe);
            //    TB_saldo.Text = string.Format("{0:C2}", saldo); ;



            MySqlCommand cmd = new MySqlCommand("SELECT fecha, tipo_doc,cargo_ab,no_referen, importe from cuenxpdet where cuenxpag='" + cuenxpag + "'", BDConexicon.conectar());
            //MySqlDataAdapter da = new MySqlDataAdapter(cmd);
            //DataTable dt = new DataTable();

            //da.Fill(dt);
            //DG_datos2.DataSource = dt;

            MySqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                if (dr["cargo_ab"].ToString().Equals("C"))
                {
                    saldo += Convert.ToDouble(dr["importe"].ToString());
                }
                else
                {
                    saldo -= Convert.ToDouble(dr["importe"].ToString());
                }
                DG_datos2.Rows.Add(dr["fecha"].ToString(), dr["tipo_doc"].ToString(), dr["cargo_ab"].ToString(), dr["no_referen"].ToString(), dr["importe"].ToString(), saldo);
            }
            dr.Close();

            DG_datos2.Columns[0].Width = 130;
            DG_datos2.Columns[1].Width = 130;
            DG_datos2.Columns[3].Width = 330;
            //DG_datos2.Columns[4].Width = 200;

            //foreach (DataGridViewRow row in DG_datos2.Rows)
            //{
            //    abonos += Convert.ToDouble(row.Cells["importe"].Value);

            //}

            //TB_abono.Text = string.Format( "{0:C2}",abonos);
            BDConexicon.ConectarClose();
        }
        //########################### OBTIENE EL NOMBRE DE LA SUCURSAL ################################################################
        public void Sucursal()// obtiene el nombre de la sucursal, debe cambiar el método de conexión según la suc. donde se use
        {
            string       sucursal = "";
            MySqlCommand cmd      = new MySqlCommand("select empresa from econfig", BDConexicon.conectar());

            MySqlDataReader rd = cmd.ExecuteReader();

            while (rd.Read())
            {
                sucursal = rd[0].ToString();

                if (sucursal.Equals("OSMART VALLARTA"))
                {
                    TB_origen.Text = "VA";
                }
                if (sucursal.Equals("OSMART RENACIMIENTO"))
                {
                    TB_origen.Text = "RE";
                }
                if (sucursal.Equals("OSMART COLOSO"))
                {
                    TB_origen.Text = "CO";
                }
                if (sucursal.Equals("OSMART VELAZQUEZ"))
                {
                    TB_origen.Text = "VE";
                }
                if (sucursal.Equals("BODEGA"))
                {
                    TB_origen.Text = "BO";
                }
                if (sucursal.Equals("PREGOT"))
                {
                    TB_origen.Text = "PREGOT";
                }
            }

            BDConexicon.ConectarClose();
        }