Ejemplo n.º 1
0
 private void btnAddCounter2_Click(object sender, EventArgs e)
 {
     this.TopMost = false;
     try
     {
         using (frmMomentalCounter f = new frmMomentalCounter())
         {
             if (f.ShowDialog() == DialogResult.OK)
             {
                 using (SqlConnection cn = new SqlConnection(prop.Connection_string))
                 {
                     cn.Open();
                     SqlCommand cmd = new SqlCommand();
                     cmd.Connection = cn;
                     cmd.CommandTimeout = 9000;
                     cmd.CommandText = "INSERT INTO [dbo].[mcounters] ([mcounter],[date_mcounter],[id_user],[name_user]) VALUES (" + ((long)f.txtCounter.Value).ToString() + ",getdate()," + usr.Id_user + ",'" + usr.Name + "')";
                     cmd.ExecuteNonQuery();
                 }
                 FillCounters();
             }
         }
     }
     catch { }
     this.TopMost = prop.Mod_operator_top_most;
 }
Ejemplo n.º 2
0
        private void gridCounter2_DoubleClick(object sender, EventArgs e)
        {
            this.TopMost = false;
            if (gridCounter2.Row > 0)
            {
                if (gridCounter2.GetData(gridCounter2.Row, gridCounter2.Selection.LeftCol) != null)
                {
                    if (int.Parse(gridCounter2.Rows[gridCounter2.Row][1].ToString()) > 0)
                    {
                        using (frmMomentalCounter f = new frmMomentalCounter(int.Parse(gridCounter2.Rows[gridCounter2.Row][3].ToString())))
                        {
                            if (f.ShowDialog() == DialogResult.OK)
                            {
                                using (SqlConnection cn = new SqlConnection(prop.Connection_string))
                                {
                                    cn.Open();
                                    SqlCommand cmd = new SqlCommand();
                                    cmd.Connection = cn;
                                    cmd.CommandTimeout = 9000;
                                    cmd.CommandText = "UPDATE [dbo].[mcounters] SET [mcounter] = " + ((long)f.txtCounter.Value).ToString() + ", [id_user] = " + usr.Id_user + ", [name_user] = '" + usr.Name + "', [exported] = 0 WHERE id_mcounter  = " + int.Parse(gridCounter2.Rows[gridCounter2.Row][1].ToString());
                                    cmd.ExecuteNonQuery();
                                }
                                FillCounters();

                            }
                        }
                    }
                }
            }
            this.TopMost = prop.Mod_operator_top_most;
        }