Esempio n. 1
0
        // Escribe los valores en la clase entradasmat
        private static entradasmat Loadentradasmat(IDataReader reader)
        {
            entradasmat item = new entradasmat();

            item.nsis   = Convert.ToString(reader["nsis"]);
            item.nrec   = Convert.ToString(reader["nrec"]);
            item.fech   = Convert.ToDateTime(reader["fech"]);
            item.prov   = Convert.ToString(reader["prov"]);
            item.mat    = Convert.ToString(reader["mat"]);
            item.equ    = Convert.ToString(reader["equ"]);
            item.ope    = Convert.ToString(reader["ope"]);
            item.rkm    = Convert.ToDecimal(reader["rkm"]);
            item.volm   = Convert.ToDecimal(reader["volm"]);
            item.cosm   = Convert.ToDecimal(reader["cosm"]);
            item.flem   = Convert.ToDecimal(reader["flem"]);
            item.tifkm  = Convert.ToDecimal(reader["tifkm"]);
            item.timat  = Convert.ToDecimal(reader["timat"]);
            item.anul   = Convert.ToInt32(reader["anul"]);
            item.matfle = Convert.ToDecimal(reader["matfle"]);
            item.ttra   = Convert.ToString(reader["ttra"]);
            item.hini   = Convert.ToString(reader["hini"]);
            item.hfin   = Convert.ToString(reader["hfin"]);
            item.dcarg  = Convert.ToString(reader["dcarg"]);
            //item.usu = Convert.ToString(reader["usu"]);
            return(item);
        }
Esempio n. 2
0
        // devuleve un registro en particular
        public static entradasmat GellIdentradasmat(string c, int i)
        {
            entradasmat list = null;

            using (MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["default"].ToString()))
            {
                conn.Open();
                MySqlCommand command;
                if (i == 1)
                {
                    command = new MySqlCommand("SELECT * FROM entradasmat WHERE nrec like @cod", conn);
                }
                else if (i == 2)
                {
                    command = new MySqlCommand("SELECT * FROM entradasmat WHERE nrec like @cod", conn);
                }
                else
                {
                    command = new MySqlCommand("SELECT * FROM entradasmat WHERE mat like @cod", conn);
                }
                command.Parameters.AddWithValue("@cod", c);


                MySqlDataReader reader = command.ExecuteReader();
                if (reader.HasRows == true)
                {
                    while (reader.Read())
                    {
                        list = Loadentradasmat(reader);
                    }
                }
            }
            return(list);
        }
Esempio n. 3
0
        private static entradasmat Loadresumen3(IDataReader reader)
        {
            decimal     s;
            entradasmat item = new entradasmat();

            item.ttra   = Convert.ToString(reader["nom"]);
            s           = reader["total"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["total"]);
            item.matfle = s;
            return(item);
        }
