Ejemplo n.º 1
0
        public void UpdateStatus(int id, int status, String repairer, String comment)
        {
            SqlCommand cmd;

            cmd = cnn.CreateCommand();
            if (status == 3)
            {
                cmd.CommandText = "UPDATE [PTR].[dbo].[FailRecord] SET [status] = @stt,[TimeResume]=@now, [Repairer]=@repairer,[Comment]=@comment WHERE [RecordId] = @id";
                cmd.Parameters.AddWithValue("@now", ServerTime.current());
                cmd.Parameters.AddWithValue("@id", id);
                cmd.Parameters.AddWithValue("@stt", status);
                cmd.Parameters.AddWithValue("@repairer", repairer);
                cmd.Parameters.AddWithValue("@comment", comment);
                cmd.ExecuteNonQuery();
                cmd             = cnn.CreateCommand();
                cmd.CommandText = "UPDATE [PTR].[dbo].[FailRecord] SET [Duration] = DATEDIFF(MINUTE,[TimeStop],[TimeResume]) WHERE [RecordId] = @id";
                cmd.Parameters.AddWithValue("@id", id);
                cmd.ExecuteNonQuery();
            }
            else
            {
                cmd.CommandText = "UPDATE [PTR].[dbo].[FailRecord] SET [status] = @stt, [Repairer]=@repairer WHERE [RecordId] = @id";

                cmd.Parameters.AddWithValue("@id", id);
                cmd.Parameters.AddWithValue("@stt", status);
                cmd.Parameters.AddWithValue("@repairer", repairer);
                cmd.ExecuteNonQuery();
            }
        }
Ejemplo n.º 2
0
        public void UpdateTimeResume()
        {
            SqlCommand cmd;

            cmd = cnn.CreateCommand();
            DateTime now = ServerTime.current();

            cmd.CommandText = "UPDATE [PTR].[dbo].[FailRecord] SET [TimeResume] = @n WHERE [status] <> 3";

            cmd.Parameters.AddWithValue("@n", now);
            cmd.ExecuteNonQuery();


            cmd             = cnn.CreateCommand();
            cmd.CommandText = "UPDATE [PTR].[dbo].[FailRecord] SET [Duration] = DATEDIFF(MINUTE,[TimeStop],[TimeResume])";
            cmd.ExecuteNonQuery();
        }