Esempio n. 4
0
        // hace las operaciones correspondiente al procedimiento almacenado.
        public static int accion(entradasmat item, int op)
        {
            int rowsAffected = 0;

            try
            {
                using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["default"].ToString()))
                {
                    con.Open();

                    MySqlCommand command = new MySqlCommand("SP_entradasmat", con);
                    command.CommandType = CommandType.StoredProcedure;

                    MySqlParameter paramId = new MySqlParameter("msj", MySqlDbType.Int32);
                    paramId.Direction = ParameterDirection.Output;
                    command.Parameters.Add(paramId);

                    command.Parameters.AddWithValue("nsis1", item.nsis);
                    command.Parameters.AddWithValue("nrec1", item.nrec);
                    command.Parameters.AddWithValue("fech1", item.fech);
                    command.Parameters.AddWithValue("prov1", item.prov);
                    command.Parameters.AddWithValue("mat1", item.mat);
                    command.Parameters.AddWithValue("equ1", item.equ);
                    command.Parameters.AddWithValue("ope1", item.ope);
                    command.Parameters.AddWithValue("rkm1", item.rkm);
                    command.Parameters.AddWithValue("volm1", item.volm);
                    command.Parameters.AddWithValue("cosm1", item.cosm);
                    command.Parameters.AddWithValue("flem1", item.flem);
                    command.Parameters.AddWithValue("tifkm1", item.tifkm);
                    command.Parameters.AddWithValue("timat1", item.timat);
                    command.Parameters.AddWithValue("anul1", item.anul);
                    command.Parameters.AddWithValue("matfle1", item.matfle);
                    command.Parameters.AddWithValue("ttra1", item.ttra);
                    command.Parameters.AddWithValue("hini1", item.hini);
                    command.Parameters.AddWithValue("hfin1", item.hfin);
                    command.Parameters.AddWithValue("dcarg1", item.dcarg);
                    command.Parameters.AddWithValue("usu", item.usu);
                    command.Parameters.AddWithValue("opc", op);
                    command.ExecuteNonQuery();
                    rowsAffected = int.Parse(command.Parameters["msj"].Value.ToString());
                }
            }
            catch (MySqlException ex)
            {
                MessageBox.Show("Error de acceso a datos: " + ex.Message.ToString(), Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex1)
            {
                MessageBox.Show("Error: " + ex1.Message.ToString(), Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(rowsAffected);
        }
Esempio n. 5
0
        private static entradasmat Loadresumen2(IDataReader reader)
        {
            //try
            //{
            decimal s;
            //cmd.Parameters.Add(new SqlParameter("@Symb", DBNull.Value.ToString()));
            entradasmat item = new entradasmat();

            item.rkm = Convert.ToInt32(reader["viajes"]);
            item.equ = Convert.ToString(reader["equ"]);

            s           = reader["total"] == DBNull.Value ? 0: Convert.ToDecimal(reader["total"]);
            item.matfle = s;
            return(item);
            //}
            //catch (Exception)
            //{

            //}
        }
Esempio n. 6
0
        private void frmmovimientosdetEXT_Load(object sender, EventArgs e)
        {
            //textBox7.Text = op_sql.parametro1("Select flete from conf_transp");
            IntPtr hmenu = GetSystemMenu(this.Handle, 0);
            int    cnt   = GetMenuItemCount(hmenu);

            // remove 'close' action
            RemoveMenu(hmenu, cnt - 1, MF_DISABLED | MF_BYPOSITION);
            // remove extra menu line
            RemoveMenu(hmenu, cnt - 2, MF_DISABLED | MF_BYPOSITION);
            DrawMenuBar(this.Handle);

            //int hora=DateTime.Now.Hour;
            //int minuto = DateTime.Now.Minute;
            //maskedTextBox1.Text = DateTime.Now.Hour();
            textBox1.Text = op_sql.parametro("Select num from tmpautonumerico where tabla=@tabla", "tabla", "entmat").PadLeft(10, '0');

            //textBox12.Text = DateTime.Now.ToShortDateString();

            comboBox3.DataSource    = op_combos.FillCombo("select cod, nom from proveedores order by 2");
            comboBox3.DisplayMember = "nom";
            comboBox3.ValueMember   = "cod";
            comboBox3.Text          = null;

            comboBox4.DataSource    = op_combos.FillCombo("select idproy as cod, nomproy as nom from proyectos where  activo=1 order by 2");
            comboBox4.DisplayMember = "nom";
            comboBox4.ValueMember   = "cod";
            comboBox4.Text          = null;


            comboBox1.DataSource    = op_documentos.transaccion();
            comboBox1.DisplayMember = "nom";
            comboBox1.ValueMember   = "cod";
            comboBox1.Text          = null;


            if (!string.IsNullOrEmpty(_id))
            {
                entradasmat c = op_entradasmat.GellIdentradasmat(_id, 1);
                if (c != null)
                {
                    this.Text                    = "Editando Registro: [Recibo: " + c.nrec + " Equipo: " + c.equ + "]";
                    this.textBox1.Text           = c.nsis;
                    this.textBox2.Text           = c.nrec;
                    this.textBox3.Text           = c.equ;
                    this.textBox7.Text           = c.flem.ToString();
                    this.comboBox2.SelectedValue = c.mat;
                    this.comboBox3.SelectedValue = c.prov;
                    this.comboBox4.SelectedValue = c.dcarg;

                    this.textBox14.Text        = c.ope;
                    this.maskedTextBox2.Text   = c.hfin;
                    this.maskedTextBox1.Text   = c.hini;
                    this.dateTimePicker1.Value = c.fech;
                    this.textBox4.Text         = c.rkm.ToString();
                    this.textBox5.Text         = c.volm.ToString();
                    this.textBox6.Text         = c.cosm.ToString();

                    this.comboBox1.SelectedValue = c.ttra;

                    TimeSpan a = TimeSpan.Parse(c.hfin) - TimeSpan.Parse(c.hini);
                    this.label5.Text      = "Tiempo de Respuesta: " + a.ToString();
                    dataGridView1.Visible = true;
                    DataGridViewRowCollection dr = dataGridView1.Rows;
                    dr.Clear();
                    dr.Add("INGRESO POR FLETE - KM", c.Tifkm.ToString("c"));
                    dr.Add("INGRESO POR MATERIAL", c.Timat.ToString("c"));
                    dr.Add("TOTAL", c.matfle.ToString("c"));

                    this.textBox13.Text      = op_sql.parametro("select nomempl from empleados where codempl=@cod order by 1", "@cod", c.ope);
                    toolStripButton5.Visible = true;
                    toolStripButton1.Visible = false;
                    toolStripButton3.Visible = false;
                    operacion();

                    //foreach (Control u in this.Controls)
                    //{
                    //    if (u is Button)
                    //        u.Enabled = true;
                    //}
                }
            }
            else
            {
                toolStripButton3.Visible = false;
                toolStripButton5.Visible = false;
                toolStripButton1.Visible = true;

                this.label5.Text = null;
                this.Text        = "Nuevo Registro - Entrada de Materiales";
            }

            textBox3.AutoCompleteCustomSource = Operaciones.autocompletar.LoadAutoComplete();
            textBox3.AutoCompleteMode         = AutoCompleteMode.Suggest;
            textBox3.AutoCompleteSource       = AutoCompleteSource.CustomSource;
        }
Esempio n. 7
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (!validacion())
            {
                return;
            }

            entradasmat c = new entradasmat();

            c.nsis   = this.textBox1.Text.Trim();
            c.nrec   = this.textBox2.Text.Trim();
            c.fech   = this.dateTimePicker1.Value;
            c.prov   = this.comboBox3.SelectedValue.ToString();
            c.mat    = this.comboBox2.SelectedValue.ToString();
            c.equ    = this.textBox3.Text.Trim();
            c.ope    = this.textBox14.Text.Trim();
            c.rkm    = Convert.ToDecimal(this.textBox4.Text.Trim());
            c.volm   = Convert.ToDecimal(this.textBox5.Text.Trim());
            c.cosm   = Convert.ToDecimal(this.textBox6.Text.Trim());
            c.flem   = Convert.ToDecimal(this.textBox7.Text.Trim());
            c.ttra   = this.comboBox1.SelectedValue.ToString();
            c.matfle = Convert.ToDecimal(c.Matfle);
            c.tifkm  = Convert.ToDecimal(c.Tifkm);
            c.timat  = Convert.ToDecimal(c.Timat);
            c.hfin   = this.maskedTextBox2.Text;
            c.hini   = this.maskedTextBox1.Text;
            c.dcarg  = this.comboBox4.SelectedValue.ToString();
            c.usu    = Operaciones.op_var.usu;

            TimeSpan a = TimeSpan.Parse(c.hfin) - TimeSpan.Parse(c.hini);

            this.label5.Text = "Tiempo de Respuesta: " + a.ToString();
            //this.label15.Text = String.Format("{0:0.00}",c.matfle);
            //this.textBox10.Text =String.Format("{0:0.00}", c.tifkm);
            //this.textBox11.Text=String.Format("{0:0.00}",c.timat);
            //c.matfle = Convert.ToDecimal(this.label15.Text.Trim());
            //c.tifkm = Convert.ToDecimal(this.textBox10.Text.Trim());
            //c.timat = Convert.ToDecimal(this.textBox11.Text.Trim());

            dataGridView1.Visible = true;
            DataGridViewRowCollection dr = dataGridView1.Rows;

            dr.Clear();
            dr.Add("INGRESO POR FLETE - KM", c.tifkm.ToString("c"));
            dr.Add("INGRESO POR MATERIAL", c.timat.ToString("c"));
            dr.Add("TOTAL", c.matfle.ToString("c"));

            int rowsAffected = 0;

            if (string.IsNullOrEmpty(_id))
            {
                rowsAffected = op_entradasmat.accion(c, 1);
            }
            else
            {
                this.textBox1.ReadOnly = true;
                //this.textBox12.ReadOnly = true;
                rowsAffected = op_entradasmat.accion(c, 2);
            }

            if (rowsAffected > 0)
            {
                if (rowsAffected == 1)
                {
                    MessageBox.Show(mensajes.MsjProc1, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    operacion();
                    this.toolStripButton3.Visible = true;
                    this.toolStripButton1.Visible = false;
                }
                if (rowsAffected == 2)
                {
                    MessageBox.Show(mensajes.MsjProc2, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    operacion();
                    this.toolStripButton3.Visible = true;
                    this.toolStripButton1.Visible = false;
                }
                if (rowsAffected == 3)
                {
                    MessageBox.Show(mensajes.MsjProc3, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                if (rowsAffected == 4)
                {
                    if (MessageBox.Show(mensajes.MsjProc4 + " " + mensajes.MsjProc5, Application.ProductName.ToString(), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        rowsAffected = op_entradasmat.accion(c, 2);
                    }
                }
            }
            else
            {
                MessageBox.Show(mensajes.MsjProc0, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }


            //this.label10.Text = "EMPLEADO: " + c.NombreCompleto;
        }